示例#1
0
        public void AddOrder(DomOrder o)
        {
            Order newOrder = DataDomainMapper.DomOrder2Order(o);

            _db.Order.Add(newOrder);
            _db.SaveChanges();
        }
        public DomUser GetUser(string username)
        {
            User    inUser  = _db.User.Where(u => u.Username == username).FirstOrDefault();
            DomUser outUser = DataDomainMapper.User2DomUser(inUser);

            _db.Entry(inUser).State = Microsoft.EntityFrameworkCore.EntityState.Detached;
            return(outUser);
        }
示例#3
0
        public void RemoveOrder(DomOrder o)
        {
            Order remOrder = DataDomainMapper.DomOrder2Order(o);

            Pizza[] pizzas = _db.Pizza.Where(p => p.OrderId == remOrder.Id).ToArray();
            _db.Pizza.RemoveRange(pizzas);
            _db.Order.Remove(remOrder);
            _db.SaveChanges();
        }
示例#4
0
        public DomOrder GetActiveOrder(string Username)
        {
            IQueryable <Order> oquery = _db.Order.Where <Order>(o => o.Username == Username && ((int)o.OrderStatus < 4));

            if (oquery.FirstOrDefault() == null)
            {
                return(null);
            }
            return(DataDomainMapper.Order2DomOrder(oquery.FirstOrDefault()));
        }
示例#5
0
        public DomOrder GetMostRecentOrder(DomUser u)
        {
            Order order = _db.Order.Where <Order>(o => o.Username == u.Username).OrderByDescending(o => o.OrderDate).FirstOrDefault();

            if (order == null)
            {
                return(null);
            }
            return(DataDomainMapper.Order2DomOrder(order));
        }
示例#6
0
        public List <DomLocation> GetLocationList()
        {
            List <Location>    inLocations  = _db.Location.ToList();
            List <DomLocation> outLocations = new List <DomLocation>();

            foreach (var l in inLocations)
            {
                outLocations.Add(DataDomainMapper.Location2DomLocation(l));
            }
            return(outLocations);
        }
示例#7
0
        public List <DomOrder> GetUserOrderList(DomUser u)
        {
            List <Order>    orderList = _db.Order.Where <Order>(o => o.Username == u.Username).ToList();
            List <DomOrder> outList   = new List <DomOrder>();

            foreach (var o in orderList)
            {
                outList.Add(DataDomainMapper.Order2DomOrder(o));
            }
            return(outList);
        }
        public List <DomPizza> GetOrderPizzas(DomOrder o)
        {
            List <Pizza>    inPizzas  = _db.Pizza.Where <Pizza>(p => p.OrderId == o.OrderID).ToList();
            List <DomPizza> outPizzas = new List <DomPizza>();

            foreach (var p in inPizzas)
            {
                outPizzas.Add(DataDomainMapper.Pizza2DomPizz(p));
            }
            return(outPizzas);
        }
        public List <DomPizzaTopping> GetPizzaToppings(DomPizza p)
        {
            List <PizzaTopping>    inPizzaToppings  = _db.PizzaTopping.Where <PizzaTopping>(pt => pt.PizzaId == p.PizzaID).ToList();
            List <DomPizzaTopping> outPizzaToppings = new List <DomPizzaTopping>();

            foreach (var pt in inPizzaToppings)
            {
                outPizzaToppings.Add(DataDomainMapper.PizzaTopping2DomPizzaTopping(pt));
            }
            return(outPizzaToppings);
        }
        public List <DomTopping> GetToppingList()
        {
            List <Topping>    inToppings  = _db.Topping.ToList();
            List <DomTopping> outToppings = new List <DomTopping>();

            foreach (var t in inToppings)
            {
                outToppings.Add(DataDomainMapper.Topping2DomTopping(t));
            }
            return(outToppings);
        }
示例#11
0
        public List <DomOrder> GetAllOrders(int LocationId)
        {
            List <Order> orders = _db.Order.Where <Order>(o => o.LocationId == LocationId && o.OrderStatus != 5).ToList();

            if (orders == null)
            {
                return(null);
            }
            List <DomOrder> outOrders = new List <DomOrder>();

            foreach (var o in orders)
            {
                outOrders.Add(DataDomainMapper.Order2DomOrder(o));
            }
            return(outOrders);
        }
示例#12
0
        public List <DomInventory> GetInventory(int LocationId)
        {
            List <Inventory> inventory = _db.Inventory.Where <Inventory>(i => i.LocationId == LocationId).ToList();

            if (inventory == null)
            {
                return(null);
            }
            List <DomInventory> outInventory = new List <DomInventory>();

            foreach (var i in inventory)
            {
                outInventory.Add(DataDomainMapper.Inventory2DomInventory(i));
            }
            return(outInventory);
        }
示例#13
0
        public List <DomUser> Getusers(int LocationId)
        {
            List <User> users = _db.User.Where <User>(u => u.LocationId == LocationId).ToList();

            if (users == null)
            {
                return(null);
            }
            List <DomUser> outUsers = new List <DomUser>();

            foreach (var u in users)
            {
                outUsers.Add(DataDomainMapper.User2DomUser(u));
            }
            return(outUsers);
        }
 public void RemoveUser(DomUser u)
 {
     _db.User.Remove(DataDomainMapper.DomUser2User(u));
 }
 public void UpdateUser(DomUser u)
 {
     _db.User.Update(DataDomainMapper.DomUser2User(u));
     _db.SaveChanges();
 }
 public void AddUser(DomUser u)
 {
     _db.User.Add(DataDomainMapper.DomUser2User(u));
     _db.SaveChanges();
 }
 public DomTopping GetTopping(int id)
 {
     return(DataDomainMapper.Topping2DomTopping(_db.Topping.Where <Topping>(t => t.Id == id).FirstOrDefault()));
 }
示例#18
0
 public DomLocation GetLocation(int id)
 {
     return(DataDomainMapper.Location2DomLocation(_db.Location.Where(l => l.Id == id).First()));
 }