Example #1
0
		public ConditionViewModel(OrderCondition orderCondition)
		{
			if (orderCondition != null)
			{
				OrderId = orderCondition.OrderId.HasValue ? orderCondition.OrderId.Value : default(int);
				Status = orderCondition.Status;
				Description = orderCondition.Description;
				LenderResponse = orderCondition.LenderResponse;
				ConditionId = orderCondition.Identity;
			}
		}
Example #2
0
		public ConditionViewModel AddCondition(int orderId, OrderConditionStatus orderConditionStatus, int conditionId, string text)
		{
			var condition = _referenceRepository.GetConditionList().FirstOrDefault(e => e.Id == conditionId);
			if (condition == null)
			{
				return new ConditionViewModel { Description = string.Empty, LenderResponse = null, Status = OrderConditionStatus.Created };
			}

			var description = condition.DisplayName.Replace("@@userInput", text);

			var order = _orderManager.GetOrderById(orderId);
			if (!AllowAddCondition(order))
			{
				return new ConditionViewModel();
			}

			var orderCondition = new OrderCondition
														{
															Status = orderConditionStatus,
															LenderResponse = null,
															Description = description,
															CreationDate = DateTime.Now,
															Identity = Guid.NewGuid()
														};
			order.Conditions.Add(orderCondition);
			SetConditionCreatedStatus(order);

			_orderHistoryManager.AddConditionNote(orderId, description);
			_notificationManager.SheduleOrderLinkedEntityPeriodicalNotifications(order, OrderPeriodicalNotificationType.ConditionCreatedNotification, orderCondition.Identity);
			_notificationManager.SheduleOrderLinkedEntityPeriodicalNotifications(order, OrderPeriodicalNotificationType.ConditionResponseEscalation, orderCondition.Identity);

			return new ConditionViewModel(orderCondition)
							{
								AllowEditDescription = AllwoEditDescription(orderCondition),
								AllowEditResponse = AllowEditResponse(orderCondition),
								AllowEditStatus = AllowEditStatus(orderCondition),
								AllowRemoveCondition = AllowRemoveCondition(orderCondition)
							};
		}
Example #3
0
		private bool AllowRemoveCondition(OrderCondition orderCondition)
		{
			var roleNotAllowedRemoveCondition = new[]
			                                    	{
			                                    		RoleType.Appraiser, RoleType.AppraisalCompanyAdmin, RoleType.CompanyAdminAndAppraiser, RoleType.LoanOfficer, RoleType.Processor, RoleType.CloserFunder
			                                    	};

			return _securityContext.CurrentUser.Roles.Select(e => e.RoleType).All(e => !roleNotAllowedRemoveCondition.Contains(e)) &&
						 orderCondition.Status != OrderConditionStatus.Closed;
		}
Example #4
0
		private bool AllowEditStatus(OrderCondition orderCondition)
		{
			var rolesAllowedEditStatus = new[]
			                                    	{
			                                    		RoleType.Appraiser, RoleType.AppraisalCompanyAdmin, RoleType.CompanyAdminAndAppraiser
			                                    	};

			return _securityContext.CurrentUser.Roles.Select(e => e.RoleType).Any(e => rolesAllowedEditStatus.Contains(e)) &&
						 orderCondition.Status != OrderConditionStatus.Closed;
		}