public void Present(GetAllBeersResponse response) { ViewModel = new ApiGetAllBeersViewModel { HttpCode = response.Data.Any() ? 200 : 204, Success = true, Data = response.Data.Select(x => new { Id = x.Id.Value, Label = x.Label.Value, Description = x.Description.Value, Stock = x.Stock.Value, Available = x.Stock.Value > 0, LimitedStock = x.Stock.Value <= 50 }), Page = response.Page, PerPage = response.PerPage, Total = response.Total }; }
public void Present(GetAllBeersResponse response) { var vmHttpCode = response.Beers.Count > 0 ? 200 : 204; var vmData = response.Beers.Select(b => new ApiGetAllBeersViewModel.Beer { Id = b.Id.Value, Label = b.Label.Value, Description = b.Description.Value, Stock = b.Stock.Value, Available = b.Stock.Value > 0, LastItems = b.Stock.Value > 0 && b.Stock.Value <= 10 }).ToList(); ViewModel = new ApiGetAllBeersViewModel { HttpCode = vmHttpCode, Data = vmData }; }