From dd0385c4dd275eb515a6294ccd9612b0d796f6e6 Mon Sep 17 00:00:00 2001 From: cult Date: Wed, 3 Nov 2021 15:53:31 +0500 Subject: [PATCH] CS2-104: Added .Include() filemarks to fileInfoDto queries --- .../Services/FileService.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/AsbCloudInfrastructure/Services/FileService.cs b/AsbCloudInfrastructure/Services/FileService.cs index 7de88c0f..0b8a8c5b 100644 --- a/AsbCloudInfrastructure/Services/FileService.cs +++ b/AsbCloudInfrastructure/Services/FileService.cs @@ -33,7 +33,7 @@ namespace AsbCloudInfrastructure.Services } public async Task 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 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 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> 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 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 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 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);