Ejemplo n.º 1
0
        public virtual Request UpdateRequest(RequestModel <TUserModel> requestModel)
        {
            var request        = ConvertToRequest(requestModel);
            var updatedRequest = RequestsRepository.UpdateRequest(request,
                                                                  !RequestSecurityService.InRole(AclRole.Administrator));

            return(updatedRequest);
        }
Ejemplo n.º 2
0
        public IEnumerable <MailMessage> UpdateRequestEmails(Request request)
        {
            var messages = new List <MailMessage>();

            if (request.User.Roles.Any(r => r.IdRole == 1))
            {
                return(messages);
            }

            if (_requestSecurityService.InRole(AclRole.Administrator))
            {
                return(messages);
            }
            var requester          = request.User;
            var waitAgreementUsers = _requestService.GetWaitAgreementUsers(request.IdRequest,
                                                                           _requestService.GetRequestAgreements(request.IdRequest).ToList()).ToList();

            if (!string.IsNullOrEmpty(requester.Email))
            {
                var message = UpdateRequestRequesterEmail(request, waitAgreementUsers);
                messages.Add(message);
            }
            foreach (var user in waitAgreementUsers)
            {
                if (string.IsNullOrEmpty(user.Email))
                {
                    continue;
                }
                var message = UpdateRequestCoordinatorEmail(request, user);
                messages.Add(message);
            }
            if (request.IdCurrentRequestStateType == 2)
            {
                var users = _requestSecurityService.GetUsersBy(AclRole.Dispatcher)
                            .Union(_requestSecurityService.GetUsersBy(AclRole.Registrar));
                foreach (var user in users)
                {
                    if (string.IsNullOrEmpty(user.Email))
                    {
                        continue;
                    }
                    var message = UpdateRequestDispatcherEmail(request, user);
                    messages.Add(message);
                }
            }

            return(messages);
        }