public async Task <IHttpActionResult> PutOrder(int id, Order order) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != order.OrderId) { return(BadRequest()); } db.Entry(order).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Update(Category cat) { if (cat != null) { var category = GetById(cat.CategoryId); if (category != null) { db.Entry(category).CurrentValues.SetValues(cat); db.Entry(category).State = EntityState.Modified; } else { db.Entry(cat).State = EntityState.Modified; } } }
public void Update(Supplier sup) { if (sup != null) { var supplier = GetById(sup.SupplierId); if (supplier != null) { db.Entry(supplier).CurrentValues.SetValues(sup); db.Entry(supplier).State = EntityState.Modified; } else { db.Entry(sup).State = EntityState.Modified; } } }
public void Update(Product prod) { if (prod != null) { var product = GetById(prod.ProductId); if (product != null) { db.Entry(product).CurrentValues.SetValues(prod); db.Entry(product).State = EntityState.Modified; } else { db.Entry(prod).State = EntityState.Modified; } } }
public ActionResult Edit(User usr) { if (Session["UserId"] != null && Session["Role"].ToString() == "user") { string username = User.Identity.Name; User user = db.Users.FirstOrDefault(u => u.UserId.Equals(username)); user.Firstname = usr.Firstname; user.Lastname = usr.Lastname; user.Address = usr.Address; user.ContactNumber = usr.ContactNumber; user.City = usr.City; user.Country = usr.Country; user.Password = user.Password; user.ConfirmPassword = user.Password; Session["Username"] = (user.Firstname + " " + user.Lastname).ToString(); db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(View(usr)); } else { return(RedirectToAction("Index", "User")); } }
public ActionResult ProductView(string ProductId) { if (ProductId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Product product = db.Products.Find(ProductId); if (product == null) { return(HttpNotFound()); } if (product.Stock < 30) { product.SpecialDiscount = 25; db.Entry(product).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } DateTime dt1 = new DateTime(2020, 09, 23); DateTime dt2 = new DateTime(2020, 09, 20); DateTime dt3 = new DateTime(2020, 09, 21); if (DateTime.Now.Date == dt1.Date && DateTime.Now.Month == dt1.Month) { product.SpecialDiscount = 24; db.Entry(product).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } if (DateTime.Now.Date == dt2.Date && DateTime.Now.Month == dt2.Month) { product.SpecialDiscount = 23; db.Entry(product).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } if (DateTime.Now.Date == dt3.Date && DateTime.Now.Month == dt3.Month) { product.SpecialDiscount = 13; db.Entry(product).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(View(product)); }
public ActionResult EditSupplier([Bind(Include = "SupplierId,SupplierName")] Supplier supplier) { if (Session["UserId"] != null && Session["Role"].ToString() == "Admin") { if (ModelState.IsValid) { db.Entry(supplier).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(supplier)); } else { return(RedirectToAction("Login")); } }
public void Update(ProductSupplier ps) { db.Entry(ps).State = EntityState.Modified; }
public async Task UpdateAsync(T entity) { _context.Entry(entity).State = EntityState.Modified; await _context.SaveChangesAsync(); }