예제 #1
0
 public Carts GetCartByUserId(int id)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         return(db.Cart.Where(cart => cart.IdUser == id).LastOrDefault());
     }
 }
예제 #2
0
 public int GetCartIdByGuid(string guid)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         return(db.Cart.Where(cart => cart.Guid == guid).FirstOrDefault().Id);
     }
 }
예제 #3
0
 public List <Burgers> GetItemsInCart(int id)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         return(db.Burger.Where(burger => burger.IdCart == id).ToList());
     }
 }
예제 #4
0
 public List <Burgers> GetProducts()
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         return(db.Burger.ToList());
     }
 }
예제 #5
0
 public List <Users> GetUsers()
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         return(db.User.ToList());
     }
 }
예제 #6
0
 public bool CreateCart(Carts c)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         try
         {
             db.Cart.Add(c);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
예제 #7
0
 public int AddUser(Users u)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         try
         {
             db.User.Add(u);
             db.SaveChanges();
             return(db.User.Where(x => x.Username == u.Username).FirstOrDefault().Id);
         }
         catch
         {
             return(-1);
         }
     }
 }
예제 #8
0
 public bool AddProductToBasket(Burgers b)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         try
         {
             db.Burger.Add(b);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
예제 #9
0
 public bool DeleteBurger(Burgers b)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         try
         {
             db.Burger.Remove(b);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
예제 #10
0
 public bool UpdateInfoUser(Users user)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         try
         {
             Users u = db.User.Where(x => x.Id == user.Id).FirstOrDefault();
             u.Address  = user.Address;
             u.Password = user.Password;
             u.Username = user.Username;
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
예제 #11
0
 public bool UpdateBurgerInfo(Burgers burger)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         try
         {
             Burgers b = db.Burger.Where(x => x.Id == burger.Id).FirstOrDefault();
             b.Children    = burger.Children;
             b.Cities      = burger.Cities;
             b.Components  = burger.Components;
             b.Description = burger.Description;
             b.Number      = burger.Number;
             b.Picture     = burger.Picture;
             b.Price       = burger.Price;
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }