public ActionResult Edit([Bind(Include = "Id,Name,Description,Price,PictureUrl,Category")] Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product)); }
public ActionResult Edit([Bind(Include = "Id,Paid,Received,Name,SecondName,StudentNumber,Barcode,Faculty,Mode")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(order)); }
public ActionResult Edit([Bind(Include = "Id,Number,Quantity,OrderId,ProductId")] OrderDetail orderDetail) { if (ModelState.IsValid) { db.Entry(orderDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrderId = new SelectList(db.Orders, "Id", "Name", orderDetail.OrderId); ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", orderDetail.ProductId); return(View(orderDetail)); }
public Product UpdateProductById(int id, Product p) { Product oldProduct = db.Products.Find(id); if (oldProduct == null || oldProduct.Id != p.Id) { return(null); } db.Entry(p).State = EntityState.Modified; db.SaveChanges(); return(p); }
public Order UpdateOrderById(int id, Order o) { Order newOrder = db.Orders.Find(id); if (newOrder == null || newOrder.Id != o.Id) { return(null); } newOrder.Name = o.Name; newOrder.SecondName = o.SecondName; newOrder.StudentNumber = o.StudentNumber; newOrder.Mode = o.Mode; newOrder.Faculty = o.Faculty; newOrder.Paid = o.Paid; newOrder.Received = o.Received; db.Entry(newOrder).State = EntityState.Modified; db.SaveChanges(); return(o); }