Esempio n. 1
0
 private async Task CreateSectionContents(IEnumerable <CategoryContent> contents, MenuSection section)
 {
     foreach (var categoryContent in contents)
     {
         var sectionContent = MenuSectionContent.CreateMenuSectionContent(categoryContent.Lang,
                                                                          DynamicCreated, section);
         await _menuManager.AddSectionContentAsync(sectionContent);
     }
 }
Esempio n. 2
0
        public void ValidateMenuSectionContent(MenuSectionContent menuSectionContent)
        {
            if (menuSectionContent.MenuSection == null)
            {
                throw new UserFriendlyException("InvalidMenuSection");
            }
            if (menuSectionContent.Id != 0)
            {
                return;
            }
            var found = _menuSectionContentRepository.FirstOrDefault(a => a.Lang == menuSectionContent.Lang && a.MenuSection.Id == menuSectionContent.MenuSection.Id);

            if (found == null)
            {
                return;
            }
            throw new UserFriendlyException("LangExists");
        }
Esempio n. 3
0
        public async Task <int> AddSectionContentAsync(MenuSectionContent menu)
        {
            //_menuPolicy.ValidateMenuSectionContent(menu);
            var sectionContentFound =
                _menuSectionContentRepository.FirstOrDefault(
                    a => a.Lang == menu.Lang && a.SectionId == menu.MenuSection.Id);

            if (sectionContentFound != null)
            {
                sectionContentFound.Lang        = menu.Lang;
                sectionContentFound.DisplayText = menu.DisplayText;
                sectionContentFound.MenuSection = menu.MenuSection;
                var idFound = await _menuSectionContentRepository.InsertOrUpdateAndGetIdAsync(sectionContentFound);

                return(idFound);
            }
            var id = await _menuSectionContentRepository.InsertOrUpdateAndGetIdAsync(menu);

            return(id);
        }