Ejemplo n.º 1
0
		public ActiveOrdersViewModel GetActiveOrders(ClientDashboardFilter filter)
		{
			var result = new ActiveOrdersViewModel();
			var client = _clientManager.GetByEmail(filter.UserIdentity);
			var where = GetActiveFilter(filter, client);
			var dateNowCondition = _dateTimeManager.GetNextBusinessDay(DateTime.Now, -10);

			var _activeOrderStatuses = new[] { OrderStatus.PendingAssignment.ToString(), OrderStatus.Draft.ToString(), OrderStatus.Completed.ToString(), OrderStatus.Cancelled.ToString(), OrderStatus.CreationProcess.ToString(), OrderStatus.Rejected.ToString() };
			var _rejectedOrderStatus = new[] { OrderStatus.Rejected.ToString() };
			where = where.AndAlso(o => !_activeOrderStatuses.Contains(o.Order.OrderStatusId) ||
				(
					_rejectedOrderStatus.Contains(o.Order.OrderStatusId) && EntityFunctions.TruncateTime(
					o.Order.OrderHistoryNotes.
					Where(q => q.OrderId == o.Order.Id && q.EventId == (int)OrderHistoryEvent.OrderRejected).
					OrderByDescending(q => q.Date).
					Select(q => q.Date).
					FirstOrDefault()) > EntityFunctions.TruncateTime(dateNowCondition))
				);

			var orderBy = GetActiveOrderSortingDirection(filter, ClientDashboardSortingColumnName.LastActionDate, false);
			int totalCount;

			result.Items = _dashboardManager.GetActiveOrdersList(where, orderBy, filter.ItemsPerPage, filter.PageNumber, out totalCount);
			result.TotalItemsCount = totalCount;
			result.IsLenderColumnsVisible = client.Company.Profile.IsBroker;
			result.IsBrokerColumnVisible = client.Company.Profile.IsLender && client.Company.Profile.IsWholesale;
			return result;
		}
Ejemplo n.º 2
0
		public Func<IQueryable<Order>, IOrderedQueryable<Order>> GetSortingOrder(ClientDashboardFilter filter, ClientDashboardSortingColumnName defaultColumn, bool defaultIsAsc)
		{
			var targetOrder = OrderItems.FirstOrDefault(e => e.ColumnName == filter.ColumnName && e.IsAsc == filter.IsAsc);
			if (targetOrder != null)
			{
				return targetOrder.SortingOrder;
			}
			return OrderItems.Single(e => e.ColumnName == defaultColumn && e.IsAsc == defaultIsAsc).SortingOrder;
		}
Ejemplo n.º 3
0
		public NewOrdersViewModel GetNewOrders(ClientDashboardFilter filter)
		{
			var result = new NewOrdersViewModel();
			ClientUser client = _clientManager.GetByEmail(filter.UserIdentity);
			var where = GetCommonFilter(filter, client);
			var _newOrderStatuses = new[] { OrderStatus.PendingAssignment.ToString(), OrderStatus.Draft.ToString() };
			where = where.AndAlso(o => _newOrderStatuses.Contains(o.OrderStatusId));
			var orderBy = GetSortingOrder(filter, ClientDashboardSortingColumnName.RequestDate, false);
			int totalCount;
			result.Items = _dashboardManager.GetNewOrdersList(where, orderBy, filter.ItemsPerPage, filter.PageNumber, out totalCount);
			result.TotalItemsCount = totalCount;
			result.CanAddOrders = (new[] {RoleType.LoanOfficer, RoleType.Processor, RoleType.CSR, RoleType.OperationsManager, 
				RoleType.SuperUser, RoleType.ClientAdmin, RoleType.OrderAdmin }).Contains(client.User.PrimaryRole.RoleType);
			result.IsBrocker = client.Company.Profile.IsBroker;
			result.IsLenderWholesale = client.Company.Profile.IsLender && client.Company.Profile.IsWholesale;
			return result;
		}
