/// <summary> /// выбирает непроданые товары /// </summary> /// <returns></returns> public static IEnumerable <Product> ProductsInStock() { var x = from m in ProductMethods.Outpoot() where m.Status = true select m; return(x); }
/// <summary> /// Поиск по цене(товары с меньшей ценой) /// </summary> /// <param name="price">Цена меньше которой будет поиск</param> /// <returns>Список товаров</returns> public static Dictionary <Product, int> Search(decimal price) { var x = ProductsSortByNameAndPrice(ProductMethods.Outpoot()); Dictionary <Product, int> prod = new Dictionary <Product, int>(); var p = from m in x where m.Key.Price >= price select m; foreach (var item in p) { prod.Add(item.Key, item.Value); } return(prod); }
/// <summary> /// Поиск по названию компании /// </summary> /// <param name="companyName">Название компании</param> /// <returns>Список товаров</returns> public static Dictionary <Product, int> SearchByCompany(string companyName) { var x = ProductsSortByNameAndPrice(ProductMethods.Outpoot()); Dictionary <Product, int> prod = new Dictionary <Product, int>(); var p = from m in x where m.Key.InvoiceForPurchase.CompanyProvider.Name == companyName select m; foreach (var item in p) { prod.Add(item.Key, item.Value); } return(prod); }
/// <summary> /// Поиск по описанию /// </summary> /// <param name="name">Имя товара</param> /// <returns>Список товаров</returns> public static Dictionary <Product, int> SearchByDescription(string name) { var x = ProductsSortByNameAndPrice(ProductMethods.Outpoot()); Dictionary <Product, int> prod = new Dictionary <Product, int>(); var p = from m in x where m.Key.Description.Contains(name) select m; foreach (var item in p) { prod.Add(item.Key, item.Value); } return(prod); }
/// <summary> /// Поиск и продажа товара /// </summary> /// <param name="productName">Название товара</param> /// <param name="Price">Цена товара</param> /// <returns>Логическое значение</returns> public static bool Sales(string productName, decimal Price) { var x = from m in ProductMethods.Outpoot() where productName == m.Name where Price == m.Price orderby m.DateOfPurchase select m; if (x != null) { var f = x.First(); f.Status = false; f.DateOfSale = DateTime.Now; return(ProductMethods.SaveChanges()); } else { return(false); } }
static void Main(string[] args) { List <CategoryEnt> categories = Unit.CategoryRepository.AllItems.ToList(); foreach (var item in categories) { Console.WriteLine(item.Id); Console.WriteLine(item.Name); } List <ProductEnt> u = Unit.ProductRepository.AllItems.ToList(); var x = ProductMethods.Outpoot(); foreach (var item in x) { Console.WriteLine(item.ToString()); Console.WriteLine(item.CategoryId); Console.WriteLine(item.Category.Name); Console.WriteLine($"ID накладной{item.InvoiceForPurchase.Id}\n"); } Console.ReadKey(); }
string ProductCommand(string message, string[] json) { Product data = null;; if (json != null) { data = JsonConvert.DeserializeObject <Product>(json[0]); } string outMessage = null; switch (message) { case "AddItem": ProductMethods.AddItem(data); outMessage = "Добавленно"; break; case "AddItems": List <Product> list = new List <Product>(); int i = 0; foreach (var x in json) { Product u = JsonConvert.DeserializeObject <Product>(json[i]); list.Add(u); } ProductMethods.AddItems(list); outMessage = "Добавленно"; break; case "ChangeItem": if (ProductMethods.ChangeItem(data) == true) { outMessage = "Найден"; } else { outMessage = "Не найден"; } break; case "DeleteItem": ProductMethods.DeleteItem(Convert.ToInt32(json[0])); outMessage = "Удален"; break; case "GetItem": string s = JsonConvert.SerializeObject(ProductMethods.GetItem(Convert.ToInt32(json[0]))); outMessage = s; break; case "Outpoot": string outs = null; List <Product> unitWeights = ProductMethods.Outpoot().ToList(); foreach (var x in unitWeights) { outs = $"{outs}!{JsonConvert.SerializeObject(x)}"; } outMessage = outs; break; default: outMessage = "Product connect"; break; } return(outMessage); }
// GET: Products public ActionResult Index() { return(View(ProductMethods.Outpoot().ToList())); }
public void OutItem() { List <Product> list = ProductMethods.Outpoot().ToList(); Assert.AreNotEqual(null, list); }