public static List <crops> GetAllProducts() { List <crops> allcrops = new List <crops>(); allcrops = DBManager.GetAllProducts(); // fiter data // sort data and send Analytical data back to Controller action method // according to business logic modify data and store back to data base return(allcrops); /* allProducts.Add(new Product { ID = 1, Title = "Gerbera", Description = "Wedding Flower", UnitPrice = 6, Quantity = 5000 }); * allProducts.Add(new Product { ID = 2, Title = "Rose", Description = "Valentine Flower", UnitPrice = 15, Quantity = 7000 }); * allProducts.Add(new Product { ID = 3, Title = "Lotus", Description = "Worship Flower", UnitPrice = 26, Quantity = 0 }); * allProducts.Add(new Product { ID = 4, Title = "Carnation", Description = "Pink carnations signify a mother's love, red is for admiration and white for good luck", UnitPrice = 16, Quantity = 27000 }); * allProducts.Add(new Product { ID = 5, Title = "Lily", Description = "Lilies are among the most popular flowers in the U.S.", UnitPrice = 6, Quantity = 1000 }); * allProducts.Add(new Product { ID = 6, Title = "Jasmine", Description = "Jasmine is a genus of shrubs and vines in the olive family", UnitPrice = 26, Quantity = 0 }); * allProducts.Add(new Product { ID = 7, Title = "Daisy", Description = "Give a gift of these cheerful flowers as a symbol of your loyalty and pure intentions.", UnitPrice = 36, Quantity = 159 }); * allProducts.Add(new Product { ID = 8, Title = "Aster", Description = "Asters are the September birth flower and the the 20th wedding anniversary flower.", UnitPrice = 16, Quantity = 67 }); * allProducts.Add(new Product { ID = 9, Title = "Daffodil", Description = "Wedding Flower", UnitPrice = 6, Quantity = 5000 }); * allProducts.Add(new Product { ID = 10, Title = "Dahlia", Description = "Dahlias are a popular and glamorous summer flower.", UnitPrice = 7, Quantity = 0 }); * allProducts.Add(new Product { ID = 11, Title = "Hydrangea", Description = "Hydrangea is the fourth wedding anniversary flower", UnitPrice = 12, Quantity = 0 }); * allProducts.Add(new Product { ID = 12, Title = "Orchid", Description = "Orchids are exotic and beautiful, making a perfect bouquet for anyone in your life.", UnitPrice = 10, Quantity = 700 }); * allProducts.Add(new Product { ID = 13, Title = "Statice", Description = "Surprise them with this fresh, fabulous array of Statice flowers", UnitPrice = 16, Quantity = 1500 }); * allProducts.Add(new Product { ID = 14, Title = "Sunflower", Description = "Sunflowers express your pure love.", UnitPrice = 8, Quantity = 2300 }); * allProducts.Add(new Product { ID = 15, Title = "Tulip", Description = "Tulips are the quintessential spring flower and available from January to June.", UnitPrice = 17, Quantity = 10000 }); * * * return allProducts;*/ }
public static Product GetFifthProduct() { List <Product> products = DBManager.GetAllProducts(); Product product5 = products.FirstOrDefault(p => p.ID == 5); return(product5); }
public static List <string> GetProductsDistinct() { List <Product> products = DBManager.GetAllProducts(); var categoryNames = (from prod in products select prod.Quantity).Distinct(); return(categoryNames as List <string>); }
public static dynamic GetProductDetails() { List <Product> products = DBManager.GetAllProducts(); var productInfos = from prod in products select new { prod.Title, prod.Description, Price = prod.UnitPrice }; return(productInfos); }
public static List <string> GetProjectTitles() { List <Product> products = DBManager.GetAllProducts(); var productNames = from prod in products select prod.Title; return(productNames as List <string>); }
// methods for LINQ TryOuts /* public static List<Product> GetSoldOutProducts() * { * //List<Product> products = GetAllProducts(); * List<Product> products = GetAllProductsFromDatabase(); * * var soldOutProducts = from prod in products * where prod.Quantity == 0 * select prod; * return soldOutProducts as List<Product>; * } */ public static List <Product> GetProuductsInStockLessthan(int amount) { List <Product> products = DBManager.GetAllProducts(); var expensiveInStockProducts = from prod in products where prod.Quantity > 0 && prod.UnitPrice > amount select prod; return(expensiveInStockProducts as List <Product>); }
public static dynamic GetProductCount() { List <Product> products = DBManager.GetAllProducts(); var categoryCounts = from prod in products group prod by prod.Quantity into prodGroup select new { Category = prodGroup.Key, ProductCount = prodGroup.Count() }; return(categoryCounts); }
public static List <Product> GetProductsGroupByQuantity() { List <Product> products = DBManager.GetAllProducts(); var orderGroups = from prod in products group prod by prod.Quantity into prodGroup select new { Category = prodGroup.Key, Products = prodGroup }; return(orderGroups as List <Product>); }
public static List <Product> GetProductsByDescending() { List <Product> products = DBManager.GetAllProducts(); var sortedProducts = from prod in products orderby prod.Quantity descending select prod; return(sortedProducts as List <Product>); }
public static List <Product> GetAllProductsFromDatabase() { List <Product> allProducts = DBManager.GetAllProducts(); return(allProducts); }