public void Insert(Product product, string username) { product.Id = GetNewId(ID_PREFIX_PRODUCT); product.View = 0; product.Username = username; db.Products.Add(product); db.SaveChanges(); }
public string Insert(string recipient, string address, string phone) { Order order = new Order(); order.Id = GetNewId(); order.CustomerName = recipient; order.Address = address; order.PhoneNumber = phone; order.CreatedDate = DateTime.Now; order.Status = 0; db.Orders.Add(order); db.SaveChanges(); return(order.Id); }
public ActionResult Edit([Bind(Include = "Id,CreatedDate,TotalCost,Status,CustomerId,CustomerName,Address,PhoneNumber")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(order)); }
public static HeaderTransaction InsertHeaderTransaction(HeaderTransaction headerTransaction) { using (WatchShopEntities db = new WatchShopEntities()) { db.HeaderTransaction.Add(headerTransaction); db.SaveChanges(); return(headerTransaction); } }
public static void DecreaseStock(int id, int quantity) { using (WatchShopEntities db = new WatchShopEntities()) { Product product = db.Product.Where(x => x.id == id).FirstOrDefault(); product.stock -= quantity; db.SaveChanges(); } }
public static DetailTransaction InsertDetailTransaction(DetailTransaction detailTransaction) { using (WatchShopEntities db = new WatchShopEntities()) { db.DetailTransaction.Add(detailTransaction); db.SaveChanges(); int productId = detailTransaction.product_id; int quantity = detailTransaction.quantity.Value; ProductRepository.DecreaseStock(productId, quantity); return(detailTransaction); } }
protected void DeleteButton_Click(object sender, EventArgs e) { Button currentButton = (Button)sender; int selectedRowIndex = 0; if (int.TryParse(currentButton.ID.Substring(0, currentButton.ID.Length - 2), out selectedRowIndex)) { int productId = int.Parse(((Label)ProductTable.Rows[selectedRowIndex].Cells[6].Controls[0]).Text); using (WatchShopEntities db = new WatchShopEntities()) { Product toDeleteProduct = db.Product.Where(x => x.id == productId).First(); db.Product.Remove(toDeleteProduct); db.SaveChanges(); } Response.Redirect(Request.RawUrl); } }
public void Insert(Branch branch) { branch.Id = GetNewId(); db.Branches.Add(branch); db.SaveChanges(); }
public void Insert(User user) { db.Users.Add(user); db.SaveChanges(); }
public void Create(Role role) { db.Roles.Add(role); db.SaveChanges(); }
public void Insert(UserGroup userGroup) { userGroup.Id = GetNewId(ID_USER_GROUP_PREFIX); db.UserGroups.Add(userGroup); db.SaveChanges(); }