Ejemplo n.º 1
0
        public ActionResult EditCleaning(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.Cleaner)
            {
                User = user
            };
            var viewmodel = new EditCleaningViewModel();

            if (user.Role != Role.HeadCleaner)
            {
                _logic.Error        = "You do not have permission to do this!";
                TempData["SRLogic"] = _logic;

                return(RedirectToAction("Index", "SR"));
            }
            if (viewmodel.EndDate < viewmodel.StartDate)
            {
                viewmodel.EndDate = null;
            }
            viewmodel.CleaningToChange = _logic.GetCleaningToEdit(id);
            viewmodel.Id = viewmodel.CleaningToChange.Id;
            viewmodel.AssignedWorkers = _logic.AssignedWorkers;

            return(View(viewmodel));
        }
Ejemplo n.º 2
0
        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));
        }