示例#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);
         }
     }
 }