public ExampleSection(Section entity, ExampleSection parent, bool childs) { if (entity == null) { throw new ArgumentNullException("entity"); } Id = entity.Id; Title = entity.Title; Description = entity.Description; CreatedDate = entity.CreatedDate; ModifiedDate = entity.ModifiedDate; if (parent != null) { ParentSectionId = parent.Id; ParentSection = parent; } if (childs && entity.ChildSections != null && entity.ChildSections.Any()) { ChildSections = entity.ChildSections.Select(s => new ExampleSection(s, false)).ToList(); } else { ChildSections = new List <ExampleSection>(); } }
public ExampleSection(Section entity, ExampleSection parent, bool childs) { if (entity == null) throw new ArgumentNullException("entity"); Id = entity.Id; Title = entity.Title; Description = entity.Description; CreatedDate = entity.CreatedDate; ModifiedDate = entity.ModifiedDate; if (parent != null) { ParentSectionId = parent.Id; ParentSection = parent; } if (childs && entity.ChildSections != null && entity.ChildSections.Any()) { ChildSections = entity.ChildSections.Select(s => new ExampleSection(s, false)).ToList(); } else { ChildSections = new List<ExampleSection>(); } }
public ExampleTopic(Topic entity, ExampleSection section) { if (entity == null) throw new ArgumentNullException("entity"); Id = entity.Id; Title = entity.Title; Text = entity.Text; CreatedDate = entity.CreatedDate; ModifiedDate = entity.ModifiedDate; Status = entity.Status; Author = entity.Author; PictureId = entity.PictureId; SectionId = entity.SectionId; Section = section; if (entity.Messages != null && entity.Messages.Any()) { Messages = entity.Messages.Select(m => new ExampleMessage(m, this)).ToList(); } else { Messages = new List<ExampleMessage>(); } }
public ExampleTopic(Topic entity, ExampleSection section) { if (entity == null) { throw new ArgumentNullException("entity"); } Id = entity.Id; Title = entity.Title; Text = entity.Text; CreatedDate = entity.CreatedDate; ModifiedDate = entity.ModifiedDate; Status = entity.Status; Author = entity.Author; PictureId = entity.PictureId; SectionId = entity.SectionId; Section = section; if (entity.Messages != null && entity.Messages.Any()) { Messages = entity.Messages.Select(m => new ExampleMessage(m, this)).ToList(); } else { Messages = new List <ExampleMessage>(); } }
public async Task<ActionResult> Create(int? id) { if (id == null || id == default(int)) { return View(new ExampleSection()); } var section = await _sectionService.FindByIdAsync(id.Value); if (section == null) { return HttpNotFound(); } var newSection = new ExampleSection { ParentSectionId = id, ParentSection = new ExampleSection(section, false) }; return View(newSection); }