public static Dto.Section ConvertToDto(this Model.Section section, bool include_children = false) { Dto.Section sectionDto = new Dto.Section { Enabled = section.Enabled, Id = section.Id, EditionId = section.EditionId, Edition = (section.Edition != null) ? section.Edition.ConvertToDto() : null, Name = section.Name, Sort_Key = section.Sort_Key, Modules = (section.Modules != null && include_children) ? section.Modules.ForeachToDto(): null, }; return(sectionDto); }
public static Model.Section ConvertToEntity(this Dto.Section sectionDto, Model.Section section = null) { if (section == null) { section = new Model.Section(); } section.Enabled = sectionDto.Enabled; section.Id = sectionDto.Id; section.EditionId = sectionDto.EditionId; if (sectionDto.Edition != null) { section.Edition = sectionDto.Edition.ConvertToEntity(); } section.Name = sectionDto.Name; section.Sort_Key = sectionDto.Sort_Key; return(section); }