public MenuViewModel GetViewModel(int restaurantId, int?addToOrderId = null) { var vm = new MenuViewModel(); vm.Restaurant = _ctx.Restaurants.Find(restaurantId); vm.AddToOrderId = addToOrderId; vm.Categories = new List <MenuViewModelCategory>(); var items = _ctx.MenuItems.Include(i => i.Prices).Where(i => i.RestaurantId == restaurantId).OrderBy(i => i.MenuCategory.Seq); var categs = items.Select(i => i.MenuCategory).Distinct().OrderBy(c => c.Seq); foreach (MenuCategory categ in categs) { var vcateg = new MenuViewModelCategory(); vcateg.Category = categ; vcateg.Items = new List <MenuViewModelItem>(); foreach (MenuItem item in items.Where(i => i.MenuCategoryId == categ.Id).OrderBy(i => i.Name)) { var vitem = new MenuViewModelItem(); vitem.Item = item; vitem.Prices = item.Prices.OrderBy(p => p.Price).ToList(); vcateg.Items.Add(vitem); } vm.Categories.Add(vcateg); } return(vm); }
private void AddClientrMenuViewModelItems(List <MenuViewModelItem> items) { MenuViewModelItem item = null; item = new MenuViewModelItem() { Title = "Home", ControllerName = "Base", ActionName = "Index" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "New Item Form", ControllerName = "ItemForm", ActionName = "Create" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "Cabinet", ControllerName = "Account", ActionName = ""/////////??????????????? }; TryAddMenuViewModelItem(items, item); }
private void AddDriverMenuViewModelItems(List <MenuViewModelItem> items) { MenuViewModelItem item = null; item = new MenuViewModelItem() { Title = "Home", ControllerName = "Base", ActionName = "Index" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "DriveControl", ControllerName = "ControlDrive", ActionName = "TakeControl" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "Cabinet", ControllerName = "Account", ActionName = ""/////////??????????????? }; TryAddMenuViewModelItem(items, item); }
private void TryAddMenuViewModelItem(List <MenuViewModelItem> items, MenuViewModelItem itemToAdd) { if (items.Any(item => item.Title == itemToAdd.Title || (item.ControllerName == itemToAdd.ControllerName && item.ActionName == itemToAdd.ActionName))) { return; } items.Add(itemToAdd); }
private void AddUserMenuViewModelItems(List <MenuViewModelItem> items) { MenuViewModelItem item = null; item = new MenuViewModelItem() { Title = "Home", ControllerName = "KnowledgeBase", ActionName = "Index" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "Cabinet", ControllerName = "Account", ActionName = ""/////////??????????????? }; TryAddMenuViewModelItem(items, item); }
private void AddTeacherMenuViewModelItems(List <MenuViewModelItem> items) { MenuViewModelItem item = null; item = new MenuViewModelItem() { Title = "Home", ControllerName = "KnowledgeBase", ActionName = "Index" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "New Item Form", ControllerName = "ItemForm", ActionName = "Create" }; TryAddMenuViewModelItem(items, item); }
private void AddAdminMenuViewModelItems(List <MenuViewModelItem> items) { MenuViewModelItem item = null; item = new MenuViewModelItem() { Title = "Головна", ControllerName = "Admin", ActionName = "Index" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "Викладачі", ControllerName = "Admin", ActionName = "ShowTeachers" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "Студенти", ControllerName = "Admin", ActionName = "ShowStudents" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "Предмети", ControllerName = "Admin", ActionName = "ShowSubjects" }; TryAddMenuViewModelItem(items, item); }
private void AddAdminMenuViewModelItems(List <MenuViewModelItem> items) { MenuViewModelItem item = null; item = new MenuViewModelItem() { Title = "Головна", ControllerName = "Admin", ActionName = "Index" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "Водії", ControllerName = "Admin", ActionName = "ShowDriver" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "Клиенти", ControllerName = "Admin", ActionName = "ShowClients" }; TryAddMenuViewModelItem(items, item); item = new MenuViewModelItem() { Title = "Транспортні засоби", ControllerName = "Admin", ActionName = "ShowCars" }; TryAddMenuViewModelItem(items, item); }