public void Add(Category obj) { try { db.Categories.Add(obj);//menambahkan data db.SaveChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void Add(Author obj) { try { db.Authors.Add(obj); db.SaveChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void UpdateCartID(string tempUsername, string username) { var results = from s in db.ShoppingCarts where s.CartID == tempUsername select s; foreach (var sc in results) { sc.CartID = username; } db.SaveChanges(); }
public void Add(Book obj) { try { db.Books.Add(obj); db.SaveChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void AddOrder(Order obj) { try { db.Orders.Add(obj); db.SaveChanges(); } catch (InvalidCastException e) { // Perform some action here, and then throw a new exception. throw new Exception("Put your error message here.", e); } }
public void AddToCart(ShoppingCart sc) { var result = GetItemByUser(sc.CartID, sc.BookID); if (result != null) { //ditambahi klo sudah ada result.Quantity += 1; } else { db.ShoppingCarts.Add(sc); } try { db.SaveChanges(); } catch (Exception ex) { throw new Exception(ex.Message, ex.InnerException); } }
public void Add(Book book) { db.Books.Add(book); db.SaveChanges(); }