public async Task <IActionResult> PutOrder([FromRoute] long id, [FromBody] Order order) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != order.Id) { return(BadRequest()); } _context.Entry(order).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IHttpActionResult PutProduct(int id, Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.ProductID) { return(BadRequest()); } db.Entry(product).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutManufacturer(int id, Manufacturer manufacturer) { if (id != manufacturer.Id) { return(BadRequest()); } if (manufacturer.Name == "") { return(BadRequest("Manufacturer name can't be empty!")); } if (_context.Manufacturers.Any(m => m.Id != id && m.Name == manufacturer.Name)) { return(BadRequest("Manufacturer name is already taken!")); } _context.Entry(manufacturer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ManufacturerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCategory(int id, Category category) { if (id != category.Id) { return(BadRequest()); } _context.Entry(category).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutItem(int id, Item item) { if (id != item.Id) { return(BadRequest()); } if (_context.Items.Any(i => i.Id != id && i.Name == item.Name)) { return(BadRequest("Item name is already taken!")); } _context.Entry(item).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void UpdateCategory(Category category) { using (var context = new EShopContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void UpdateProduct(Product product) { using (var context = new EShopContext()) { context.Entry(product).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void SaveProduct(Product product) { using (var context = new EShopContext()) { context.Entry(product.Category).State = System.Data.Entity.EntityState.Unchanged; context.Products.Add(product); context.SaveChanges(); } }
public async Task <ActionResult <Page> > PutPage(Guid id, Page page) { if (page.Id != id) { return(BadRequest()); } _context.Entry(page).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public ActionResult Edit([Bind(Include = "ItemId,CategoryId,ProductId,Title,Price,Descript,Image")] Item item) { if (ModelState.IsValid) { db.Entry(item).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", item.CategoryId); ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Name", item.ProductId); return(View(item)); }
public bool UpdateOrderStatus(int ID, string status) { using (var context = new EShopContext()) { var order = context.Orders.Find(ID); order.Status = status; context.Entry(order).State = EntityState.Modified; return(context.SaveChanges() > 0); } }
public ProductCart Update(ProductCart productCart) { _context.Entry(productCart).State = EntityState.Modified; _context.SaveChanges(); return(productCart); }
public void Update(Order order) { _context.Entry(order).State = EntityState.Modified; }
public void Update(User user) { _context.Entry(user).State = EntityState.Modified; }
public void Update(Product product) { _context.Entry(product).State = EntityState.Modified; }
public void Update(Category category) { _context.Entry(category).State = EntityState.Modified; }