public IndexViewModel Index(IndexSetupViewModel inModel) { var products = new List <Product>(); // Test data loaded in for test products.Add(new Product { Name = "Product 1", Description = "This is a test product", Cost = 32m, Price = 50m }); products.Add(new Product { Name = "Product 2", Description = "This is a test product 2", Cost = 12m, Price = 40m }); products.Add(new Product { Name = "Product 3", Description = "This is a test product 3", Cost = 22m, Price = 30m }); products.Add(new Product { Name = "Product 4", Description = "This is a test product 4", Cost = 92m, Price = 150m }); var model = new IndexViewModel(); var list = new List <ProductDisplay>(); foreach (var product in products) { list.Add(new ProductDisplay(product)); } model.Products = list; return(model); }
public IndexViewModel Index(IndexSetupViewModel inModel) { // Todo: Is this what we want here to only show published posts? var posts = _repository.Query <Post>().Where(post => post.Published <= DateTime.Today).OrderByDescending(post => post.Published); return(new IndexViewModel { Posts = posts.ToList().Select(p => new PostDisplay(p)) }); }
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; }
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); }
public IndexViewModel Index(IndexSetupViewModel inModel) { // Todo: Is this what we want here to only show published posts? var posts = _repository.Query<Post>().Where(post=> post.Published <= DateTime.Today).OrderByDescending(post => post.Published); return new IndexViewModel {Posts = posts.ToList().Select(p => new PostDisplay(p))}; }