public ProductDto MapToDto(Product item) { if (item == null) { return(null); } return(new ProductDto { ProductId = item.ProductId, CategoryId = item.CategoryId, Discontinued = item.Discontinued, ProductName = item.ProductName, QuantityPerUnit = item.QuantityPerUnit, ReorderLevel = item.ReorderLevel, SupplierId = item.SupplierId, UnitsOnOrder = item.UnitsOnOrder, UnitsInStock = item.UnitsInStock, UnitPrice = item.UnitPrice, Category = _categoryDtoMapper.MapToDto(item.Category), Supplier = _supplierDtoMapper.MapToDto(item.Supplier) }); }
public async Task <IEnumerable <CategoryDto> > GetAllAsync() { var categories = await _categoriesRepository.GetAllAsync(); return(categories.Select(x => _categoryDtoMapper.MapToDto(x))); }