public async Task <IActionResult> Index() { var month = DateTime.Now.Month; var year = DateTime.Now.Year; if (month == 1) { year = year - 1; month = 12; } else { month = month - 1; } ViewBag.Month = month; ViewBag.Year = year; var sources = await _context.Sources.ToListAsync(); var sourcesSelectListItems = from s in sources select new SelectListItem { Value = s.SourceId.ToString(), Text = s.Description }; ViewBag.Months = ConstData.MonthsSelectList(); ViewBag.Sources = sourcesSelectListItems.ToList(); return(View()); }
public IActionResult Index() { var month = DateTime.Now.Month; var year = DateTime.Now.Year; if (month == 1) { year = year--; month = 12; } else { month = month--; } ViewBag.Month = month; ViewBag.Year = year; ViewBag.Months = ConstData.MonthsSelectList(); return(View()); }