public async Task <ActionResult> Edit([Bind(Include = "CategoryId,Description")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(category)); }
public async Task <ActionResult> Edit(ProductView view) { if (ModelState.IsValid) { var pic = string.Empty; var folder = "~/Content/Images"; if (view.ImageFile != null) { pic = FileHerpels.FileUpload(view.ImageFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var viewProduct = ToProductView(view); viewProduct.Image = pic; db.Entry(viewProduct).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories.OrderBy(c => c.Description), "CategoryId", "Description", view.CategoryId); return(View(view)); }