public SectionModel(IRepository<Section> sectionContext, Section section) { Id = section.Id; Name = section.Name; Header = section.Header; Content = section.Content; Description = section.Description; LastUpdateDate = section.LastUpdateDate; OrderNumber = section.OrderNumber; SectionList = sectionContext.List; SelectedParentSection = section.ParentSection == null ? 0 : section.ParentSection.Id; }
public ActionResult Create(SectionModel newSection) { try { var section = new Section { Name = newSection.Name, Header = newSection.Header, Content = newSection.Content, Description = newSection.Description, OrderNumber = newSection.OrderNumber, ParentSection = _sectionrepository.FindById(newSection.SelectedParentSection) }; _sectionrepository.Add(section); return RedirectToAction("Index"); } catch { return View(); } }