Exemple #1
0
        public static void Save(Request request)
        {
            var service = ServiceManager.GetService <RequestService>();
            var dto     = new DataConverter <Request>().Convert <RequestDTO>(request);

            dto.SourceType = RequestSourceEnum.External;
            var actionTypeEnum = request.IsNew ? ActionTypeEnum.Add : ActionTypeEnum.Update;

            try
            {
                if (request.IsNew)
                {
                    request.ID        = service.Save(dto, Requester.Logged.ID, request.IsUrgent);
                    request.RequestID = request.ID;
                }
                else
                {
                    request.LastEditorID = Requester.Logged.ID;
                    service.Update(dto);
                }

                var actionProcessor = new ActionProcessor();

                actionProcessor.ProcessAction(actionTypeEnum, request);
            }
            catch (Exception ex)
            {
                log.Debug("Error catched", ex);

                var error = ex.Message;

                if (ex.Message.Contains("AccessDeniedException"))
                {
                    error = "The request was not posted. Access is denied.";
                }

                if (ex.Message.Contains("password is invalid"))
                {
                    error = "The request was not posted. The provided password is invalid.";
                }

                ActionProcessor.SetLastAction(error, null, ActionTypeEnum.None);
                ActionProcessor.IsError = true;
            }
        }