示例#1
0
        public IActionResult Create(PageViewModel model)
        {
            var translateClient = new GoogleTranslateClient(_googleTranslateConfig);

            var page = new Page
            {
                StringKey = model.StringKey,
                Name      = new LocalizationSet
                {
                    Localizations = new List <Localization>
                    {
                        Heplers.Localization(translateClient.TranslateToRussian(model.Name), Culture.RuCode),
                        Heplers.Localization(translateClient.TranslateToEnglish(model.Name), Culture.EnCode),
                        Heplers.Localization(translateClient.TranslateToKorean(model.Name), Culture.KoCode)
                    }
                },
                Content = new LocalizationSet
                {
                    Localizations = new List <Localization>
                    {
                        Heplers.Localization(translateClient.TranslateToRussian(model.Content), Culture.RuCode),
                        Heplers.Localization(translateClient.TranslateToEnglish(model.Content), Culture.EnCode),
                        Heplers.Localization(translateClient.TranslateToKorean(model.Content), Culture.KoCode)
                    }
                },
                MetaDescription = new LocalizationSet
                {
                    Localizations = new List <Localization>
                    {
                        Heplers.Localization(translateClient.TranslateToRussian(model.MetaDescription), Culture.RuCode),
                        Heplers.Localization(translateClient.TranslateToEnglish(model.MetaDescription), Culture.EnCode),
                        Heplers.Localization(translateClient.TranslateToKorean(model.MetaDescription), Culture.KoCode)
                    }
                },
                MetaTitle = new LocalizationSet
                {
                    Localizations = new List <Localization>
                    {
                        Heplers.Localization(translateClient.TranslateToRussian(model.MetaTitle), Culture.RuCode),
                        Heplers.Localization(translateClient.TranslateToEnglish(model.MetaTitle), Culture.EnCode),
                        Heplers.Localization(translateClient.TranslateToKorean(model.MetaTitle), Culture.KoCode)
                    }
                },
                MetaKeywords = new LocalizationSet
                {
                    Localizations = new List <Localization>
                    {
                        Heplers.Localization(translateClient.TranslateToRussian(model.MetaKeywords), Culture.RuCode),
                        Heplers.Localization(translateClient.TranslateToEnglish(model.MetaKeywords), Culture.EnCode),
                        Heplers.Localization(translateClient.TranslateToKorean(model.MetaKeywords), Culture.KoCode)
                    }
                }
            };

            _localizedPageService.AddPage(page);

            return(RedirectToAction("Index"));
        }
示例#2
0
        public IActionResult EditMenuItem(MenuItemViewModel model)
        {
            var translateClient = new GoogleTranslateClient(_googleTranslateConfig);
            var menuItem        = new MenuItem
            {
                Name = new LocalizationSet
                {
                    Localizations = new List <Localization>
                    {
                        Heplers.Localization(translateClient.TranslateToRussian(model.Name), Culture.RuCode),
                        Heplers.Localization(translateClient.TranslateToEnglish(model.Name), Culture.EnCode),
                        Heplers.Localization(translateClient.TranslateToKorean(model.Name), Culture.KoCode)
                    }
                },
                Id         = model.Id,
                Order      = model.Order,
                MenuId     = model.MenuId,
                CustomUrl  = model.CustomUrl,
                Action     = model.Action,
                Controller = model.Controller,
                IsHidden   = model.IsHidden,
                PageId     = model.PageId
            };

            _menuItemService.UpdateMenuItem(menuItem);

            return(RedirectToAction("MenuItems", new { Id = model.MenuId }));
        }
示例#3
0
        public IActionResult EditMenu(MenuViewModel model)
        {
            var translateClient = new GoogleTranslateClient(_googleTranslateConfig);
            var menu            = new Menu
            {
                Name = new LocalizationSet
                {
                    Localizations = new List <Localization>
                    {
                        Heplers.Localization(translateClient.TranslateToRussian(model.Name), Culture.RuCode),
                        Heplers.Localization(translateClient.TranslateToEnglish(model.Name), Culture.EnCode),
                        Heplers.Localization(translateClient.TranslateToKorean(model.Name), Culture.KoCode)
                    }
                },
                Id = model.Id
            };

            _menuItemService.UpdateMenu(menu);

            return(RedirectToAction("Menus"));
        }