Ejemplo n.º 4
0
		public ActionResult Index()
		{
			FiltersDetails.LastOrder.IsDesc = true;
			FiltersDetails.LastOrder.DefaultColumn = ClientDashboardSortingColumnName.RequestDate.ToString();
			var filter = new ClientDashboardFilter()
			{
				ColumnName = FiltersDetails.LastOrder.ToEnum(ClientDashboardSortingColumnName.RequestDate),
				IsAsc = !FiltersDetails.LastOrder.IsDesc,
				ItemsPerPage = FiltersDetails.PaggingDetails.ElementsPerPage,
				PageNumber = FiltersDetails.PaggingDetails.CurrentPage,
				UserIdentity = User.Identity.Name,
				Fragment = FiltersDetails.GetFilterValue<ClientDashboardFilterViewModel>(f => f.SearchFragment)
			};
			var model = _dashboardService.GetNewOrders(filter);
			FiltersDetails.PaggingDetails.SetPageCount(model.TotalItemsCount).CheckElementOnPage(model.TotalItemsCount);
			return DashboardView("Index", model);
		}
Ejemplo n.º 5
0
		public ActionResult Index()
		{
			FiltersDetails.LastOrder.IsDesc = true;
			FiltersDetails.LastOrder.DefaultColumn = ClientDashboardSortingColumnName.LastActionDate.ToString();
			var filter = new ClientDashboardFilter
			{
				ColumnName = FiltersDetails.LastOrder.ToEnum(ClientDashboardSortingColumnName.LastActionDate),
				IsAsc = !FiltersDetails.LastOrder.IsDesc,
				ItemsPerPage = FiltersDetails.PaggingDetails.ElementsPerPage,
				PageNumber = FiltersDetails.PaggingDetails.CurrentPage,
				UserIdentity = User.Identity.Name,
				Fragment = FiltersDetails.GetFilterValue<ClientDashboardFilterViewModel>(f => f.SearchFragment),
				DateFrom = AssignmentFilters.ParseDateTime(FiltersDetails.GetFilterValue<ClientDashboardFilterViewModel, DateTime?>(f => f.DateFrom)),
				DateTo = AssignmentFilters.ParseDateTime(FiltersDetails.GetFilterValue<ClientDashboardFilterViewModel, DateTime?>(f => f.DateTo))

			};
			var model = _dashboardService.GetOrdersArchive(filter);
			FiltersDetails.PaggingDetails.SetPageCount(model.TotalItemsCount).CheckElementOnPage(model.TotalItemsCount);

			return DashboardView(NameHelper.Dashboard.OrdersArchive.Index, model);
		}
Ejemplo n.º 6
0
		private static Func<IQueryable<ActiveOrderItem>, IOrderedQueryable<ActiveOrderItem>> GetActiveOrderSortingDirection(ClientDashboardFilter filter, ClientDashboardSortingColumnName defaultColumn, bool defaultIsAsc)
		{
			var targetOrder = ActiveOrderItems.FirstOrDefault(e => e.ColumnName == filter.ColumnName && e.IsAsc == filter.IsAsc);
			return targetOrder != null ?
				targetOrder.SortingOrder : ActiveOrderItems.Single(e => e.ColumnName == defaultColumn && e.IsAsc == defaultIsAsc).SortingOrder;
		}
Ejemplo n.º 7
0
		private static Expression<Func<ActiveOrderItem, bool>> GetActiveFilter(ClientDashboardFilter filter, ClientUser client)
		{
			var result = HasClientUserAccessToActiveOrder(client);

			if (!string.IsNullOrWhiteSpace(filter.Fragment))
			{
				var fragmentTrimmed = filter.Fragment.Trim();
				result = result.AndAlso(o => o.Order.GeneralInfo.BorrowerFirstName.Contains(fragmentTrimmed) || o.Order.GeneralInfo.BorrowerLastName.Contains(fragmentTrimmed)
					|| o.Order.GeneralInfo.LoanNumber.Contains(fragmentTrimmed) || o.Order.OrderPublicId.Contains(fragmentTrimmed));
			}
			if (filter.DateFrom.HasValue)
			{
				result = result.AndAlso(o => EntityFunctions.TruncateTime(o.Order.CreationDate) >= EntityFunctions.TruncateTime(filter.DateFrom));
			}
			if (filter.DateTo.HasValue)
			{
				result = result.AndAlso(o => EntityFunctions.TruncateTime(o.Order.CreationDate) <= EntityFunctions.TruncateTime(filter.DateTo));
			}
			result = result.AndAlso(o => !o.Order.IsTestOrder);
			return result;
		}