Example #1
0
 public bool CreateCart(Carts c)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         try
         {
             db.Cart.Add(c);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Example #2
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);
         }
     }
 }
Example #3
0
 public bool AddProductToBasket(Burgers b)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         try
         {
             db.Burger.Add(b);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Example #4
0
 public bool DeleteBurger(Burgers b)
 {
     using (var db = new GoodBurgerEntitiesContext())
     {
         try
         {
             db.Burger.Remove(b);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Example #5
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);
         }
     }
 }
Example #6
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);
         }
     }
 }