// GET: BonusPool public ActionResult Index() { var model = new BonusPoolCalculatorViewModel { // todo make API model AllEmployees = _mappable.Map <IEnumerable <HrEmployeeViewModel> >(_service.GetAll()) }; return(View(model)); }
private static void ReadCLPRFiles(IMappable mapper, DbContextOptionsBuilder <MedicContext> builder, string directoryPath) { string invalidCLPRFileMessage = "Invalid CLPR file."; string[] files = Directory.GetFiles(directoryPath, "*.xml"); IMedicXmlParser medicXmlParser = new DefaultMedicXmlParser(new GetXmlParameters()); int counter = 1; foreach (string file in files) { using FileStream sr = new FileStream(file, FileMode.Open, FileAccess.Read); CLPR.HospitalPractice clprFile = medicXmlParser.ParseXML <CLPR.HospitalPractice>(sr); if (clprFile != default) { HospitalPractice hospitalPracticeEntity = mapper.Map <HospitalPractice, CLPR.HospitalPractice>(clprFile); if (hospitalPracticeEntity != default) { using MedicContext medicContext = new MedicContext(builder.Options); using IImportMedicFile importMedicFile = new ImportMedicFile(medicContext); importMedicFile.ImportHospitalPractice(hospitalPracticeEntity); consoleWriter.Notify($"{file} - imported, ({counter++}/{files.Length})."); } else { consoleWriter.Notify(invalidCLPRFileMessage); } } else { consoleWriter.Notify(invalidCLPRFileMessage); } } }
public object Ap(IMappable m) { return(m.Map(Value)); }
public async Task <IActionResult> CPFile(IFormFile CpFileFormFile) { try { string error = default; if (CpFileFormFile != default) { CP.CPFile cpFileModel = MedicXmlParser .ParseXML <CP.CPFile>(CpFileFormFile.OpenReadStream()); if (cpFileModel != default) { CPFile cpFileEntity = Mapper.Map <CPFile, CP.CPFile>(cpFileModel); await Task.Run(() => ImportMedicFile.ImportCPFile(cpFileEntity)); ClearCache(); } else { error = MedicDataLocalization.Get(MedicDataLocalization.InvalidFile); } } else { error = MedicDataLocalization.Get(MedicDataLocalization.InvalidFile); } return(View(new FileUploadPageCPFile() { Title = MedicDataLocalization.Get(MedicDataLocalization.CPFile), Description = MedicDataLocalization.Get(MedicDataLocalization.CPFile), Keywords = MedicDataLocalization.Get(MedicDataLocalization.CPFileSummary), Error = error })); } catch (XmlException xmlEx) { Task <int> _ = MedicLoggerService.SaveAsync(new Log() { Message = xmlEx.Message, InnerExceptionMessage = xmlEx?.InnerException?.Message ?? null, Source = xmlEx.Source, StackTrace = xmlEx.StackTrace, Date = DateTime.Now }); return(View(new FileUploadPageCPFile() { Title = MedicDataLocalization.Get(MedicDataLocalization.CPFile), Description = MedicDataLocalization.Get(MedicDataLocalization.CPFile), Keywords = MedicDataLocalization.Get(MedicDataLocalization.CPFileSummary), Error = MedicDataLocalization.Get(MedicDataLocalization.InvalidFile) })); } catch (InvalidOperationException invalOpEx) { Task <int> _ = MedicLoggerService.SaveAsync(new Log() { Message = invalOpEx.Message, InnerExceptionMessage = invalOpEx?.InnerException?.Message ?? null, Source = invalOpEx.Source, StackTrace = invalOpEx.StackTrace, Date = DateTime.Now }); return(View(new FileUploadPageCPFile() { Title = MedicDataLocalization.Get(MedicDataLocalization.CPFile), Description = MedicDataLocalization.Get(MedicDataLocalization.CPFile), Keywords = MedicDataLocalization.Get(MedicDataLocalization.CPFileSummary), Error = MedicDataLocalization.Get(MedicDataLocalization.InvalidFile) })); } catch (Exception ex) { Task <int> _ = MedicLoggerService.SaveAsync(new Log() { Message = ex.Message, InnerExceptionMessage = ex?.InnerException?.Message ?? null, Source = ex.Source, StackTrace = ex.StackTrace, Date = DateTime.Now }); throw; } }