public async Task <ActionResult <IEnumerable <Item> > > GetItems() { try { List <Item> items = await _itemContext.FindAll(); List <object> result = new List <object>(); items.ForEach((i) => result.Add(new { Product = _productRepository.GetById(i.ProductId), Quantity = i.Quantity, Id = i.Id })); return(Ok(result)); } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "An unexpected fault happened. Try again later.")); } }