CS2-104: Added .Include() filemarks to fileInfoDto queries

This commit is contained in:
cult 2021-11-03 15:53:31 +05:00
parent 8d73f0e471
commit dd0385c4dd

View File

@ -33,7 +33,7 @@ namespace AsbCloudInfrastructure.Services
}
public async Task<string> GetFileWebUrlAsync(FileInfoDto fileInfo, string userLogin,
CancellationToken token = default)
CancellationToken token)
{
var fileWebUrl = fileInfo.PublishInfo?.WebStorageFileUrl;
@ -49,7 +49,7 @@ namespace AsbCloudInfrastructure.Services
}
public async Task<FileInfoDto> MoveAsync(int idWell, int? idUser, int idCategory,
string destinationFileName, string srcFilePath, CancellationToken token = default)
string destinationFileName, string srcFilePath, CancellationToken token)
{
destinationFileName = Path.GetFileName(destinationFileName);
srcFilePath = Path.GetFullPath(srcFilePath);
@ -82,7 +82,7 @@ namespace AsbCloudInfrastructure.Services
}
public async Task<FileInfoDto> SaveAsync(int idWell, int? idUser, int idCategory,
string fileFullName, Stream fileStream, CancellationToken token = default)
string fileFullName, Stream fileStream, CancellationToken token)
{
//save info to db
var fileInfo = new AsbCloudDb.Model.FileInfo()
@ -119,7 +119,7 @@ namespace AsbCloudInfrastructure.Services
}
public async Task<IEnumerable<FileInfoDto>> GetInfosByCategoryAsync(int idWell,
int idCategory, CancellationToken token = default)
int idCategory, CancellationToken token)
{
var entities = await dbSetConfigured
.Include(f => f.FileMarks)
@ -137,19 +137,18 @@ namespace AsbCloudInfrastructure.Services
DateTime end = default, int skip = 0, int take = 32, CancellationToken token = default)
{
var query = dbSetConfigured
.Include(f => f.FileMarks)
.Where(e => e.IdWell == idWell &&
e.IdCategory == idCategory);
query = query.Where(e => !e.IsDeleted);
if (idCategory == 13)
query = query.Include(f => f.FileMarks);
e.IdCategory == idCategory &&
!e.IsDeleted);
if (!string.IsNullOrEmpty(companyName))
query = query
.Include(file => file.Author)
.ThenInclude(a => a.Company)
.Where(e => (e.Author == null) || (e.Author.Company == null) || e.Author.Company.Caption.Contains(companyName));
.Where(e => (e.Author == null) ||
(e.Author.Company == null) ||
e.Author.Company.Caption.Contains(companyName));
if (!string.IsNullOrEmpty(fileName))
query = query.Where(e => e.Name.ToLower().Contains(fileName.ToLower()));
@ -189,9 +188,10 @@ namespace AsbCloudInfrastructure.Services
}
public async Task<FileInfoDto> GetInfoAsync(int fileId,
CancellationToken token = default)
CancellationToken token)
{
var entity = await dbSetConfigured
.Include(f => f.FileMarks)
.AsNoTracking()
.FirstOrDefaultAsync(f => f.Id == fileId, token)
.ConfigureAwait(false);
@ -289,7 +289,7 @@ namespace AsbCloudInfrastructure.Services
}
private async Task<string> PublishFileToCloudAsync(string filePath, string originalName,
CancellationToken token = default)
CancellationToken token)
{
await using var fileStream = File.Open(filePath, FileMode.Open);
var uploadedFileId = await googleDriveService.UploadFileAsync(fileStream, originalName,
@ -304,7 +304,7 @@ namespace AsbCloudInfrastructure.Services
}
private async Task<int> SaveWeblinkToFileInfo(int idFileInfo, string userLogin, string weblink,
CancellationToken token = default)
CancellationToken token)
{
var fileInfo = await db.Files.FirstOrDefaultAsync(f => f.Id == idFileInfo, token)
.ConfigureAwait(false);