public IEnumerable <CustomersActivityReport> GetCustomersActivityReport(string firstName, string lastName, int?minAge, int?maxAge, DateTime?fromDate, DateTime?untilDate) { var customers = _customersQueryProcessor.Search(firstName, lastName, minAge, maxAge, null, null); var report = customers.Select(x => new CustomersActivityReport { CoustomerId = x.Id ?? 0, FirstName = x.FirstName, LastName = x.LastName, BirthDate = x.BirthDate, NumberOfOrders = _ordersQueryProcessor.Search(null, x.Id, null, new int?[] { (int)Consts.Decodes.OrderStatus.Accepted }, null, null, fromDate, untilDate).Count(), NumberOfCanceledOrders = _ordersQueryProcessor.Search(null, x.Id, null, new int?[] { (int)Consts.Decodes.OrderStatus.Canceled }, null, null, fromDate, untilDate).Count(), NumberOfJoiningAsGuest = _participantsQueryProcessor.Search(x.Id, null, new int?[] { (int)Consts.Decodes.InvitationStatus.Accepted }, null, null, null, null, null, null).Count() }).ToArray(); for (int i = 0; i < report.Count(); i++) { var item = report[i]; var itemOrder = _ordersQueryProcessor.Search(null, item.CoustomerId, null, new int?[] { (int)Consts.Decodes.OrderStatus.Accepted }, null, null, null, null); if (itemOrder.Count != 0) { item.LastGameDate = itemOrder.Max(x => x.StartDate); } } return(report); }
public DTOs.Order Get(int id) { DTOs.Order order = _ordersQueryProcessor.GetOrder(id); order.Participants = _participantsQueryProcessor.Search(null, null, new int?[] { (int)Consts.Decodes.InvitationStatus.Sent, (int)Consts.Decodes.InvitationStatus.Accepted }, null, order.Id, null, null, null, null).ToList(); return(order); }
public List <DTOs.Participant> SearchParticipants(int?ownerId = null, string ownerName = null, int?orderId = null, int?invitationStatusId = null, int?fieldId = null, string fieldName = null, DateTime?fromDate = null, DateTime?untilDate = null) { var currPrincipal = HttpContext.Current.User as ClaimsPrincipal; var currIdentity = currPrincipal.Identity as BasicAuthenticationIdentity; int userId = currIdentity.UserId; int?[] statuses = null; if (invitationStatusId.HasValue) { statuses = new int?[] { invitationStatusId } } ; return(_participantsQueryProcessor.Search(userId, ownerId, statuses, ownerName, orderId, fieldId, fieldName, fromDate, untilDate).ToList()); }
public IEnumerable <DTOs.Order> SearchAvailableOrdersToJoin(int?ownerId, string ownerName, int?orderId, int?orderStatusId, int?fieldId, string fieldName, DateTime?startDate, DateTime?endDate) { var currPrincipal = HttpContext.Current.User as ClaimsPrincipal; var currIdentity = currPrincipal.Identity as BasicAuthenticationIdentity; int userId = currIdentity.UserId; var filter = PredicateBuilder.New <Order>(x => x.Owner.Id != userId); if (orderId.HasValue) { filter.And(x => x.Id == orderId); } if (!string.IsNullOrEmpty(ownerName)) { string[] names = ownerName.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); if (names.Length == 1) { filter.And(x => x.Owner.FirstName.Contains(ownerName) || x.Owner.LastName.Contains(ownerName)); } else if (names.Length == 2) { filter.And(x => x.Owner.FirstName.Contains(names[0]) || x.Owner.LastName.Contains(names[1])); } } if (ownerId.HasValue) { filter.And(x => x.Owner.Id == ownerId); } if (orderStatusId.HasValue) { filter.And(x => orderStatusId == x.Status.Id); } else { var statuses = new int?[] { (int)Consts.Decodes.OrderStatus.Accepted, (int)Consts.Decodes.OrderStatus.Sent }; filter.And(x => statuses.Contains(x.Status.Id)); } if (fieldId.HasValue) { filter.And(x => x.Field.Id == fieldId); } if (!string.IsNullOrEmpty(fieldName)) { filter.And(x => x.Field.Name.Contains(fieldName)); } if (startDate.HasValue) { filter.And(x => x.StartDate >= startDate); } if (endDate.HasValue) { DateTime?calcEndDate = endDate.Value.AddDays(1); filter.And(x => x.StartDate <= calcEndDate); } var allResult = Query().Where(filter).ToList().Select(x => new DTOs.Order().Initialize(x)); List <DTOs.Order> finalResult = new List <DTOs.Order>(); foreach (var item in allResult) { var participants = _participantsQueryProcessor.Search(null, null, null, null, item.Id, null, null, null, null); } return(finalResult); }