public async Task <IActionResult> PutMenuItem(long id, MenuItem menuItem) { if (id != menuItem.Id) { return(BadRequest()); } _context.Entry(menuItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MenuItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTimeSheet(long id, long employeeId, TimeSheet timeSheet) { if (id != timeSheet.Id && employeeId != timeSheet.EmployeeId) { return(BadRequest()); } _context.Entry(timeSheet).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TimeSheetExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Update(Picture item) { var photo = _context.Pictures.FirstOrDefault(o => o.Id == item.Id); bool isModified = false; if (photo.Name != item.Name) { photo.Name = item.Name; isModified = true; } if (photo.Path != item.Path) { photo.Path = item.Path; isModified = true; } if (photo.UpdateTimestamp != item.UpdateTimestamp) { photo.Path = item.Path; isModified = true; } if (isModified) { _context.Entry(photo).State = EntityState.Modified; _context.SaveChanges(); } }
public IHttpActionResult PutProduct(int id, ProductUpdateRequestModel requestModel) { Product product = _ctx.Products.FirstOrDefault(x => x.Id == id); if (product == null) { return(NotFound()); } product.Name = requestModel.Name; try { _ctx.Entry(product).State = EntityState.Modified; _ctx.SaveChanges(); } catch (Exception ex) { throw; } return(Content(HttpStatusCode.OK, new ProductDto { Id = product.Id, StoreId = product.StoreId, Name = product.Name })); }
public async Task <IActionResult> PutEmployee(long id, Employee employee) { if (id != employee.Id) { return(BadRequest()); } _context.Entry(employee).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "Id,Quantity,Date")] 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,FName,LName,DateOfRegistration,Email")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Edit([Bind(Include = "Id,Name,Price,Description,DateOfAdding")] Good good) { if (ModelState.IsValid) { db.Entry(good).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(good)); }
public ActionResult Edit([Bind(Include = "OrderID,UserID,DeliveryName,DeliveryAddress,TotalPrice,DateCreated")] 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,FileName")] ProductImage productImage) { if (ModelState.IsValid) { db.Entry(productImage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productImage)); }
public ActionResult Edit([Bind(Include = "ID,Name")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit([Bind(Include = "ID,ImageNumber,ProductID,ProductImageID")] ProductImageMapping productImageMapping) { if (ModelState.IsValid) { db.Entry(productImageMapping).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductID = new SelectList(db.Products, "ID", "Name", productImageMapping.ProductID); ViewBag.ProductImageID = new SelectList(db.ProductImages, "ID", "FileName", productImageMapping.ProductImageID); return(View(productImageMapping)); }
public void Update(Product item) { var product = _context.Products.FirstOrDefault(o => o.Id == item.Id); bool isModified = false; if (product.Name != item.Name) { product.Name = item.Name; isModified = true; } if (product.Descriptions != item.Descriptions) { product.Descriptions = item.Descriptions; isModified = true; } if (product.Price != item.Price) { product.Price = item.Price; isModified = true; } if (product.CategoryId != item.CategoryId) { product.CategoryId = item.CategoryId; isModified = true; } if (product.IsDeleted != item.IsDeleted) { product.IsDeleted = item.IsDeleted; isModified = true; } if (product.Count != item.Count) { product.Count = item.Count; isModified = true; } if (isModified) { _context.Entry(product).State = EntityState.Modified; _context.SaveChanges(); } }
public void Update(Mark item) { var mark = _context.Marks.FirstOrDefault(o => o.Id == item.Id); bool isModified = false; if (mark.Name != item.Name) { mark.Name = item.Name; isModified = true; } if (isModified) { _context.Entry(mark).State = EntityState.Modified; _context.SaveChanges(); } }
public void Update(Category item) { var category = _context.Categories.FirstOrDefault(o => o.Id == item.Id); bool isModified = false; if (category.Name != item.Name) { category.Name = item.Name; isModified = true; } if (isModified) { _context.Entry(category).State = EntityState.Modified; _context.SaveChanges(); } }
public void Update(Order item) { var order = _context.Orders.Include("Products").Include("User").FirstOrDefault(o => o.Id == item.Id); bool isModified = false; if (order.OrderDate != item.OrderDate) { order.OrderDate = item.OrderDate; isModified = true; } if (order.OrderPrice != item.OrderPrice) { order.OrderPrice = item.OrderPrice; isModified = true; } if (order.Quantity != item.Quantity) { order.Quantity = item.Quantity; isModified = true; } //Просмотреть в дебаге как будет обарабатываться изменение продуктов заказе //Придется дописать if (order.Products.Count != item.Products.Count) { order.Products = item.Products; isModified = true; } if (isModified) { _context.Entry(order).State = EntityState.Modified; _context.SaveChanges(); } }
public virtual bool Edit(T entity) { _entities.Entry(entity).State = EntityState.Modified; return(true); }