public ActionResult Put(Guid id, [FromBody] SectionApiModel section) { try { ApiResponse serviceResponse = this._sectionService.Update(id, section.Name); if (serviceResponse.IsSuccess()) { return(new ObjectUpdatedResult(serviceResponse.Id.Value)); } else { return(new ValidationErrorResult(serviceResponse)); } } catch (Exception ex) { return(new UnknownErrorResult(ex, base._errorEnabled)); } }
public static SectionApiModel Map(Section section, bool nested = true) { if (section == null) { return(null); } SectionApiModel sectionApiModel = new SectionApiModel() { Id = section.Id, Name = section.Name, Parent = Map(section.ParentSection, false) }; sectionApiModel.Children = new List <SectionApiModel>(); if (nested) { foreach (var subsection in section.SubSections) { sectionApiModel.Children.Add(Map(subsection)); } } return(sectionApiModel); }