示例#1
0
        public async Task <IActionResult> Index(PlannedSearch search, int page = 1)
        {
            try
            {
                PlannedWhereBuilder plannedWhereBuilder = new PlannedWhereBuilder(search);

                string searchParams = search != default ? search.ToString() : default;

                List <PlannedPreviewViewModel> plannings = await GetPage(search, plannedWhereBuilder, searchParams, page);

                string plannedCountKey = $"{MedicConstants.Planned} - {searchParams}";

                if (!base.MedicCache.TryGetValue(plannedCountKey, out int planningsCount))
                {
                    planningsCount = await PlannedService
                                     .GetPlanningsCountAsync(plannedWhereBuilder);

                    base.MedicCache.Set(plannedCountKey, planningsCount);
                }

                List <SexOption> sexOptions = base.GetDefaultSexes();
                sexOptions.AddRange(await base.GetSexesAsync());

                List <HealthRegionOption> healthRegions = base.GetDefaultHealthRegions();
                healthRegions.AddRange(await base.GetHealthRegionsAsync());

                return(View(new PlannedPageIndexModel()
                {
                    Plannings = plannings,
                    Title = MedicDataLocalization.Get(MedicDataLocalization.Plannings),
                    Description = MedicDataLocalization.Get(MedicDataLocalization.Plannings),
                    Keywords = MedicDataLocalization.Get(MedicDataLocalization.PlanningsSummary),
                    Search = search,
                    CurrentPage = page,
                    TotalPages = base.TotalPages((int)search.Length, planningsCount),
                    TotalResults = planningsCount,
                    Sexes = sexOptions,
                    HealthRegions = healthRegions
                }));
            }
            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 ex;
            }
        }
示例#2
0
        public async Task <IActionResult> Login(LoginInputModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(new AccountPageLoginModel()
                    {
                        Title = GeneralLocalization.Get(GeneralLocalization.Login),
                        Description = GeneralLocalization.Get(GeneralLocalization.Login),
                        Keywords = GeneralLocalization.Get(GeneralLocalization.Login),
                        LoginInputModel = model
                    }));
                }

                IR.SignInResult result = await SignInManager.PasswordSignInAsync(model.Username, model.Password, model.RememberMe, false);

                if (!result.Succeeded)
                {
                    ModelState.AddModelError(string.Empty, GeneralLocalization.Get(GeneralLocalization.InvalidTry));

                    return(View(new AccountPageLoginModel()
                    {
                        Title = GeneralLocalization.Get(GeneralLocalization.Login),
                        Description = GeneralLocalization.Get(GeneralLocalization.Login),
                        Keywords = GeneralLocalization.Get(GeneralLocalization.Login),
                        LoginInputModel = model
                    }));
                }

                if (!string.IsNullOrWhiteSpace(model.ReturnUrl) && Url.IsLocalUrl(model.ReturnUrl))
                {
                    return(this.Redirect(model.ReturnUrl));
                }

                return(RedirectToAction(nameof(HomeController.Index), GetControllerName(nameof(HomeController))));
            }
            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;
            }
        }
