public ActionResult Index(FinancialSummaryIndexModel model) { model.Load(db, Permissions); if (User.IsInRole("RegionReadOnly")) { model.RegionId = db.Users.Where(f => f.UserName == User.Identity.Name).Select(f => f.RegionId).SingleOrDefault(); } return(View("Index", model)); }
public ActionResult IndexExport(FinancialSummaryIndexModel model) { db.CommandTimeout = 180; model.iDisplayStart = 0; model.iDisplayLength = int.MaxValue; var result = model.Data(db, Permissions); var missingExRates = result.Where(f => f.Amount == null).Select(f => new { f.Cur, f.AppName }).Distinct().ToList(); if (missingExRates.Any()) { model.Load(db, Permissions); if (User.IsInRole("RegionReadOnly")) { model.RegionId = db.Users.Where(f => f.UserName == User.Identity.Name).Select(f => f.RegionId).SingleOrDefault(); } foreach (var item in missingExRates) { var msg = string.Format("No exchange rate is defined for the {0} in the app {1}", item.Cur, item.AppName); this.ModelState.AddModelError("", msg); } return(View("Index", model)); } return(this.Excel("output", "data", result.ToList())); }