public ActionResult Edit(Product product, int ProductModelId, int ProductCategoryID, int ProductSubCategoryID, HttpPostedFileBase file) { product.ProductModelId = ProductModelId; product.ProductSubCategoryID = ProductSubCategoryID; product.rowguid = Guid.NewGuid(); product.ModifiedDate = DateTime.Now; if (ModelState.IsValid) { if (file != null) { Photo photo = new Photo(); photo.rowguid = Guid.NewGuid(); photo.ModifiedDate = DateTime.Now; photo.Name = file.FileName; photo.Image = new byte[file.ContentLength]; file.InputStream.Read(photo.Image, 0, file.ContentLength); context.Entry(photo).State = EntityState.Modified; context.Photo.Add(photo); context.SaveChanges(); } context.Entry(product).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index")); } return(View(product)); }
public ActionResult Edit(ProductModel model) { model.ModifiedDate = DateTime.Now; context.Entry(model).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Edit(ProductSubCategory category) { category.ModifiedDate = DateTime.Now; context.Entry(category).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("List")); }
public async Task <IActionResult> PutCustomer(int id, Customer customer) { if (id != customer.CustomerId) { return(BadRequest()); } _context.Entry(customer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProduct(int id, Product product) { if (id != product.ProductId) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }