Esempio n. 1
0
        public IActionResult ReportDelete(int id)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            //checkowner
            CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;
            //enter user
            User user = context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID")));

            if (!(HttpContext.Session.GetString("AdminValidity") == "Admin" || HttpContext.Session.GetString("AdminValidity") == "Super Admin" || (user.FirstName + user.LastName) == context.getServiceReport(id).ReportFrom))
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (context.getServiceReport(id).ReportStatus != "Confirmed")
            {
                context.DeleteReport(id);
            }

            context.LogAction("Service Report", "Service Report (SRN: " + id + ") has been deleted.", context.GetUser(Convert.ToInt32(HttpContext.Session.GetString("LoginID"))));
            return(RedirectToAction("ViewReports"));
        }