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 List <DTOs.Order> SearchMyOrders(int?orderId = null, int?orderStatusId = 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 (orderStatusId.HasValue) { statuses = new int?[] { orderStatusId } } ; return(_ordersQueryProcessor.Search(orderId, userId, null, statuses, fieldId, fieldName, fromDate, untilDate)); }
public IEnumerable <UsingFieldsReport> GetUsingFieldsReport(int?fieldId, string fieldName, DateTime?fromDate, DateTime?untilDate) { var orders = _ordersQueryProcessor.Search(null, null, null, new int?[] { (int)Consts.Decodes.OrderStatus.Accepted }, null, null, fromDate, untilDate); var report = _fieldsQueryProcessor.Search(fieldId, fieldName, null).Select(x => new UsingFieldsReport() { FieldId = x.Id ?? 0, FieldName = x.Name, hours16_18Orders = orders.Where(f => x.Id == f.Field.Id && DateUtils.ConvertFromJavaScript(f.StartDate).Hour == 16).Count(), hours18_20Orders = orders.Where(f => x.Id == f.Field.Id && DateUtils.ConvertFromJavaScript(f.StartDate).Hour == 18).Count(), hours20_22Orders = orders.Where(f => x.Id == f.Field.Id && DateUtils.ConvertFromJavaScript(f.StartDate).Hour == 20).Count(), WeekEndOrders = orders.Where(f => x.Id == f.Field.Id && (DateUtils.ConvertFromJavaScript(f.StartDate).DayOfWeek == DayOfWeek.Friday || DateUtils.ConvertFromJavaScript(f.StartDate).DayOfWeek == DayOfWeek.Saturday)).Count(), WeekDayOrders = orders.Where(f => x.Id == f.Field.Id && !(DateUtils.ConvertFromJavaScript(f.StartDate).DayOfWeek == DayOfWeek.Friday || DateUtils.ConvertFromJavaScript(f.StartDate).DayOfWeek == DayOfWeek.Saturday)).Count() }); return(report); }