Ejemplo n.º 1
0
        public ActionResult Delete(int id, int pageNumber)
        {
            var newsItem = _newsService.GetNewsById(id);

            if (newsItem.CustomerId != _workContext.CurrentCustomer.Id)
            {
                return(RedirectToRoute("HomePage"));
            }
            //celar entity slug
            _urlRecordService.ClearEntitySlug <NewsItem>(newsItem, newsItem.LanguageId);
            _newsService.DeleteNews(newsItem);

            return(RedirectToAction("ManageNews", new { sellerId = _workContext.CurrentCustomer.Id, pagenumber = pageNumber }));
        }
Ejemplo n.º 2
0
        protected void UpdateLocales(Event mt, EventModel model)
        {
            foreach (var localized in model.Locales)
            {
                _localizedEntityService.SaveLocalizedValue(mt,
                                                           x => x.ShortDescription,
                                                           localized.ShortDescription,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(mt,
                                                           x => x.Title,
                                                           localized.Title,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(mt,
                                                           x => x.FullDescription,
                                                           localized.FullDescription,
                                                           localized.LanguageId);
                _urlRecordService.ClearEntitySlug(mt, localized.LanguageId);
                //search engine name
                model.SeName = mt.ValidateSeName(model.SeName, mt.Title, true);
                _urlRecordService.SaveSlug(mt, model.SeName, localized.LanguageId);
            }
        }
Ejemplo n.º 3
0
        protected void UpdateLocales(Category category, CategoryModel model)
        {
            foreach (var localized in model.Locales)
            {
                _localizedEntityService.SaveLocalizedValue(category,
                                                           x => x.Name,
                                                           localized.Name,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(category,
                                                           x => x.Description,
                                                           localized.Description,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(category,
                                                           x => x.MetaKeywords,
                                                           localized.MetaKeywords,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(category,
                                                           x => x.MetaDescription,
                                                           localized.MetaDescription,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(category,
                                                           x => x.MetaTitle,
                                                           localized.MetaTitle,
                                                           localized.LanguageId);


                _urlRecordService.ClearEntitySlug(category, localized.LanguageId);
                //search engine name
                var seName = category.ValidateSeName(localized.SeName, localized.Name, false);
                _urlRecordService.SaveSlug(category, seName, localized.LanguageId);
            }
        }
Ejemplo n.º 4
0
        public ActionResult Edit(NewsItemModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
            {
                return(AccessDeniedView());
            }

            var newsItem = _newsService.GetNewsById(model.Id);

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

            if (ModelState.IsValid)
            {
                bool featured  = newsItem.Featured;
                bool published = newsItem.Published;
                model.StartDate       = newsItem.StartDateUtc;
                model.EndDate         = newsItem.EndDateUtc;
                model.PublishingDate  = newsItem.PublishingDate;
                newsItem              = model.ToEntity(newsItem);
                newsItem.Featured     = featured;
                newsItem.StartDateUtc = model.StartDate;
                newsItem.EndDateUtc   = model.EndDate;

                if (!model.Published)
                {
                    newsItem.Published = false;
                }
                else
                {
                    if (model.PublishingDate == null)
                    {
                        newsItem.PublishingDate = DateTime.UtcNow;
                        if (newsItem.Customer != null && !published)
                        {
                            _newPublicationEmailSender.SendNewsPublicationNotification(newsItem);
                        }
                    }
                    else
                    {
                        if (newsItem.Customer != null && !published)
                        {
                            _newPublicationEmailSender.SendNewsPublicationNotification(newsItem);
                        }
                    }
                    newsItem.Published = true;
                }
                _urlRecordService.ClearEntitySlug(newsItem, newsItem.LanguageId);
                _newsService.UpdateNews(newsItem);
                //search engine name
                var seName = newsItem.ValidateSeName(model.SeName, model.Title, true);
                _urlRecordService.SaveSlug(newsItem, seName, newsItem.LanguageId);
                _genericAttributeService.SaveAttribute <int>(newsItem, SystemCustomerAttributeNames.PictureId, model.PictureId);
                _genericAttributeService.SaveAttribute <int>(newsItem, SystemCustomerAttributeNames.PictureCatalogId, model.CatalogPictureId);
                SuccessNotification(_localizationService.GetResource("Admin.ContentManagement.News.NewsItems.Updated"));
                return(continueEditing ? RedirectToAction("Edit", new { id = newsItem.Id }) : RedirectToAction("List"));
            }
            model.CompanyId = newsItem.Customer == null ? 0 : newsItem.Customer.CompanyInformationId.Value;
            //If we got this far, something failed, redisplay form
            ViewBag.AllLanguages = _languageService.GetAllLanguages(true);
            return(View(model));
        }