Exemple #1
0
        public OrderModel AddOrderPos(long orderId, long itemTypeId)
        {
            var relevantOrder = context.Order
                                .Include(o => o.Positions)
                                .FirstOrDefault(o => o.Id == orderId);

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

            var position = new OrderPos()
            {
                Number = context.OrderPos
                         .Where(op => op.OrderId == orderId)
                         .Select(op => op.Number)
                         .DefaultIfEmpty(0)
                         .Max() + 1,
                CreationDate = DateTime.Now,
                PosStatus    = PosStatus.New,
                ItemtypId    = itemTypeId,
                OrderId      = orderId,
                Amount       = 1
            };

            relevantOrder.Positions.Add(position);
            context.SaveChanges();

            return(orderService.GetOrder(orderId));
        }
Exemple #2
0
        public bool OnOrderAssigned(string tabletIdentifier, long orderId)
        {
            var relevantOrder = context.Order
                                .Include(o => o.Guests)
                                .FirstOrDefault(o => o.Id == orderId);

            if (relevantOrder == null)
            {
                return(false);
            }


            var tablet = context.Tablet.FirstOrDefault(t => t.Identifier == tabletIdentifier);

            if (tablet == null)
            {
                return(false);
            }


            relevantOrder.Guests.Add(tablet);

            context.SaveChanges();

            return(true);
        }
        public bool SetMode(string tabletIdentifier, Mode tabletMode)
        {
            var tabletWasFound = false;

            //Looking for Tablet
            var searchedTablet = context.Tablet
                                 .FirstOrDefault(m => m.Identifier == tabletIdentifier);

            if (searchedTablet == null)
            {
                searchedTablet = new Tablet
                {
                    Identifier = tabletIdentifier,
                    Mode       = tabletMode
                };

                context.Tablet.Add(searchedTablet);
            }
            else
            {
                tabletWasFound      = true;
                searchedTablet.Mode = tabletMode;
            }

            context.SaveChanges();
            return(tabletWasFound);
        }
Exemple #4
0
        public OrderModel CreateOrder(long tableId, string tabletIdentifier)
        {
            var newOrder = new Order();

            newOrder.Table = context.Table
                             .FirstOrDefault(t => t.Id == tableId);
            newOrder.Waiter = context.Tablet
                              .FirstOrDefault(m => m.Identifier == tabletIdentifier);
            newOrder.OrderStatus  = OrderStatus.New;
            newOrder.CreationTime = DateTime.Now;
            newOrder.UpdateTime   = newOrder.CreationTime;
            newOrder.PriceOrder   = 0;

            context.Add(newOrder);
            context.SaveChanges();

            return(GetOrder(newOrder.Id));
        }
        public void TestGetSubmenues()
        {
            var builder = new DbContextOptionsBuilder <WaitlessContext>();

            builder.UseInMemoryDatabase("unittest");
            var context = new WaitlessContext(builder.Options);

            context.Submenu.Add(new Database.Models.Submenu());
            context.SaveChanges();

            var service = new SubmenuService(context);
            var result  = service.GetSubmenus(0);

            Assert.Equal(1, result.Count());
        }