- First, let's add the AutoMapper dependency to project.json.
- After that, we will create the ProductRepository with fake data. Our HomeController controller class will consume the data from this repository. The objects consumed from the repository will be ProductDto objects, but we will use them only to transport data between the repository and the controller:
public class ProductDataStore{ public static ProductDataStore Current { get; } = new ProductDataStore(); public List<ProductDto> Products { get; set; } public ProductDataStore() { Products = new List<ProductDto>() { new ProductDto { Id = 1, Name = "Laptop" }, new ProductDto { Id = 2, Name = "Phone" }, new ProductDto { Id = 3, Name = "Desktop" } }; }}public interface ...