CS2-56: Changed tuple to FileInfoDto

This commit is contained in:
KharchenkoVV 2021-08-19 17:32:22 +05:00
parent 8b5af8d32e
commit d0deefe74f
3 changed files with 17 additions and 14 deletions

View File

@ -10,9 +10,8 @@ namespace AsbCloudApp.Services
public interface IFileService public interface IFileService
{ {
string RootPath { get; } string RootPath { get; }
IDictionary<string, int> SaveFileInfos(int idWell, IDictionary<string, int> SaveFileInfos(int idWell, int idUser,
int idCategory, IEnumerable<(string fileName, int idWell, int idCategory, IEnumerable<FileInfoDto> filesInfo);
DateTime date, int idUser)> filesInfo);
Task SaveFile(int idWell, int idCategory, int fileId, Task SaveFile(int idWell, int idCategory, int fileId,
string fileExtension, Stream fileStream); string fileExtension, Stream fileStream);

View File

@ -23,8 +23,8 @@ namespace AsbCloudInfrastructure.Services
this.db = db; this.db = db;
} }
public IDictionary<string, int> SaveFileInfos(int idWell, int idCategory, public IDictionary<string, int> SaveFileInfos(int idWell, int idUser,
IEnumerable<(string fileName, int idWell, int idCategory, DateTime date, int idUser)> filesInfo) IEnumerable<FileInfoDto> filesInfo)
{ {
var fileIdsToNames = new Dictionary<string, int>(); var fileIdsToNames = new Dictionary<string, int>();
@ -32,11 +32,11 @@ namespace AsbCloudInfrastructure.Services
{ {
var file = new AsbCloudDb.Model.FileInfo() var file = new AsbCloudDb.Model.FileInfo()
{ {
Name = fileInfo.fileName, Name = fileInfo.Name,
IdWell = fileInfo.idWell, IdWell = idWell,
IdCategory = fileInfo.idCategory, IdCategory = fileInfo.IdCategory,
UploadDate = fileInfo.date, UploadDate = fileInfo.UploadDate,
IdAuthor = fileInfo.idUser IdAuthor = idUser
}; };
db.Files.Add(file); db.Files.Add(file);

View File

@ -48,11 +48,15 @@ namespace AsbCloudWebApi.Controllers
idWell, token).ConfigureAwait(false)) idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
var fileInfoCollection = files.Select(f => var fileInfoCollection = files.Select(f => new FileInfoDto
(f.FileName, idWell, idCategory, DateTime.Now, (int)idUser)); {
Name = f.FileName,
IdCategory = idCategory,
UploadDate = DateTime.Now
});
var fileNamesAndIds = fileService.SaveFileInfos(idWell, var fileNamesAndIds = fileService.SaveFileInfos(idWell, (int)idUser,
idCategory, fileInfoCollection); fileInfoCollection);
foreach (var file in files) foreach (var file in files)