示例#3
0
        public async Task <IActionResult> Index(TransferSearch search, int page = 1)
        {
            try
            {
                TransferWhereBuilder plannedWhereBuilder = new TransferWhereBuilder(search);

                string searchParams = search != default ? search.ToString() : default;

                List <TransferPreviewViewModel> trasnfers = await GetPage(search, plannedWhereBuilder, searchParams, page);

                string trasnferCountKey = $"{MedicConstants.Transfers} - {searchParams}";

                if (!base.MedicCache.TryGetValue(trasnferCountKey, out int trasnfersCount))
                {
                    trasnfersCount = await TransferService
                                     .GetTrasnfersCountAsync(plannedWhereBuilder);

                    base.MedicCache.Set(trasnferCountKey, trasnfersCount);
                }

                return(View(new TransferPageIndexModel()
                {
                    Transfers = trasnfers,
                    Title = MedicDataLocalization.Get(MedicDataLocalization.Transfers),
                    Description = MedicDataLocalization.Get(MedicDataLocalization.Transfers),
                    Keywords = MedicDataLocalization.Get(MedicDataLocalization.TransfersSummary),
                    Search = search,
                    CurrentPage = page,
                    TotalPages = base.TotalPages((int)search.Length, trasnfersCount),
                    TotalResults = trasnfersCount
                }));
            }
            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 ex;
            }
        }
        public async Task <IActionResult> Index(ProtocolDrugTherapySearch search, int page = 1)
        {
            try
            {
                ProtocolDrugTherapyWhereBuilder protocolDrugTherapyWhereBuilder = new ProtocolDrugTherapyWhereBuilder(search);

                string searchParams = search != default ? search.ToString() : default;

                List <ProtocolDrugTherapyPreviewViewModel> protocolDrugTherapies = await GetPage(search, protocolDrugTherapyWhereBuilder, searchParams, page);

                string protocolDrugTherapiesCountKey = $"{MedicConstants.ProtocolDrugTherapies} - {searchParams}";

                if (!base.MedicCache.TryGetValue(protocolDrugTherapiesCountKey, out int protocolDrugTherapiesCount))
                {
                    protocolDrugTherapiesCount = await ProtocolDrugTherapyService
                                                 .GetProtocolDrugTherapiesCountAsync(protocolDrugTherapyWhereBuilder);

                    base.MedicCache.Set(protocolDrugTherapiesCountKey, protocolDrugTherapiesCount);
                }

                List <string> atcNames = new List <string>()
                {
                    default
                };

                if (!base.MedicCache.TryGetValue(MedicConstants.AtcNames, out List <string> addedAtcNames))
                {
                    addedAtcNames = await DrugProtocolService.GetDrugProtocolATCNames();

                    addedAtcNames.Sort((x, y) => x.CompareTo(y));

                    base.MedicCache.Set(MedicConstants.AtcNames, addedAtcNames);
                }

                atcNames.AddRange(addedAtcNames);

                List <SexOption> sexOptions = base.GetDefaultSexes();
                sexOptions.AddRange(await base.GetSexesAsync());

                List <HealthRegionOption> healthRegions = base.GetDefaultHealthRegions();
                healthRegions.AddRange(await base.GetHealthRegionsAsync());

                return(View(new ProtocolDrugTherapyPageIndexModel()
                {
                    ProtocolDrugTherapies = protocolDrugTherapies,
                    Title = MedicDataLocalization.Get(MedicDataLocalization.ProtocolDrugTherapies),
                    Description = MedicDataLocalization.Get(MedicDataLocalization.ProtocolDrugTherapies),
                    Keywords = MedicDataLocalization.Get(MedicDataLocalization.ProtocolDrugTherapiesSummary),
                    Search = search,
                    CurrentPage = page,
                    TotalPages = base.TotalPages((int)search.Length, protocolDrugTherapiesCount),
                    TotalResults = protocolDrugTherapiesCount,
                    Sexes = sexOptions,
                    HealthRegions = healthRegions,
                    ATCNames = atcNames
                }));
            }
            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;
            }
        }
        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;
            }
        }
示例#6
0
        public async Task <IActionResult> Index(OutSearch search, int page = 1)
        {
            try
            {
                OutWhereBuilder outWhereBuilder = new OutWhereBuilder(search);

                string searchParams = search != default ? search.ToString() : default;

                string outsCountKey = $"{MedicConstants.OutsCount} - {searchParams}";

                List <OutPreviewViewModel> outs = await GetPage(search, outWhereBuilder, searchParams, page);

                if (!base.MedicCache.TryGetValue(outsCountKey, out int outsCount))
                {
                    outsCount = await OutService.GetOutsCountAsync(outWhereBuilder);

                    base.MedicCache.Set(outsCountKey, outsCount);
                }

                List <SexOption> sexOptions = base.GetDefaultSexes();
                sexOptions.AddRange(await base.GetSexesAsync());

                List <HealthRegionOption> healthRegions = base.GetDefaultHealthRegions();
                healthRegions.AddRange(await base.GetHealthRegionsAsync());

                List <UsedDrugCodeOption> usedDrugs = new List <UsedDrugCodeOption>()
                {
                    new UsedDrugCodeOption()
                    {
                        Key = string.Empty, Code = MedicDataLocalization.Get(MedicDataLocalization.NoSelection)
                    }
                };

                if (!MedicCache.TryGetValue(MedicConstants.UsedDrugs, out List <UsedDrugCodeOption> drugs))
                {
                    drugs = await UsedDrugService.UsedDrugsByCodeAsync();

                    MedicCache.Set(MedicConstants.UsedDrugs, drugs);
                }

                usedDrugs.AddRange(drugs);

                return(View(new OutPageIndexModel()
                {
                    Outs = outs,
                    Title = MedicDataLocalization.Get(MedicDataLocalization.OutsView),
                    Description = MedicDataLocalization.Get(MedicDataLocalization.OutsView),
                    Keywords = MedicDataLocalization.Get(MedicDataLocalization.OutsSummary),
                    Search = search,
                    CurrentPage = page,
                    TotalPages = base.TotalPages((int)search.Length, outsCount),
                    TotalResults = outsCount,
                    Sexes = sexOptions,
                    UsedDrugCodes = usedDrugs,
                    HealthRegions = healthRegions
                }));
            }
            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;
            }
        }