コード例 #1
0
        public virtual ActionResult Edit(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageBlog))
            {
                return(AccessDeniedView());
            }

            var blogPost = _blogService.GetBlogPostById(id);

            if (blogPost == null)
            {
                //No blog post found with the specified id
                return(RedirectToAction("List"));
            }

            #region Extensions by QuanNH

            if (!_storeMappingService.TableEdit(blogPost.Id, "BlogPost"))
            {
                return(RedirectToAction("List"));
            }

            #endregion

            var model = blogPost.ToModel();
            model.StartDate = blogPost.StartDateUtc;
            model.EndDate   = blogPost.EndDateUtc;
            //languages
            PrepareLanguagesModel(model);
            //Store
            PrepareStoresMappingModel(model, blogPost, false);
            return(View(model));
        }
コード例 #2
0
        public virtual ActionResult Edit(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
            {
                return(AccessDeniedView());
            }

            var newsItem = _newsService.GetNewsById(id);

            if (newsItem == null)
            {
                //No news item found with the specified id
                return(RedirectToAction("List"));
            }

            #region Extensions by QuanNH

            if (!_storeMappingService.TableEdit(id, "NewsItem"))
            {
                return(RedirectToAction("List"));
            }

            #endregion

            var model = newsItem.ToModel();
            model.StartDate = newsItem.StartDateUtc;
            model.EndDate   = newsItem.EndDateUtc;
            //languages
            PrepareLanguagesModel(model);
            //Store
            PrepareStoresMappingModel(model, newsItem, false);
            return(View(model));
        }
コード例 #3
0
        public virtual ActionResult Edit(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories))
            {
                return(AccessDeniedView());
            }

            var category = _categoryService.GetCategoryById(id);

            if (category == null || category.Deleted)
            {
                //No category found with the specified id
                return(RedirectToAction("List"));
            }

            #region Extensions by QuanNH

            if (!_storeMappingService.TableEdit(category.Id, "Category"))
            {
                return(RedirectToAction("List"));
            }

            #endregion

            var model = category.ToModel();
            //locales
            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.Name            = category.GetLocalized(x => x.Name, languageId, false, false);
                locale.Description     = category.GetLocalized(x => x.Description, languageId, false, false);
                locale.MetaKeywords    = category.GetLocalized(x => x.MetaKeywords, languageId, false, false);
                locale.MetaDescription = category.GetLocalized(x => x.MetaDescription, languageId, false, false);
                locale.MetaTitle       = category.GetLocalized(x => x.MetaTitle, languageId, false, false);
                locale.SeName          = category.GetSeName(languageId, false, false);
            });
            //templates
            PrepareTemplatesModel(model);
            //categories
            PrepareAllCategoriesModel(model);
            //discounts
            PrepareDiscountModel(model, category, false);
            //ACL
            PrepareAclModel(model, category, false);
            //Stores
            PrepareStoresMappingModel(model, category, false);

            return(View(model));
        }
コード例 #4
0
        public virtual ActionResult Edit(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMessageTemplates))
            {
                return(AccessDeniedView());
            }

            var messageTemplate = _messageTemplateService.GetMessageTemplateById(id);

            if (messageTemplate == null)
            {
                //No message template found with the specified id
                return(RedirectToAction("List"));
            }

            #region Extensions by QuanNH

            if (!_storeMappingService.TableEdit(messageTemplate.Id, "MessageTemplate"))
            {
                return(RedirectToAction("List"));
            }

            #endregion

            var model = messageTemplate.ToModel();
            model.SendImmediately     = !model.DelayBeforeSend.HasValue;
            model.HasAttachedDownload = model.AttachedDownloadId > 0;
            var allowedTokens = string.Join(", ", _messageTokenProvider.GetListOfAllowedTokens(messageTemplate.GetTokenGroups()));
            model.AllowedTokens = string.Format("{0}{1}{1}{2}{1}", allowedTokens, Environment.NewLine,
                                                _localizationService.GetResource("Admin.ContentManagement.MessageTemplates.Tokens.ConditionalStatement"));
            //available email accounts
            foreach (var ea in _emailAccountService.GetAllEmailAccounts())
            {
                model.AvailableEmailAccounts.Add(new SelectListItem {
                    Text = ea.DisplayName, Value = ea.Id.ToString()
                });
            }
            //Store
            PrepareStoresMappingModel(model, messageTemplate, false);
            //locales
            AddLocales(_languageService, model.Locales, (locale, languageId) =>
            {
                locale.BccEmailAddresses = messageTemplate.GetLocalized(x => x.BccEmailAddresses, languageId, false, false);
                locale.Subject           = messageTemplate.GetLocalized(x => x.Subject, languageId, false, false);
                locale.Body = messageTemplate.GetLocalized(x => x.Body, languageId, false, false);

                locale.EmailAccountId = messageTemplate.GetLocalized(x => x.EmailAccountId, languageId, false, false);
                //available email accounts (we add "Standard" value for localizable field)
                locale.AvailableEmailAccounts.Add(new SelectListItem
                {
                    Text  = _localizationService.GetResource("Admin.ContentManagement.MessageTemplates.Fields.EmailAccount.Standard"),
                    Value = "0"
                });
                foreach (var ea in _emailAccountService.GetAllEmailAccounts())
                {
                    locale.AvailableEmailAccounts.Add(new SelectListItem
                    {
                        Text     = ea.DisplayName,
                        Value    = ea.Id.ToString(),
                        Selected = ea.Id == locale.EmailAccountId
                    });
                }
            });

            return(View(model));
        }