public void Add(User user) { _context.Users.Add(user); _context.SaveChanges(); }
public void Add(Product product) { _context.Products.Add(product); _context.SaveChanges(); }
public void AddOrders(Orders obj) { _context.Add(obj); _context.SaveChanges(); }
public bool Insert(ChiTietHoaDon detail) { db.ChiTietHoaDons.Add(detail); db.SaveChanges(); return(true); }
public void AddItem(Items obj) { _context.Add(obj); _context.SaveChanges(); }
public int Insert(User entity) { db.Users.Add(entity); db.SaveChanges(); return(entity.ID); }
public long Insert(DanhMucSanPham list) { db.DanhMucSanPhams.Add(list); db.SaveChanges(); return(list.ID); }
public void Save() { _shopDbContext.SaveChanges(); }
public void Add(Orders item) { _context.Add(item); _context.SaveChanges(); }
public IActionResult buyItem(int itemID) { GetData(); AspNetUsers user = new AspNetUsers(); Inventory tempItem = new Inventory(); foreach (var item in itemList) { if (item.ProductId == itemID) { tempItem = item; } } foreach (var client in clientList) { if (client.Email == User.Identity.Name) { user = client; } } if (tempItem.Quantity > 0 && user.Balance >= tempItem.UnitPrice) { tempItem.Quantity -= 1; user.Balance -= tempItem.UnitPrice; foreach (var item in itemList) { if (item.ProductId == tempItem.ProductId) { item.Quantity = tempItem.Quantity; } } foreach (var client in clientList) { if (user.Email == User.Identity.Name) { client.Balance = user.Balance; } } SaveItem(itemList); SaveUsers(clientList); ShopDBContext db = new ShopDBContext(); db.Orders.Add(new Orders { UserId = User.Identity.GetHashCode(), ItemId = tempItem.ProductId }); db.SaveChanges(); return(View("Review", tempItem)); } else if (tempItem.Quantity <= 0) { ViewBag.Message = "Not enough in stock to purchase."; return(View("Review")); } else { ViewBag.Message = "Not enough funds in your account."; return(View("Review")); } }
public long Insert(DanhMucBaiViet list) { db.DanhMucBaiViets.Add(list); db.SaveChanges(); return(list.ID); }
public void AddItems(Orders order) { _context.Add(order); _context.SaveChanges(); }