public async Task <int> Create([FromBody] CreateAppendiceCommand createAppendiceCommand) { createAppendiceCommand.CreatedBy = User.Identity.GetUserName(); createAppendiceCommand.CreatedOn = DateTime.Now; createAppendiceCommand.Deleted = false; createAppendiceCommand.FileName = await UploadAppendices(createAppendiceCommand); return(await Mediator.Send(createAppendiceCommand)); }
private Task <string> UploadAppendices(CreateAppendiceCommand command) { List <string> files = new List <string>(); string folderPath = GetFolderPath(command.Code); if (command.Files != null && command.Files.Any()) { foreach (HttpFile file in command.Files) { string filePath = $"{folderPath}/{file.FileName}"; command.LinkFile = $"/downloadfile/viewfile?sourcedoc={folderPath.Replace(UploadFolderPath, string.Empty)}/{file.FileName}"; files.Add(file.FileName); SaveAs(filePath, file); } } return(Task.FromResult(string.Join(";", files))); }
public static Appendice ToAppendice(this CreateAppendiceCommand command) { return(command.MapTo <CreateAppendiceCommand, Appendice>()); }