Пример #1
0
 public static List <Food> ListFood()
 {
     using (ShopOrders entities = new ShopOrders())
     {
         return(entities.Foods.ToList <Food>());
     }
 }
Пример #2
0
 public static List <Order> GetOrder(int orderId)
 {
     using (ShopOrders entities = new ShopOrders())
     {
         return(entities.Orders.Where(p => p.OrderID == orderId).ToList <Order>());
     }
 }
Пример #3
0
 public static List <Size> ListSize()
 {
     using (ShopOrders entities = new ShopOrders())
     {
         return(entities.Sizes.ToList <Size>());
     }
 }
Пример #4
0
 public static List <Order> ListOrdersBy(string name)
 {
     using (ShopOrders entities = new ShopOrders())
     {
         return(entities.Orders.Where(p => p.Username == name).ToList <Order>());
     }
 }
Пример #5
0
 public static string GetFood(int id)
 {
     using (ShopOrders entities = new ShopOrders())
     {
         Food f = entities.Foods.Where(p => p.ID == id).First <Food>();
         return(f.Name);
     }
 }
Пример #6
0
 public static void DeleteOrder(int orderId)
 {
     using (ShopOrders entities = new ShopOrders())
     {
         Order order = entities.Orders.Where(p => p.OrderID == orderId).First <Order>();
         entities.Orders.Remove(order);
         entities.SaveChanges();
     }
 }
Пример #7
0
 public static void UpdateOrder(int orderId, int foodid,
                                string size, string chilli, string salt, string pepper)
 {
     using (ShopOrders entities = new ShopOrders())
     {
         Order order = entities.Orders.Where(p => p.OrderID == orderId).First <Order>();
         order.FoodID   = foodid;
         order.FoodName = GetFood(foodid);
         order.Size     = size;
         order.Chilli   = chilli;
         order.MoreSalt = salt;
         order.Pepper   = pepper;
         entities.SaveChanges();
     }
 }
Пример #8
0
 public static void AddOrder(string user, int foodID, string foodname,
                             string size, string chilli, string salt, string pepper)
 {
     using (ShopOrders entities = new ShopOrders())
     {
         Order order = new Order
         {
             Username = user,
             FoodID   = foodID,
             FoodName = foodname,
             Size     = size,
             Chilli   = chilli,
             MoreSalt = salt,
             Pepper   = pepper
         };
         entities.Orders.Add(order);
         entities.SaveChanges();
     }
 }