public ActionResult Edit(ArticleDto user, HttpPostedFileBase image) { if (image != null) { var allowedContentTypes = new[] { "image/jpeg", "image/jpg", "image/png", "image/gif", "image/tif" }; if (allowedContentTypes.Contains(image.ContentType)) { var imagesPath = "/Content/Images/"; var filename = Guid.NewGuid().ToString() + image.FileName; var uploadPath = imagesPath + filename; var physicalPath = Server.MapPath(uploadPath); image.SaveAs(physicalPath); user.ImagePath = uploadPath; } } else { return(RedirectToAction("Edit")); } OpArticleUpdate op = new OpArticleUpdate(); op.Article = user; OperationResult result = OperationManager.Singleton.ExecuteOperation(op); TempData["Success"] = "Updated Successfully!"; return(RedirectToAction("Index")); }
public ActionResult Edit(ArticleDto dto) { // Check if model state is valid if (ModelState.IsValid) { OpArticleUpdate op = new OpArticleUpdate(); op.Article = dto; OperationResult result = OperationManager.Singleton.ExecuteOperation(op); TempData["Success"] = "Updated Successfully!"; return(RedirectToAction("Index")); } return(View("Edit")); }