Exemple #1
0
        public async Task <ActionResult <OrderWithStatus> > GetOrderWithStatus(int orderId)
        {
            var reply = await orders.GetOrderDetailsAsync(new OrderService.OrderDetailsRequest()
            {
                OrderId = orderId,
                UserId  = GetUserId(),
            });

            if (reply.Order == null)
            {
                return(NotFound());
            }

            var status = await delivery.GetDeliveryStatusAsync(new DeliveryService.DeliveryRequest()
            {
                OrderId = orderId,
                UserId  = GetUserId(),
            });

            return(OrderWithStatus.FromOrder(FromGrpc(reply.Order), status.Status, new LatLong()
            {
                Latitude = status.Location?.Latitude ?? 0,
                Longitude = status.Location?.Longitude ?? 0,
            }));
        }
Exemple #2
0
        public async Task <ActionResult <List <OrderWithStatus> > > GetOrders()
        {
            var reply = await orders.GetOrderHistoryAsync(new OrderService.OrderHistoryRequest()
            {
                UserId = GetUserId(),
            });

            return(reply.Orders.OrderByDescending(o => o.CreatedTime).Select(o => OrderWithStatus.FromOrder(FromGrpc(o))).ToList());
        }
Exemple #3
0
        public async Task <ActionResult <List <OrderWithStatus> > > GetOrders()
        {
            var orders = await _db.Orders.Include(o => o.Pizzas).ThenInclude(p => p.Special)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping)
                         .OrderByDescending(o => o.CreatedTime)
                         .ToListAsync();

            return(orders.Select(o => OrderWithStatus.FromOrder(o)).ToList());
        }
Exemple #4
0
        public async Task <ActionResult <List <OrderWithStatus> > > GetOrders()
        {
            var Orders = await Context.Orders.Where(o => o.UsrId == GetUserId())
                         .Include(o => o.DeliveryLocation)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping)
                         .OrderByDescending(o => o.CreatedTime).ToListAsync();

            return(Orders.Select(o => OrderWithStatus.FromOrder(o)).ToList());
        }
        public async Task <ActionResult <List <OrderWithStatus> > > GetOrders()
        {
            var orders = await _db.Orders
                         .Include(o => o.DeliveryLocation)
                         .Include(o => o.Drugs).ThenInclude(p => p.Deal)
                         .Include(o => o.Drugs)
                         .OrderByDescending(o => o.CreatedTime)
                         .ToListAsync();

            return(orders.Select(o => OrderWithStatus.FromOrder(o)).ToList());
        }
Exemple #6
0
        public async Task <List <OrderWithStatus> > GetOrders()
        {
            var orders = await Context.Orders
                         .Where(o => o.UserId == GetUserId())
                         .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping)
                         .OrderByDescending(o => o.CreatedTime)
                         .ToListAsync();

            return(orders.ConvertAll(o => OrderWithStatus.FromOrder(o)));
        }
Exemple #7
0
        public async Task <ActionResult <List <OrderWithStatus> > > GetOrdersAdmin()
        {
            var orders = await _db.Orders
                         .Where(o => !o.CanceledTime.HasValue && !o.DeliveredTime.HasValue)
                         .Include(o => o.DeliveryLocation)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping)
                         .OrderByDescending(o => o.CreatedTime)
                         .ToListAsync();

            return(orders.Select(o => OrderWithStatus.FromOrder(o)).ToList());
        }
        public async Task <ActionResult <OrderWithStatus> > GetOrderbyId(int orderId)
        {
            var matchingOrder = _Orders.FirstOrDefault(o => o.OrderId == orderId);

            if (matchingOrder != null)
            {
                return(await Task.FromResult <OrderWithStatus>(OrderWithStatus.FromOrder(matchingOrder)));
            }
            else
            {
                return(NotFound());
            }
        }
        public async Task <List <OrderWithStatus> > GetOrders(int day, int month, int year)
        {
            var date = new DateTime(year, month, day);

            var orders = await _db.Orders
                         .Where(o => o.CollectionDate.Date == date.Date)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                         .Include(o => o.Drinks).ThenInclude(d => d.Drink)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping)
                         .OrderByDescending(o => o.CreatedTime)
                         .ToListAsync();

            return(orders.Select(o => OrderWithStatus.FromOrder(o)).ToList());
        }
Exemple #10
0
        public async Task <ActionResult <OrderWithStatus> > GetOrderWithStatus(int orderId)
        {
            var order = await _db.Orders.Where(o => o.OrderId == orderId)
                        .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                        .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping)
                        .SingleOrDefaultAsync();

            if (order == null)
            {
                return(NotFound());
            }

            return(OrderWithStatus.FromOrder(order));
        }
        public async Task <OrderWithStatus> GetOrderWithStatus(int orderId, string orderPassword)
        {
            var order = await _db.Orders
                        .Where(o => o.OrderId == orderId && o.Password == orderPassword)
                        .Include(o => o.Drinks).ThenInclude(d => d.Drink)
                        .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                        .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping)
                        .SingleOrDefaultAsync();

            if (order == null)
            {
                return(null);
            }

            return(OrderWithStatus.FromOrder(order));
        }
        public async Task <ActionResult <OrderWithStatus> > GetOrderWithStatus(int orderId)
        {
            var order = await _db.Orders
                        .Where(o => o.OrderId == orderId)
                        .Include(o => o.DeliveryLocation)
                        .Include(o => o.Drugs).ThenInclude(p => p.Deal)
                        .Include(o => o.Drugs)
                        .SingleOrDefaultAsync();

            if (order == null)
            {
                return(NotFound());
            }

            return(OrderWithStatus.FromOrder(order));
        }
Exemple #13
0
        public async Task <ActionResult <OrderWithStatus> > GetOrderWithStatus(int orderId)
        {
            var Orders = await Context.Orders.Where(o => o.UsrId == GetUserId())
                         .Where(o => o.OrderId == orderId)
                         .Include(o => o.DeliveryLocation)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Toppings)
                         .ThenInclude(t => t.Topping)
                         .SingleOrDefaultAsync();

            if (Orders == null)
            {
                return(NotFound());
            }
            else
            {
                return(OrderWithStatus.FromOrder(Orders));
            }
        }
 public async Task <List <OrderWithStatus> > GetOrders()
 {
     return(await Task.FromResult <List <OrderWithStatus> >(_Orders.Select(o => OrderWithStatus.FromOrder(o)).ToList()));
 }