public ActionResult UpdateBook(Book model) { ViewData["CategoryID"] = new SelectList( //db.Categories.ToList() categoryConcrete.GetCategoryList() .Select(x => new { x.CategoryID, x.CategoryName }), "CategoryID", "CategoryName"); ViewData["AuthorID"] = new SelectList( //db.Authors.ToList() authorConcrete.GetAuthorList() .Select(x => new { x.AuthorID, AuthorName = x.FirstName + " " + x.LastName }) , "AuthorID", "AuthorName"); ViewData["StatusID"] = new SelectList( //db.Statuses.ToList() statusConcrete.GetStatusList() .Select(x => new { x.StatusID, x.StatusName }), "StatusID", "StatusName"); if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0) { try { var file = Request.Files[0]; string pic = System.IO.Path.GetFileName(file.FileName); string path = System.IO.Path.Combine( Server.MapPath("~/img/Books"), pic); // file is uploaded file.SaveAs(path); model.ImageUrl = "~/img/Books/" + pic; } catch (Exception ex) { ModelState.AddModelError("Error", "Resim yüklenemiyor!" + ex.Message); return(View(model)); } } if (false && !ModelState.IsValid) { ModelState.AddModelError("Error", "Bir hata oluştu!"); return(View(model)); } else { try { //repBook.Update(model); //uow.SaveChanges(); bookConcrete.Update(model); return(RedirectToAction("MyBooks")); } catch (Exception ex) { ModelState.AddModelError("Error", ex); return(View(model)); } } }