public ActionResult Lista(string tag = "") { var products = _mediator.Send(new ProductList.Query()); ViewBag.Tag = tag; return(View(Products.All(tag))); }
public void Update_MultipleRows() { // first insert 2 categories and 4 products, one for each category var categories = new Categories(ProviderName); var insertedCategory1 = categories.Insert(new { CategoryName = "Category 1", Description = "Cat 1 desc" }); int category1ID = insertedCategory1.CategoryID; Assert.IsTrue(category1ID > 0); var insertedCategory2 = categories.Insert(new { CategoryName = "Category 2", Description = "Cat 2 desc" }); int category2ID = insertedCategory2.CategoryID; Assert.IsTrue(category2ID > 0); var products = new Products(ProviderName); for (int i = 0; i < 4; i++) { var category = i % 2 == 0 ? insertedCategory1 : insertedCategory2; var p = products.Insert(new { ProductName = "Prod" + i, category.CategoryID }); Assert.IsTrue(p.ProductID > 0); } var allCat1Products = products.All(where : "WHERE CategoryID=@0", args: category1ID).ToArray(); Assert.AreEqual(2, allCat1Products.Length); foreach (var p in allCat1Products) { Assert.AreEqual(category1ID, Convert.ToInt32(p.CategoryID)); // convert from uint p.CategoryID = category2ID; } Assert.AreEqual(2, products.Save(allCat1Products)); }
public override IEnumerable <dynamic> Get([FromUri] GetModel model) { if (model?.FilterKey == null) { return(Products.All()); } var filter = Filters.Get(model.FilterKey.Value); return(Products.Find(filter["Name"].ToString(), filter["Category"].ToString())); }
public void Update_MultipleRows(bool explicitConnection) { // first insert 2 categories and 4 products, one for each category var categories = new Categories(explicitConnection); DbConnection connection = null; if (explicitConnection) { MightyTests.ConnectionStringUtils.CheckConnectionStringRequiredForOpenConnection(categories); connection = categories.OpenConnection(MightyTests.ConnectionStringUtils.GetConnectionString(TestConstants.WriteTestConnection, TestConstants.ProviderName)); } using (connection) { var insertedCategory1 = categories.Insert(new { CategoryName = "Category 1", Description = "Cat 1 desc" }, connection); int category1ID = insertedCategory1.CategoryID; Assert.IsTrue(category1ID > 0); var insertedCategory2 = categories.Insert(new { CategoryName = "Category 2", Description = "Cat 2 desc" }, connection); int category2ID = insertedCategory2.CategoryID; Assert.IsTrue(category2ID > 0); var products = new Products(explicitConnection); if (explicitConnection) { MightyTests.ConnectionStringUtils.CheckConnectionStringRequiredForOpenConnection(products); } for (int i = 0; i < 4; i++) { var category = i % 2 == 0 ? insertedCategory1 : insertedCategory2; var p = products.Insert(new { ProductName = "Prod" + i, category.CategoryID }, connection); Assert.IsTrue(p.ProductID > 0); } var allCat1Products = products.All(connection, where : "WHERE CategoryID=@0", args: category1ID).ToArray(); Assert.AreEqual(2, allCat1Products.Length); foreach (var p in allCat1Products) { Assert.AreEqual(category1ID, p.CategoryID); p.CategoryID = category2ID; } Assert.AreEqual(2, products.Save(connection, allCat1Products)); } }
private void ClearProductSelected() { Products.All(p => p.Seleted = false); }
public ActionResult Index() { var products = new Products(); return(View(products.All().ToList <dynamic>())); }
// <asp:Repeater SelectMethod="GetItems" /> public IEnumerable<dynamic> GetItems() { var products = new Products(); return products.All(where: "WHERE CategoryID = @0", args: 4); }