public async Task <IEnumerable <ApiModels.PrimaryObject> > GetAllAsync() { var domainPrimaryObjects = await _primaryObjectService.GetAllAsync(); Ensure.That(domainPrimaryObjects, nameof(domainPrimaryObjects)) .WithException(_ => new HttpResponseException(HttpStatusCode.NotFound)) .IsNotNull(); return(domainPrimaryObjects.Select(this.Map).ToArray()); }
public async Task <ActionResult> Index() { var primaryObjects = await _primaryObjectService.GetAllAsync(); var models = primaryObjects.Select(po => new Models.PrimaryObject() { Id = po.Id, Description = po.Description, Name = po.Name, SecondaryObjects = new Models.SecondaryObject[0], }) .OrderBy(_ => _.Name) .ToArray(); return(View(models)); }