public IHttpActionResult PutCustomer(int id, Customer customer) { if (id != customer.CustomerID) { return(BadRequest()); } db.Entry(customer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public User UpdateUser(UserViewModel userViewModel) { User user = _db.Users.Where(u => u.Id == userViewModel.Id).FirstOrDefault(); if (user != null) { user.UserName = userViewModel.UserName; user.EmailAddress = userViewModel.EmailAddress; user.Password = userViewModel.Password; user.ConfirmPassword = userViewModel.ConfirmPassword; _db.Entry(user).State = EntityState.Modified; _db.SaveChanges(); } return(user); }
public Product UpdateProduct(ProductViewModel productViewModel) { Product product = _db.Products.Where(u => u.Id == productViewModel.Id).FirstOrDefault(); if (product != null) { product.Name = productViewModel.Name; product.Price = productViewModel.Price; product.Quantity = productViewModel.Quantity; _db.Entry(product).State = EntityState.Modified; _db.SaveChanges(); } return(product); }
public ActionResult Edit([Bind(Include = "Customer_No,Customer_Name")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }