public IActionResult ReportConfirm(int id) { if (HttpContext.Session.GetString("LoginID") == null) { return(RedirectToAction("Login", "Users")); } CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext; User user = context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID"))); if (!(HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin")) { return(RedirectToAction("Error", "Admin")); } ServiceReport meh = context.getServiceReport(id); double totalmshremain = context.GetRemainingMSHByCompany(meh); if (totalmshremain < meh.MSHUsed) { TempData["error"] = "The company you are trying to confirm currently does not have enough remaining MSH."; return(RedirectToAction("Report", new { id })); } context.LogAction("Service Report", "Service Report (SRN: " + id + ") has been confirmed.", context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID")))); context.ReportConfirm(id); ServiceReport remains = context.SubtractMSHUsingSR(context.getServiceReport(id)); while (remains.MSHUsed != 0) { remains = context.SubtractMSHUsingSR(remains); } Debug.WriteLine("hi id = " + id); return(RedirectToAction("ViewReports")); }