// GET: Admin/ContentSections/Edit public ActionResult Edit(int id) { var sectionToEdit = pageContentService.FindById(id); var foundSection = new ContentSectionViewModel { Id = sectionToEdit.Id, SectionName = sectionToEdit.SectionName, Title = sectionToEdit.Title, Content = sectionToEdit.Content, Image = sectionToEdit.Image, ImageFile = null }; return(View(foundSection)); }
public ActionResult Edit(ContentSectionViewModel contentSection) { if (!this.ModelState.IsValid) { return(this.View(contentSection)); } var contentToEdit = this.MappingService.Map <ContentSectionViewModel, PageContent>(contentSection); var imageProcessed = this.ImageService.ProcessImage(contentSection.ImageFile); if (!imageProcessed) { ModelState.AddModelError("Image", "The was a problem with your image!"); } this.pageContentService.UpdatePageContent(contentToEdit); return(Redirect("/Admin/ContentSections")); }