ProcessAction() public method

public ProcessAction ( ActionTypeEnum actionTypeEnum, IEntity entity ) : void
actionTypeEnum ActionTypeEnum
entity IEntity
return void
Exemplo n.º 1
0
		public void Save()
		{
			var serviceWse = ServiceManager.GetService<CommentService>();

			var commentDto = new DataConverter<Comment>().Convert<CommentDTO>(this);
			try
			{
				bool isNew = !commentDto.ID.HasValue || commentDto.ID.Value <= 0;
				if (isNew)
				{
					serviceWse.Create(commentDto);
				}
				else
				{
					serviceWse.Update(commentDto);
				}

				var actionProcessor = new ActionProcessor();
				actionProcessor.ProcessAction(isNew ? ActionTypeEnum.Add : ActionTypeEnum.Update, this);
			}
			catch (Exception e)
			{
				log.Debug("Error catched", e);

				if (e.Message.Contains("should not be empty"))
				{
					ActionProcessor.LastAction = ("The description of comment should not be empty");
					ActionProcessor.IsError = true;
				}
				else
				{
					throw;
				}
			}
		}
Exemplo n.º 2
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;
			}
		}
Exemplo n.º 3
0
		public static void Save(Requester requester)
		{
			log.DebugFormat("Save requester with id '{0}'", requester.ID);
			var service = ServiceManager.GetService<RequesterService>();
			var dto = new DataConverter<Requester>().Convert<RequesterDTO>(requester);
			int? requesterId;

			if (requester.IsNew)
			{
				requesterId = service.Create(dto);
			}
			else
			{
				service.Update(dto);
				requesterId = dto.ID;
				DataPortal.Instance.ResetCachedValue(typeof(Requester), requesterId);
			}
			
			var actionProcessor = new ActionProcessor();
			requester.ID = requesterId;
			requester.UserID = requesterId;
			ActionTypeEnum actionTypeEnum = requester.IsNew ? ActionTypeEnum.Add : ActionTypeEnum.Update;
			actionProcessor.ProcessAction(actionTypeEnum, requester);
		}