Ejemplo n.º 1
0
        // Owner can be changed.
        public DTOs.Order Update(int id, DTOs.Order order)
        {
            Order existingOrder = Get(id);

            if (order.Status != null)
            {
                existingOrder.Status = _decodesQueryProcessor.Get <OrderStatusDecode>(order.Status);
            }

            if (order.Field != null)
            {
                existingOrder.Field = _fieldsQueryProcessor.Get(order.Field.Id ?? 0);
            }

            if (order.PlayersNumber != 0)
            {
                existingOrder.PlayersNumber = order.PlayersNumber;
            }

            existingOrder.StartDate = DateUtils.ConvertFromJavaScript(order.StartDate);

            Update(id, existingOrder);

            return(new DTOs.Order().Initialize(existingOrder));
        }
Ejemplo n.º 2
0
        public DTOs.Order Save(DTOs.Order order)
        {
            // TODO remove EndDate from Order
            Order newOrder = new Order()
            {
                StartDate     = DateUtils.ConvertFromJavaScript(order.StartDate),
                Field         = _fieldsQueryProcessor.Get(order.Field.Id ?? 0),
                PlayersNumber = order.PlayersNumber,
                Status        = _decodesQueryProcessor.Get <OrderStatusDecode>(order.Status),
                Participants  = new List <Participant>()
            };

            Order persistedOrder = Save(newOrder);

            return(new DTOs.Order().Initialize(persistedOrder));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public List <DTOs.Order> SearchOptionalsOrders(int?orderId = null, int?fieldId = null, int?fieldType = null, DateTime?date = null)
        {
            DateTime?dateTime = date.Value.Date;

            //if (date.HasValue)
            //    dateTime = DateUtils.ConvertFromJavaScript(date ?? 0);


            List <DTOs.Order> optionals = _ordersQueryProcessor.SearchOptionalOrders(fieldId, null, fieldType, dateTime ?? DateTime.Today);

            if (orderId.HasValue)
            {
                DTOs.Order current = _ordersQueryProcessor.GetOrder(orderId ?? 0);

                if (current.Field.Id == fieldId && DateUtils.ConvertFromJavaScript(current.StartDate).Date == dateTime.Value.Date)
                {
                    optionals.Add(current);
                }
            }

            return(optionals);
        }