コード例 #1
0
ファイル: MenuService.cs プロジェクト: periface/SapTam
 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);
     }
 }
コード例 #2
0
ファイル: MenuPolicy.cs プロジェクト: periface/SapTam
        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");
        }
コード例 #3
0
ファイル: MenuManager.cs プロジェクト: periface/SapTam
        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);
        }