Example #1
0
        public async Task <IActionResult> Excel(InClinicProcedureSearch search, int page = 1)
        {
            try
            {
                InClinicProcedureWhereBuilder inClinicProcedureWhereBuilder = new InClinicProcedureWhereBuilder(search);

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

                List <InClinicProcedurePreviewViewModel> inClinicProcedures = await GetPage(search, inClinicProcedureWhereBuilder, searchParams, page);

                if (inClinicProcedures == default)
                {
                    return(BadRequest());
                }

                return(await base.FormatModel <InClinicProcedurePreviewViewModel>(inClinicProcedures, MedicDataLocalization.InClinicProcedures, FormattableFactory));
            }
            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;
            }
        }
Example #2
0
        public async Task <IActionResult> Index(InClinicProcedureSearch search, int page = 1)
        {
            try
            {
                InClinicProcedureWhereBuilder inClinicProcedureWhereBuilder = new InClinicProcedureWhereBuilder(search);

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

                string inclinicProceduresCountKey = $"{MedicConstants.InClinicProcedures} - {searchParams}";

                List <InClinicProcedurePreviewViewModel> inClinicProcedures = await GetPage(search, inClinicProcedureWhereBuilder, searchParams, page);

                if (!base.MedicCache.TryGetValue(inclinicProceduresCountKey, out int inClinicProceduresCount))
                {
                    inClinicProceduresCount = await InClinicProcedureService
                                              .GetInClinicProceduresCountAsync(inClinicProcedureWhereBuilder);

                    base.MedicCache.Set(inclinicProceduresCountKey, inClinicProceduresCount);
                }

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

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

                return(View(new InClinicProcedurePageIndexModel()
                {
                    InClinicProcedures = inClinicProcedures,
                    Title = MedicDataLocalization.Get(MedicDataLocalization.InClinicProcedures),
                    Description = MedicDataLocalization.Get(MedicDataLocalization.InClinicProcedures),
                    Keywords = MedicDataLocalization.Get(MedicDataLocalization.InClinicProceduresSummary),
                    Search = search,
                    CurrentPage = page,
                    TotalPages = base.TotalPages((int)search.Length, inClinicProceduresCount),
                    TotalResults = inClinicProceduresCount,
                    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;
            }
        }