Inheritance: RequestDTO, IEntity
		public static bool HaveRightToViewRequest(Request request)
		{
			if (request.OwnerID == Requester.LoggedUserID)
			{
				return true;
			}
			if (request.Requesters.Any(x => x.RequesterID == Requester.LoggedUserID))
			{
				return true;
			}
			if (request.IsPrivate == true)
			{
				return false;
			}
			if (Settings.Scope == RequestScope.Private)
			{
				return false;
			}

			return true;
		}
Example #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;
			}
		}
Example #3
0
		public static Request RetrieveToEditOrCreate(int? requestID)
		{
			var request = new Request();
			if (requestID > 0)
			{
				request = RetrieveToEdit(requestID) ?? request;
			}
			if (request.IsNew)
			{
				var list = RetrieveProducts();
				if (list.Count == 1)
				{
					request.ProjectID = list[0].ID;
				}
			}
			return request;
		}