public ActionResult EditRepair(int id) { var result = GetLoggedInUser(new[] { Role.Cleaner, Role.Engineer, Role.HeadCleaner, Role.HeadEngineer }); if (result is ActionResult) { return(result as ActionResult); } var user = (User)result; var _logic = new SRLogic(Role.Engineer) { User = user }; var viewmodel = new EditRepairViewModel(); if (user.Role != Role.HeadEngineer) { _logic.Error = "You do not have permission to do this!"; TempData["SRLogic"] = _logic; return(RedirectToAction("Index", "SR")); } viewmodel.RepairToChange = _logic.GetRepairToEdit(id); viewmodel.Id = viewmodel.RepairToChange.Id; viewmodel.AssignedWorkers = _logic.AssignedWorkers; return(View(viewmodel)); }
public ActionResult MarkAsDone(int id) { var logic = new SRLogic(); var markasdonemodel = new MarkAsDoneViewModel(); var result = GetLoggedInUser(new[] { Role.Cleaner, Role.Engineer, Role.HeadCleaner, Role.HeadEngineer }); if (result is ActionResult) { return(result as ActionResult); } var user = (User)result; if (user.Role == Role.HeadEngineer || user.Role == Role.Engineer) { var servicetomarkasdone = logic.GetRepairToEdit(id); markasdonemodel.RepairMarkAsDone = servicetomarkasdone; markasdonemodel.Serviceid = servicetomarkasdone.Id; } if (user.Role == Role.HeadCleaner || user.Role == Role.Cleaner) { var servicetomarkasdone = logic.GetCleaningToEdit(id); markasdonemodel.CleaningMarkAsDone = servicetomarkasdone; markasdonemodel.Serviceid = servicetomarkasdone.Id; } markasdonemodel.User = user; return(View(markasdonemodel)); }