public static bool EditMenuSection(MenuSections menuSection, out string message) { try { MenuSections ms = db.MenuSections.Find(menuSection.MenuSectionId); if (ms != null) { var oldMenuSectionName = ms.MenuSectionName; ms.MenuSectionName = menuSection.MenuSectionName; List <MenuPoints> menuPoints = db.MenuPoints.Where(mp => mp.MenuSectionName == oldMenuSectionName).ToList(); foreach (MenuPoints menuPoint in menuPoints) { menuPoint.MenuSectionName = menuSection.MenuSectionName; } db.SaveChanges(); message = "Menu section was edited successfully"; return(true); } message = "Error"; return(false); } catch (Exception ex) { message = ex.Message; return(false); } }
public static bool DeleteMenuSection(int MenuSectionId, out string message) { try { MenuSections menuSection = db.MenuSections.Find(MenuSectionId); if (menuSection != null) { db.MenuSections.Remove(menuSection); List <MenuPoints> menuPoints = db.MenuPoints.Where(mp => mp.MenuSectionName == menuSection.MenuSectionName).ToList(); foreach (MenuPoints menuPoint in menuPoints) { db.MenuPoints.Remove(menuPoint); } db.SaveChanges(); message = "Menu section was deleted successfully"; return(true); } message = "Error"; return(false); } catch (Exception ex) { message = ex.Message; return(false); } }
public Product(string name, MenuSections section, double price) { Name = name; Section = section; Price = price; productId = Int32.Parse(DateTime.Now.Ticks.ToString().Remove(0, 9)); }
public ActionResult DeleteMenuSection(int MenuSectionId, string message) { ViewBag.Message = message; MenuSections menuSection = db.MenuSections.Find(MenuSectionId); return(View(menuSection)); }
public static void AddProd() { ProductsCollection productsCollection = new ProductsCollection(); Storage storage = new Storage(); while (true) { Console.Write("name "); string name = Console.ReadLine(); if (name == "quit") { break; } Console.Write("Section "); string sectionStr = Console.ReadLine(); MenuSections sections = MenuSections.Гарниры; if (sectionStr == "1") { sections = MenuSections.Первое; } else if (sectionStr == "2") { sections = MenuSections.Гарниры; } else if (sectionStr == "3") { sections = MenuSections.Салаты; } else if (sectionStr == "4") { sections = MenuSections.Десерты; } else if (sectionStr == "5") { sections = MenuSections.Напитки; } Console.Write("price "); double price = double.Parse(Console.ReadLine()); productsCollection.Add(new Product(name, sections, price)); Console.WriteLine(new String('-', 30)); } foreach (Product product in productsCollection) { Console.Write(product.Name + " Quantity "); int quantity = int.Parse(Console.ReadLine()); storage.Add(product.ProductId, quantity); } DataBaseController.AllProductsSave(productsCollection); DataBaseController.StorageBaseSave(storage); Console.ReadKey(); }
public ActionResult DeleteMenuSectionPost(MenuSections menuSections) { string message = ""; if (BLL.Service.DeleteMenuSection(menuSections, out message)) { return(RedirectToAction("HookahBarDrinksMenuSections")); } else { return(RedirectToAction($"DeleteMenuSectionsPost/{menuSections.Id}", new { menuSections = menuSections, message = message })); } }
public ActionResult EditMenuSection(MenuSections menuSection) { string message = ""; if (AboutUsService.EditMenuSection(menuSection, out message)) { return(RedirectToAction("MenuSectionsList")); } else { return(RedirectToAction("EditMenuSection", new { menuSection = menuSection, message = message })); } }
private List <Product> GetProdInSection(MenuSections section) { List <Product> prodList = new List <Product>(); foreach (Product product in allProducts) { if (product.Section == section) { prodList.Add(product); } } return(prodList); }
public static bool CreateMenuSection(MenuSections menuSections, out string message) { try { db.MenuSections.Add(menuSections); db.SaveChanges(); message = $"{menuSections.Name} Created"; return(true); } catch (Exception ex) { message = ex.Message; return(false); } }
public static bool AddMenuSection(MenuSections menuSection, out string message) { try { db.MenuSections.Add(menuSection); db.SaveChanges(); message = "Menu section was added successfully"; return(true); } catch (Exception ex) { message = ex.Message; return(false); } }
public void ShowMenu() { Console.WriteLine("cart - открыть корзину; quit - выход;" + Environment.NewLine); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(new string('-', 15) + " M e n u " + new string('-', 15)); Console.ForegroundColor = ConsoleColor.Gray; int numerator = 0; foreach (var section in MenuSections.GetValues(typeof(MenuSections))) { ++numerator; Console.WriteLine(numerator + ". " + section.ToString()); } Console.WriteLine(new string('-', 50)); }
public static bool EditMenuSection(MenuSections menuSections, out string message) { try { MenuSections old = db.MenuSections.ToList().FirstOrDefault(p => p.Id == menuSections.Id); string oldNameMenuSection = old.Name; old.Name = menuSections.Name; List <HookahBarDrinks> oldBar = db.HookahBarDrinks.ToList().Where(p => p.TableName == oldNameMenuSection).ToList(); foreach (var item in oldBar) { item.TableName = menuSections.Name; } message = $"{menuSections.Name} Edited"; db.SaveChanges(); return(true); } catch (Exception ex) { message = ex.Message; return(false); } }
public static bool DeleteMenuSection(MenuSections menuSections, out string message) { try { db.MenuSections.Attach(menuSections); db.MenuSections.Remove(menuSections); List <HookahBarDrinks> bar = db.HookahBarDrinks.ToList().Where(p => p.TableName == menuSections.Name).ToList(); foreach (var item in bar) { db.HookahBarDrinks.Attach(item); db.HookahBarDrinks.Remove(item); } db.SaveChanges(); message = $"Deleted {menuSections.Name}"; return(true); } catch (Exception ex) { message = ex.Message; return(false); } }
//////////////////////////////////// public ActionResult DescriptionMenuSection(int id) { MenuSections MenuSections = db.MenuSections.ToList().FirstOrDefault(p => p.Id == id); return(View(MenuSections)); }
public ActionResult CreateMenuSection() { MenuSections menuSections = new MenuSections(); return(View(menuSections)); }
public ActionResult CreateMenuSection(MenuSections menuSection, string message) { ViewBag.Message = message; return(View(menuSection)); }