public ActionResult UpdateArticleDetails(int articleId, FormCollection form) { int quantity = 1; int galleryStartIndex = -1; string galleryHtml = null; string dynamicThumbUrl = null; var pictureModel = new ArticleDetailsPictureModel(); var m = new ArticlePostModel(); var article = _articleService.GetArticleById(articleId); // quantity required for tier prices string quantityKey = form.AllKeys.FirstOrDefault(k => k.EndsWith("EnteredQuantity")); if (quantityKey.HasValue()) { int.TryParse(form[quantityKey], out quantity); } // get merged model data _helper.PrepareArticleDetailModel(m, article); #region data object object data = new { DynamicThumblUrl = dynamicThumbUrl, GalleryStartIndex = galleryStartIndex, GalleryHtml = galleryHtml }; #endregion return(new JsonResult { Data = data }); }
public ActionResult ArticleCommentAdd(int articleId, ArticlePostModel model, bool captchaValid) { var article = _articleService.GetArticleById(articleId); if (article == null || !article.AllowComments) { return(HttpNotFound()); } if (_workContext.CurrentUser.IsGuest() && !_catalogSettings.AllowNotRegisteredUsersToLeaveComments) { ModelState.AddModelError("", _localizationService.GetResource("Article.Comments.OnlyRegisteredUsersLeaveComments")); } //validate CAPTCHA if (_captchaSettings.Enabled && _captchaSettings.ShowOnArticleCommentPage && !captchaValid) { ModelState.AddModelError("", _localizationService.GetResource("Common.WrongCaptcha")); } if (ModelState.IsValid) { var comment = new ArticleComment() { ArticleId = article.Id, AddTime = DateTime.Now, UserId = _workContext.CurrentUser.Id, IpAddress = _webHelper.GetCurrentIpAddress(), CommentText = model.AddNewComment.CommentText, CommentTitle = model.AddNewComment.CommentTitle, IsApproved = true }; comment.AddEntitySysParam(true, true); _userContentService.InsertUserContent(comment); //update totals _articleService.UpdateCommentTotals(article); //notify a site owner //if (_articleSettings.NotifyAboutNewArticleComments) // _workflowMessageService.SendArticleCommentNotificationMessage(comment, _localizationSettings.DefaultAdminLanguageId); //activity log _userActivityService.InsertActivity("PublicSite.AddArticleComment", _localizationService.GetResource("ActivityLog.PublicSite.AddArticleComment")); //The text boxes should be cleared after a comment has been posted //That' why we reload the page TempData["sm.article.addcomment.result"] = _localizationService.GetResource("Article.Comments.SuccessfullyAdded"); return(RedirectToRoute("Article", new { SeName = article.GetSeName() })); // codehint: sm-delete //return RedirectToRoute("ArticlePost", new { SeName = article.GetSeName(article.LanguageId, ensureTwoPublishedLanguages: false) }); } //If we got this far, something failed, redisplay form _helper.PrepareArticleDetailModel(model, article, true); return(View(model)); }
public ActionResult PublicInfo(string widgetZone, object model) { //if (LicenseChecker.CheckState("SmartSite.CustomBanner", null) == null) //{ // return new EmptyResult(); //} int pictureId = 0; if (model != null) { int pageId = 0; string entity = ""; if (model.GetType() == typeof(ArticlePostModel)) { ArticlePostModel articleModel = (ArticlePostModel)model; pageId = articleModel.Id; entity = "article"; } else { if (model.GetType() == typeof(ArticleCategoryModel)) { ArticleCategoryModel categoryModel = (ArticleCategoryModel)model; pageId = categoryModel.Id; entity = "category"; } else { if (model.GetType() == typeof(TopicModel)) { TopicModel topicModel = (TopicModel)model; pageId = topicModel.Id; entity = "topic"; } } } CustomBannerRecord bannerRecord = this._customBannerService.GetCustomBannerRecord(pageId, entity); if (bannerRecord != null) { pictureId = bannerRecord.PictureId; } } if (pictureId != 0) { CustomBannerSettings customBannerSettings = this._settingService.LoadSetting <CustomBannerSettings>(this._siteContext.CurrentSite.Id); Picture pic = this._pictureService.GetPictureById(pictureId); return(base.View(new PublicInfoModel { PicturePath = this._pictureService.GetPictureUrl(pic, 0, true, null), MaxBannerHeight = customBannerSettings.MaxBannerHeight, StretchPicture = customBannerSettings.StretchPicture, ShowBorderBottom = customBannerSettings.ShowBorderBottom, ShowBorderTop = customBannerSettings.ShowBorderTop, BorderTopColor = customBannerSettings.BorderTopColor, BorderBottomColor = customBannerSettings.BorderBottomColor })); } return(base.Content("")); }