Esempio n. 1
0
        public async Task <List <OrderClientDTO> > GetWaiterCurrentOrders(int waiterId)
        {
            List <OrderClientDTO> orderResult = null;

            if (userRepository.GetById(waiterId).RoleId.Equals(5))
            {
                foreach (var order in orderRepository.GetMany(o => o.CreatedBy.Equals(waiterId) && o.PaymentStatusId.Equals(1)).ToList())
                {
                    if (orderResult == null)
                    {
                        orderResult = new List <OrderClientDTO>();
                    }
                    var _order = new OrderClientDTO();
                    _order.Id = order.Id;
                    _order.PaymentStatusId = order.PaymentStatusId;
                    _order.TotalPrice      = order.TotalPrice;
                    _order.UserId          = (int)order.CreatedBy;
                    _order.customerId      = order.CustomerId;
                    foreach (var suborder in orderDetailRepository.GetAll().Where(od =>
                                                                                  od.OrderId.Equals(_order.Id) && visibleOrderStatus.Contains(od.OrderStatusId)).ToList())
                    {
                        if (_order.SubOrders == null)
                        {
                            _order.SubOrders = new List <OrderDetailClientDTO>();
                        }
                        var suborderDetail = new OrderDetailClientDTO();
                        suborderDetail.SubOrderId    = suborder.SubOrderId;
                        suborderDetail.OrderStatusId = suborder.OrderStatusId;
                        suborderDetail.SubTotalPrice = 0.00m;
                        foreach (var ordereditem in subOrderDetailRepository.GetAll().Where(o =>
                                                                                            o.SubOrderId.Equals(suborder.SubOrderId)))
                        {
                            if (suborderDetail.OrderItems == null)
                            {
                                suborderDetail.OrderItems = new List <OrderItemDetailClientDTO>();
                            }
                            var item = new OrderItemDetailClientDTO();
                            item.ItemId           = ordereditem.ItemId;
                            item.OrderQuantity    = ordereditem.OrderQuantity;
                            item.OrderPreferences = ordereditem.OrderPreferences;
                            suborderDetail.OrderItems.Add(item);
                        }
                        _order.SubOrders.Add(suborderDetail);
                    }
                    orderResult.Add(_order);
                }
            }
            return(orderResult);
        }
Esempio n. 2
0
        public async Task <OrderClientDTO> GetCustomerCurrentOrders(int orderId)
        {
            OrderClientDTO orderResult = null;
            Order          order       = null;

            order = orderRepository.GetById(orderId);
            if (order != null && order.PaymentStatusId.Equals(1))
            {
                orderResult    = new OrderClientDTO();
                orderResult.Id = order.Id;
                orderResult.PaymentStatusId = order.PaymentStatusId;
                orderResult.TotalPrice      = order.TotalPrice;
                orderResult.UserId          = (int)order.CreatedBy;
                orderResult.customerId      = order.CustomerId;
                foreach (var suborder in orderDetailRepository.GetAll().Where(od =>
                                                                              od.OrderId.Equals(orderId) &&
                                                                              visibleOrderStatus.Contains(od.OrderStatusId)).ToList())
                {
                    if (orderResult.SubOrders == null)
                    {
                        orderResult.SubOrders = new List <OrderDetailClientDTO>();
                    }
                    var suborderDetail = new OrderDetailClientDTO();
                    suborderDetail.SubOrderId    = suborder.SubOrderId;
                    suborderDetail.OrderStatusId = suborder.OrderStatusId;
                    suborderDetail.SubTotalPrice = 0.00m;
                    var test = subOrderDetailRepository.GetAll();
                    foreach (var ordereditem in subOrderDetailRepository.GetAll().Where(o =>
                                                                                        o.SubOrderId.Equals(suborder.SubOrderId)))
                    {
                        if (suborderDetail.OrderItems == null)
                        {
                            suborderDetail.OrderItems = new List <OrderItemDetailClientDTO>();
                        }
                        var item = new OrderItemDetailClientDTO();
                        item.ItemId           = ordereditem.ItemId;
                        item.OrderQuantity    = ordereditem.OrderQuantity;
                        item.OrderPreferences = ordereditem.OrderPreferences;
                        suborderDetail.OrderItems.Add(item);
                    }
                    orderResult.SubOrders.Add(suborderDetail);
                }
            }
            return(orderResult);
        }