public async Task SubmitApplication(IConfiguration config, FilesSignViewModel model) { try { foreach (var file in model.files) { if (file.idFileStore != Guid.Empty) { var fileStore = DataService.GetEntity <FileStore>(x => x.Id == file.idFileStore).FirstOrDefault(); DataService.Remove(fileStore); await DataService.SaveChangesAsync(); var fileStoreNew = new FileStoreDTO { FileType = FileType.Unknown, OrigFileName = file.name + ".p7s", FileSize = FileSignHelper.GetOriginalLengthInBytes(file.file), Ock = file.isSystemFile, EntityId = fileStore.EntityId, EntityName = fileStore.EntityName, ContentType = ".p7s", Description = "Підписаний файл лікарських засобів" }; await FileSignHelper.SaveFile(config, file, fileStoreNew, DataService); } else { var fileStore = new FileStoreDTO { FileType = FileType.Unknown, OrigFileName = file.name + ".p7s", FileSize = FileSignHelper.GetOriginalLengthInBytes(file.file), Ock = file.isSystemFile, EntityId = model.id, EntityName = nameof(ImlApplication), ContentType = ".p7s", Description = "Підписаний PDF заяви" }; await FileSignHelper.SaveFile(config, file, fileStore, DataService); } } } catch (Exception e) { Log.Error(e.Message); throw; } var app = DataService.GetEntity <ImlApplication>(x => x.Id == model.id)?.FirstOrDefault(); app.AppState = "Submitted"; app.BackOfficeAppState = "Submitted"; app.IsCreatedOnPortal = true; await DataService.SaveChangesAsync(); }
public async Task SubmitBackOfficeApplication(IConfiguration config, Guid appId) { var application = DataService.GetEntity <PrlApplication>(x => x.Id == appId).FirstOrDefault(); if (application == null) { throw new Exception(); } byte[] file; try { file = await GetApplicationFile(appId, application.AppSort); } catch (Exception e) { throw e; } var fileStore = new FileStoreDTO { FileType = FileType.Pdf, OrigFileName = "PDF заяви.pdf", FileSize = file.Length, EntityId = appId, EntityName = nameof(PrlApplication), ContentType = ".pdf", Description = "PDF заяви" }; await FileSignHelper.SaveFile(config, new FilesViewModel() { name = "PDF заяви", file = Convert.ToBase64String(file) }, fileStore, DataService); application.AppState = "Submitted"; application.BackOfficeAppState = "Submitted"; await DataService.SaveChangesAsync(); }