Пример #1
0
        private async Task SaveMenus(MenuGroup middleGroup, string parentName)
        {
            var menus = new List <Menu>();

            foreach (var menuModel in MenuModelItems.Where(c => c.GroupName == parentName && c.ChildName == middleGroup.Name))
            {
                var menu = new Menu(menuModel.Name, menuModel.Vat, menuModel.Price, menuModel.Description, menuModel.ImagePath, middleGroup.Id);
                menus.Add(menu);
            }
            await _dataService.SaveMenuItemsAsync(menus);
        }
Пример #2
0
        private async Task <List <MenuGroup> > SaveAndGetMiddleGroups(MenuGroup topGroup)
        {
            var groups            = new List <MenuGroup>();
            var distictChildNames = MenuModelItems.Where(c => c.GroupName == topGroup.Name).
                                    Select(c => c.ChildName).Distinct();

            foreach (var childName in distictChildNames)
            {
                var group = new MenuGroup(childName, topGroup.Id);
                groups.Add(group);
            }
            return(await _dataService.SaveMenuGroupsAsync(groups, topGroup.Id));
        }