public async Task <IActionResult> Excel(InsSearch search, int page = 1) { try { InWhereBuilder inWhereBuilder = new InWhereBuilder(search); string searchParams = search != default ? search.ToString() : default; List <InPreviewViewModel> ins = await GetPage(search, inWhereBuilder, searchParams, page); if (ins == default) { return(BadRequest()); } return(await base.FormatModel <InPreviewViewModel>(ins, MedicDataLocalization.Ins, 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; } }
public async Task <IActionResult> Index(InsSearch search, int page = 1) { try { InWhereBuilder inWhereBuilder = new InWhereBuilder(search); string searchParams = search != default ? search.ToString() : default; string insCountKey = $"{MedicConstants.InsCount} - {searchParams}"; List <InPreviewViewModel> ins = await GetPage(search, inWhereBuilder, searchParams, page); if (!base.MedicCache.TryGetValue(insCountKey, out int insCount)) { insCount = await InService.GetInsCountAsync(inWhereBuilder); base.MedicCache.Set(insCountKey, insCount); } List <SexOption> sexOptions = base.GetDefaultSexes(); sexOptions.AddRange(await base.GetSexesAsync()); List <HealthRegionOption> healthRegions = base.GetDefaultHealthRegions(); healthRegions.AddRange(await base.GetHealthRegionsAsync()); return(View(new InPageIndexModel() { Ins = ins, Title = MedicDataLocalization.Get(MedicDataLocalization.InsView), Description = MedicDataLocalization.Get(MedicDataLocalization.InsView), Keywords = MedicDataLocalization.Get(MedicDataLocalization.InsSummary), Search = search, CurrentPage = page, TotalPages = base.TotalPages((int)search.Length, insCount), TotalResults = insCount, 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; } }