public IndexViewModel Index(IndexSetupViewModel inModel) { var outModel = new IndexViewModel(); var productList = new List<ProductDisplay>(); productList.Add(new ProductDisplay(new Product { Name = "TestProduct1", Description = "This is a test product"})); productList.Add(new ProductDisplay(new Product { Name = "TestProduct2", Description = "This is a test product"})); productList.Add(new ProductDisplay(new Product { Name = "TestProduct3", Description = "This is a test product"})); outModel.Products = productList; return outModel; }
public IndexViewModel Index(IndexSetupViewModel inModel) { var prod1 = new Product {Name = "TestProduct1", Description = "This is a test product"}; _repository.Save(prod1); var prod2 = new Product {Name = "TestProduct2", Description = "This is a test product"}; _repository.Save(prod2); var outModel = new IndexViewModel(); var productList = _repository.Query<Product>(); outModel.Products = productList.ToList().Select(x => new ProductDisplay(x)); return outModel; }