// GET: Admin/Projects/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Project project = db.Projects.Find(id); if (project == null) { return(HttpNotFound()); } PrictureEdit pom = new PrictureEdit(); pom.Id = project.Id; pom.Caption = project.Caption; pom.Description = project.Description; pom.ImageUrl = project.ImageUrl; pom.ImageUrlSmall = project.ImageUrlSmall; return(View(pom)); }
public ActionResult Edit(PrictureEdit project) { if (ModelState.IsValid) { if (String.IsNullOrEmpty(project.Caption)) { project.Caption = "Solar Project"; } if (String.IsNullOrEmpty(project.Description)) { project.Description = "Solar Project"; } var pro = db.Projects.Find(project.Id); pro.Caption = project.Caption; pro.Description = project.Description; db.Entry(pro).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(project)); }