Beispiel #1
0
        public ActionResult AddCoordinator(int idRequest, Coordinator coordinator, string sendDescription)
        {
            var request = _requestService.GetRequestById(idRequest);

            if (!_securityService.CanAddCoordinator(request))
            {
                return(RedirectToAction("ForbiddenError", "Home"));
            }
            try
            {
                _requestService.AddCooordinator(idRequest, coordinator, sendDescription);
                _requestService.SaveChanges();
                var emails = _emailBuilder.AddCoordinatorEmails(
                    _requestService.GetRequestById(idRequest, true),
                    coordinator, sendDescription);
                _emailSender.Send(emails);
            }
            catch (DbUpdateException e)
            {
                return(RedirectToAction("ConflictError", "Home",
                                        new { message = ExceptionHelper.RollToInnerException(e).Message }));
            }
            ViewData["SecurityService"] = _securityService;
            return(PartialView("Request/AgreementsContent", _requestService.GetRequestViewModelBy(request)));
        }