public ActionResult AcceptCancelRequest(int idRequest) { var request = _requestService.GetRequestById(idRequest); if (!_securityService.CanAcceptCancelRequest(request)) { return(RedirectToAction("ForbiddenError", "Home")); } try { _requestService.AcceptCancelRequest(idRequest); _requestService.SaveChanges(); var agreementReason = request.RequestAgreements.Where(r => r.IdAgreementState == 3).Select(r => r.AgreementDescription) .Aggregate((v, acc) => v + "<br>" + acc); var emails = _emailBuilder.SetRequestStateEmails( _requestService.GetRequestById(idRequest, true), 5, agreementReason); _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))); }