/// <summary> /// Prepare the news item model /// </summary> /// <param name="model">News item model</param> /// <param name="newsItem">News item</param> /// <param name="prepareComments">Whether to prepare news comment models</param> /// <returns>News item model</returns> public virtual NewsItemModel PrepareNewsItemModel(NewsItemModel model, NewsItem newsItem, bool prepareComments) { if (model == null) { return(null); } if (newsItem == null) { return(null); } var category = _categoryService.GetNewsItemCategoriesByCategorysId(newsItem.Id); model.Id = newsItem.Id; model.MetaTitle = newsItem.MetaTitle; model.MetaDescription = newsItem.MetaDescription; model.MetaKeywords = newsItem.MetaKeywords; model.SeName = FriendlyUrlHelper.GetFriendlyTitle(_urlRecordService.GetSeName(newsItem), true); model.Title = newsItem.Title; model.EndDateUtc = newsItem.EndDateUtc; model.Short = newsItem.Short; model.Full = newsItem.Full; model.AllowComments = newsItem.AllowComments; model.CreatedOn = newsItem.StartDateUtc ?? newsItem.CreatedOnUtc; model.PictureUrl = _pictureService.GetPictureUrl(newsItem.PictureId); model.VideoId = newsItem.VideoId; model.PictureModels = PreParePictureListModel(newsItem.Id); model.Category = category; model.CategorySeName = _urlRecordService.GetSeName(category); model.CategoryName = _categoryService.GetNewsItemCategoriesByCategorysId(newsItem.Id).Name; if (newsItem.CustomerId > 0) { model.CustomerName = _customerService.GetCustomerById(newsItem.CustomerId).Name; model.AvatarUrl = _pictureService.GetPictureUrl( Convert.ToInt32(_customerService.GetCustomerById(newsItem.CustomerId).Zip), 120, defaultPictureType: PictureType.Avatar); } //number of news comments int storeId = _newsSettings.ShowNewsCommentsPerStore ? _storeContext.CurrentStore.Id : 0; model.NumberOfComments = _newsService.GetNewsCommentsCount(newsItem, storeId, true); model.NumberOfRead = _newsCounterService.GetByListCounter(newsItem.Id, "NewsItem", null).Sum(x => x.TotalVisitor); model.VideoGalleryModel = _videoFactory.PrepareVideoGalleryModel(model.VideoId); if (prepareComments) { var newsComments = newsItem.NewsComments.Where(comment => comment.IsApproved); foreach (NewsComment nc in newsComments.OrderBy(comment => comment.CreatedOnUtc)) { NewsCommentModel commentModel = PrepareNewsCommentModel(nc); model.Comments.Add(commentModel); } } return(model); }
public ActionResult Comments(int?filterByNewsItemId, GridCommand command) { var gridModel = new GridModel <NewsCommentModel>(); if (_permissionService.Authorize(StandardPermissionProvider.ManageNews)) { IList <NewsComment> comments; if (filterByNewsItemId.HasValue) { //filter comments by news item var newsItem = _newsService.GetNewsById(filterByNewsItemId.Value); comments = newsItem.NewsComments.OrderBy(bc => bc.CreatedOnUtc).ToList(); } else { //load all news comments comments = _customerContentService.GetAllCustomerContent <NewsComment>(0, null); } gridModel.Data = comments.PagedForCommand(command).Select(newsComment => { var commentModel = new NewsCommentModel(); var customer = _customerService.GetCustomerById(newsComment.CustomerId); commentModel.Id = newsComment.Id; commentModel.NewsItemId = newsComment.NewsItemId; commentModel.NewsItemTitle = newsComment.NewsItem.Title; commentModel.CustomerId = newsComment.CustomerId; commentModel.IpAddress = newsComment.IpAddress; commentModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc); commentModel.CommentTitle = newsComment.CommentTitle; commentModel.CommentText = Core.Html.HtmlUtils.FormatText(newsComment.CommentText, false, true, false, false, false, false); if (customer == null) { commentModel.CustomerName = "".NaIfEmpty(); } else { commentModel.CustomerName = customer.GetFullName(); } return(commentModel); }); gridModel.Total = comments.Count; } else { gridModel.Data = Enumerable.Empty <NewsCommentModel>(); NotifyAccessDenied(); } return(new JsonResult { Data = gridModel }); }
/// <summary> /// Prepare paged news comment list model /// </summary> /// <param name="searchModel">News comment search model</param> /// <param name="newsItem">News item; pass null to prepare comment models for all news items</param> /// <returns>News comment list model</returns> public virtual NewsCommentListModel PrepareNewsCommentListModel(NewsCommentSearchModel searchModel, NewsItem newsItem) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get parameters to filter comments var createdOnFromValue = searchModel.CreatedOnFrom == null ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(searchModel.CreatedOnFrom.Value, _dateTimeHelper.CurrentTimeZone); var createdOnToValue = searchModel.CreatedOnTo == null ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(searchModel.CreatedOnTo.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); var isApprovedOnly = searchModel.SearchApprovedId == 0 ? null : searchModel.SearchApprovedId == 1 ? true : (bool?)false; //get comments var comments = _newsService.GetAllComments(newsItemId: newsItem?.Id, approved: isApprovedOnly, fromUtc: createdOnFromValue, toUtc: createdOnToValue, commentText: searchModel.SearchText); //prepare store names (to avoid loading for each comment) var storeNames = _storeService.GetAllStores().ToDictionary(store => store.Id, store => store.Name); //prepare list model var model = new NewsCommentListModel { Data = comments.PaginationByRequestModel(searchModel).Select(newsComment => { //fill in model values from the entity var commentModel = new NewsCommentModel { Id = newsComment.Id, NewsItemId = newsComment.NewsItemId, NewsItemTitle = newsComment.NewsItem.Title, CustomerId = newsComment.CustomerId, IsApproved = newsComment.IsApproved, StoreId = newsComment.StoreId, CommentTitle = newsComment.CommentTitle }; //convert dates to the user time commentModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc); //fill in additional values (not existing in the entity) commentModel.CustomerInfo = newsComment.Customer.IsRegistered() ? newsComment.Customer.Email : _localizationService.GetResource("Admin.Customers.Guest"); commentModel.CommentText = HtmlHelper.FormatText(newsComment.CommentText, false, true, false, false, false, false); commentModel.StoreName = storeNames.ContainsKey(newsComment.StoreId) ? storeNames[newsComment.StoreId] : "Deleted"; return(commentModel); }), Total = comments.Count }; return(model); }
protected void PrepareNewsItemModel(NewsItemModel model, NewsItem newsItem, bool prepareComments) { if (newsItem == null) { throw new ArgumentNullException("newsItem"); } if (model == null) { throw new ArgumentNullException("model"); } model.Id = newsItem.Id; model.MetaTitle = newsItem.MetaTitle; model.MetaDescription = newsItem.MetaDescription; model.MetaKeywords = newsItem.MetaKeywords; model.SeName = newsItem.GetSeName(newsItem.LanguageId, ensureTwoPublishedLanguages: false); model.Title = newsItem.Title; model.Short = newsItem.Short; model.Full = newsItem.Full; model.AllowComments = newsItem.AllowComments; model.AvatarPictureSize = _mediaSettings.AvatarPictureSize; model.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.CreatedOnUtc, DateTimeKind.Utc); model.NumberOfComments = newsItem.ApprovedCommentCount; model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnNewsCommentPage; model.AllowCustomersToUploadAvatars = _customerSettings.AllowCustomersToUploadAvatars; if (prepareComments) { var newsComments = newsItem.NewsComments.Where(n => n.IsApproved).OrderBy(pr => pr.CreatedOnUtc); foreach (var nc in newsComments) { var commentModel = new NewsCommentModel() { Id = nc.Id, CustomerId = nc.CustomerId, CustomerName = nc.Customer.FormatUserName(), CommentTitle = nc.CommentTitle, CommentText = nc.CommentText, CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc), AllowViewingProfiles = _customerSettings.AllowViewingProfiles && nc.Customer != null && !nc.Customer.IsGuest(), }; if (_customerSettings.AllowCustomersToUploadAvatars) { var customer = nc.Customer; string avatarUrl = _pictureService.GetPictureUrl(customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId), _mediaSettings.AvatarPictureSize, false); if (String.IsNullOrEmpty(avatarUrl) && _customerSettings.DefaultAvatarEnabled) { avatarUrl = _pictureService.GetDefaultPictureUrl(_mediaSettings.AvatarPictureSize, PictureType.Avatar); } commentModel.CustomerAvatarUrl = avatarUrl; } model.Comments.Add(commentModel); } } }
public void PostComment(AccessToken token, int id, string content) { try { var url = string.Format(ApiUtils.NewsCommentAdd, id.ToString()); var param = new List <OkHttpUtils.Param>() { new OkHttpUtils.Param("ParentId", "0"), new OkHttpUtils.Param("Content", content), }; OkHttpUtils.Instance(token).Post(url, param, async(call, response) => { var code = response.Code(); var body = await response.Body().StringAsync(); if (code == (int)System.Net.HttpStatusCode.Created) { var user = await SQLiteUtils.Instance().QueryUser(); NewsCommentModel news = new NewsCommentModel(); news.UserName = user.DisplayName; news.FaceUrl = user.Face; news.CommentContent = content; news.DateAdded = DateTime.Now; news.Floor = 0; news.CommentID = Convert.ToInt32(body); news.AgreeCount = 0; news.AntiCount = 0; news.ContentID = 0; news.UserGuid = user.UserId; commentView.PostCommentSuccess(news); } else { try { var error = JsonConvert.DeserializeObject <ErrorMessage>(body); commentView.PostCommentFail(error.Message); } catch (Exception e) { commentView.PostCommentFail(e.Message); } } }, (call, ex) => { commentView.PostCommentFail(ex.Message); }); } catch (Exception e) { commentView.PostCommentFail(e.Message); } }
public virtual void PrepareNewsItemModel(NewsItemModel model, NewsItem newsItem, bool prepareComments) { if (newsItem == null) { throw new ArgumentNullException("newsItem"); } if (model == null) { throw new ArgumentNullException("model"); } model.Id = newsItem.Id; model.MetaTitle = newsItem.GetLocalized(x => x.MetaTitle); model.MetaDescription = newsItem.GetLocalized(x => x.MetaDescription); model.MetaKeywords = newsItem.GetLocalized(x => x.MetaKeywords); model.SeName = newsItem.GetSeName(); model.Title = newsItem.GetLocalized(x => x.Title); model.Short = newsItem.GetLocalized(x => x.Short); model.Full = newsItem.GetLocalized(x => x.Full); model.AllowComments = newsItem.AllowComments; model.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.StartDateUtc ?? newsItem.CreatedOnUtc, DateTimeKind.Utc); model.NumberOfComments = newsItem.CommentCount; model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnNewsCommentPage; if (prepareComments) { var newsComments = newsItem.NewsComments.OrderBy(pr => pr.CreatedOnUtc); foreach (var nc in newsComments) { var customer = EngineContextExperimental.Current.Resolve <ICustomerService>().GetCustomerById(nc.CustomerId); var commentModel = new NewsCommentModel { Id = nc.Id, CustomerId = nc.CustomerId, CustomerName = customer.FormatUserName(), CommentTitle = nc.CommentTitle, CommentText = nc.CommentText, CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc), AllowViewingProfiles = _customerSettings.AllowViewingProfiles && customer != null && !customer.IsGuest(), }; if (_customerSettings.AllowCustomersToUploadAvatars) { commentModel.CustomerAvatarUrl = _pictureService.GetPictureUrl( customer.GetAttribute <string>(SystemCustomerAttributeNames.AvatarPictureId), false, _mediaSettings.AvatarPictureSize, _customerSettings.DefaultAvatarEnabled, defaultPictureType: PictureType.Avatar); } model.Comments.Add(commentModel); } } }
/// <summary> /// Prepare paged news comment list model /// </summary> /// <param name="searchModel">News comment search model</param> /// <param name="newsItemId">News item Id; pass null to prepare comment models for all news items</param> /// <returns>News comment list model</returns> public virtual NewsCommentListModel PrepareNewsCommentListModel(NewsCommentSearchModel searchModel, int?newsItemId) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get parameters to filter comments DateTime?createdOnFromValue = searchModel.CreatedOnFrom == null ? null : (DateTime?)searchModel.CreatedOnFrom.Value; DateTime?createdOnToValue = searchModel.CreatedOnTo == null ? null : (DateTime?)searchModel.CreatedOnTo.Value.AddDays(1); bool?isApprovedOnly = searchModel.SearchApprovedId == 0 ? null : searchModel.SearchApprovedId == 1 ? true : (bool?)false; //get comments var comments = _newsService.GetAllComments(newsItemId: newsItemId, approved: isApprovedOnly, fromUtc: createdOnFromValue, toUtc: createdOnToValue, commentText: searchModel.SearchText); //prepare list model NewsCommentListModel model = new NewsCommentListModel { Data = comments.PaginationByRequestModel(searchModel).Select(newsComment => { //fill in model values from the entity NewsCommentModel commentModel = new NewsCommentModel { Id = newsComment.Id, NewsItemId = newsComment.NewsItemId, CustomerId = newsComment.CustomerId == 0 ? 5 : newsComment.CustomerId, IsApproved = newsComment.IsApproved, CommentTitle = newsComment.CommentTitle, CreatedOn = newsComment.CreatedOnUtc, }; if (newsComment.NewsItemId != 0) { commentModel.NewsItemTitle = _newsService.GetNewsById(newsComment.NewsItemId).Title; } commentModel.CustomerInfo = _customerService.GetCustomerById(newsComment.Id).Email; commentModel.CommentText = HtmlHelper.FormatText(newsComment.CommentText, false, true, false, false, false, false); return(commentModel); }).ToList(), Total = comments.Count }; return(model); }
public ActionResult Comments(int?filterByNewsItemId, GridCommand command) { var gridModel = new GridModel <NewsCommentModel>(); IList <NewsComment> comments; if (filterByNewsItemId.HasValue) { //filter comments by news item var newsItem = _newsService.GetNewsById(filterByNewsItemId.Value); comments = newsItem.NewsComments.OrderBy(bc => bc.CreatedOnUtc).ToList(); } else { //load all news comments comments = _customerContentService.GetAllCustomerContent <NewsComment>(0, null); } gridModel.Data = comments.PagedForCommand(command).Select(newsComment => { var commentModel = new NewsCommentModel(); var customer = _customerService.GetCustomerById(newsComment.CustomerId); commentModel.Id = newsComment.Id; commentModel.NewsItemId = newsComment.NewsItemId; commentModel.NewsItemTitle = newsComment.NewsItem.Title; commentModel.CustomerId = newsComment.CustomerId; commentModel.IpAddress = newsComment.IpAddress; commentModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc); commentModel.CommentTitle = newsComment.CommentTitle; commentModel.CommentText = HtmlUtils.ConvertPlainTextToHtml(newsComment.CommentText.HtmlEncode()); if (customer == null) { commentModel.CustomerName = "".NaIfEmpty(); } else { commentModel.CustomerName = customer.GetFullName(); } return(commentModel); }); gridModel.Total = comments.Count; return(new JsonResult { Data = gridModel }); }
public ActionResult SaveNews() { NewsCommentModel e = new NewsCommentModel(); e = ObjectUtil.Eval(e, Request.Params, "", ""); if (string.IsNullOrEmpty(e.id)) { e.id = e.createPk().ToString(); } JsResultObject result = BaseZdBiz.SaveOrUpdate(e, "新闻评论"); return(JsonText(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Comments(int?filterByNewsItemId, GridCommand command) { IPagedList <NewsComment> comments; if (filterByNewsItemId.HasValue) { // Filter comments by news item. var query = _customerContentService.GetAllCustomerContent <NewsComment>(0, null).SourceQuery; query = query.Where(x => x.NewsItemId == filterByNewsItemId.Value); comments = new PagedList <NewsComment>(query, command.Page - 1, command.PageSize); } else { // Load all news comments. comments = _customerContentService.GetAllCustomerContent <NewsComment>(0, null, null, null, command.Page - 1, command.PageSize); } var customerIds = comments.Select(x => x.CustomerId).Distinct().ToArray(); var customers = _customerService.GetCustomersByIds(customerIds).ToDictionarySafe(x => x.Id); var model = new GridModel <NewsCommentModel> { Total = comments.TotalCount }; model.Data = comments.Select(newsComment => { customers.TryGetValue(newsComment.CustomerId, out var customer); var commentModel = new NewsCommentModel { Id = newsComment.Id, NewsItemId = newsComment.NewsItemId, NewsItemTitle = newsComment.NewsItem.GetLocalized(x => x.Title), CustomerId = newsComment.CustomerId, IpAddress = newsComment.IpAddress, CreatedOn = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc), CommentTitle = newsComment.CommentTitle, CommentText = HtmlUtils.ConvertPlainTextToHtml(newsComment.CommentText.HtmlEncode()), CustomerName = customer.GetDisplayName(T) }; return(commentModel); }); return(new JsonResult { Data = model }); }
public virtual IActionResult Comments(int?filterByNewsItemId, DataSourceRequest command, NewsCommentListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews)) { return(AccessDeniedKendoGridJson()); } var createdOnFromValue = model.CreatedOnFrom == null ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnFrom.Value, _dateTimeHelper.CurrentTimeZone); var createdOnToValue = model.CreatedOnTo == null ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnTo.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); bool?approved = null; if (model.SearchApprovedId > 0) { approved = model.SearchApprovedId == 1; } var comments = _newsService.GetAllComments(0, 0, filterByNewsItemId, approved, createdOnFromValue, createdOnToValue, model.SearchText); var storeNames = _storeService.GetAllStores().ToDictionary(store => store.Id, store => store.Name); var gridModel = new DataSourceResult { Data = comments.PagedForCommand(command).Select(newsComment => { var commentModel = new NewsCommentModel { Id = newsComment.Id, NewsItemId = newsComment.NewsItemId, NewsItemTitle = newsComment.NewsItem.Title, CustomerId = newsComment.CustomerId }; var customer = newsComment.Customer; commentModel.CustomerInfo = customer.IsRegistered() ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest"); commentModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc); commentModel.CommentTitle = newsComment.CommentTitle; commentModel.CommentText = Core.Html.HtmlHelper.FormatText(newsComment.CommentText, false, true, false, false, false, false); commentModel.IsApproved = newsComment.IsApproved; commentModel.StoreId = newsComment.StoreId; commentModel.StoreName = storeNames.ContainsKey(newsComment.StoreId) ? storeNames[newsComment.StoreId] : "Deleted"; return(commentModel); }), Total = comments.Count, }; return(Json(gridModel)); }
public ActionResult Comments(int?filterByNewsItemId, GridCommand command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews)) { return(AccessDeniedView()); } IList <NewsComment> comments; if (filterByNewsItemId.HasValue) { //filter comments by news item var newsItem = _newsService.GetNewsById(filterByNewsItemId.Value); comments = newsItem.NewsComments.OrderBy(bc => bc.CreatedOnUtc).ToList(); } else { //load all news comments comments = _customerContentService.GetAllCustomerContent <NewsComment>(0, null); } var gridModel = new GridModel <NewsCommentModel> { Data = comments.PagedForCommand(command).Select(newsComment => { var commentModel = new NewsCommentModel(); commentModel.Id = newsComment.Id; commentModel.NewsItemId = newsComment.NewsItemId; commentModel.NewsItemTitle = newsComment.NewsItem.Title; commentModel.CustomerId = newsComment.CustomerId; var customer = newsComment.Customer; commentModel.CustomerInfo = customer.IsRegistered() ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest"); commentModel.IpAddress = newsComment.IpAddress; commentModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc); commentModel.CommentTitle = newsComment.CommentTitle; commentModel.CommentText = Core.Html.HtmlHelper.FormatText(newsComment.CommentText, false, true, false, false, false, false); return(commentModel); }), Total = comments.Count, }; return(new JsonResult { Data = gridModel }); }
public virtual IActionResult CommentUpdate(NewsCommentModel model) { //try to get a news comment with the specified id NewsComment comment = _newsService.GetNewsCommentById(model.Id) ?? throw new ArgumentException("No comment found with the specified id"); bool previousIsApproved = comment.IsApproved; comment.IsApproved = model.IsApproved; _newsService.UpdateNews(comment.NewsItem); //activity log _customerActivityService.InsertActivity("EditNewsComment", string.Format("EditNewsComment{0}", comment.Id), comment); return(new NullJsonResult()); }
/// <summary> /// Prepare the news comment model /// </summary> /// <param name="newsComment">News comment</param> /// <returns>News comment model</returns> public virtual NewsCommentModel PrepareNewsCommentModel(NewsComment newsComment) { if (newsComment == null) { throw new ArgumentNullException(nameof(newsComment)); } NewsCommentModel model = new NewsCommentModel { Id = newsComment.Id, CustomerId = newsComment.CustomerId, CustomerName = _customerService.GetCustomerById(newsComment.CustomerId).Name, CommentTitle = newsComment.CommentTitle, CommentText = newsComment.CommentText, CreatedOn = newsComment.CreatedOnUtc, }; return(model); }
private async Task PrepareComments(NewsItem newsItem, NewsItemModel model) { var newsComments = newsItem.NewsComments.OrderBy(pr => pr.CreatedOnUtc); foreach (var nc in newsComments) { var customer = await _customerService.GetCustomerById(nc.CustomerId); var commentModel = new NewsCommentModel { Id = nc.Id, CustomerId = nc.CustomerId, CustomerName = customer.FormatUserName(_customerSettings.CustomerNameFormat), CommentTitle = nc.CommentTitle, CommentText = nc.CommentText, CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc), }; model.Comments.Add(commentModel); } }
public IActionResult Comments(string filterByNewsItemId, DataSourceRequest command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews)) { return(AccessDeniedView()); } IList <NewsComment> comments; if (!String.IsNullOrEmpty(filterByNewsItemId)) { //filter comments by news item var newsItem = _newsService.GetNewsById(filterByNewsItemId); comments = newsItem.NewsComments.OrderBy(bc => bc.CreatedOnUtc).ToList(); } else { //load all news comments comments = _newsService.GetAllComments(""); } var gridModel = new DataSourceResult { Data = comments.PagedForCommand(command).Select(newsComment => { var commentModel = new NewsCommentModel(); commentModel.Id = newsComment.Id; commentModel.NewsItemId = newsComment.NewsItemId; commentModel.NewsItemTitle = _newsService.GetNewsById(newsComment.NewsItemId).Title; commentModel.CustomerId = newsComment.CustomerId; var customer = EngineContext.Current.Resolve <ICustomerService>().GetCustomerById(newsComment.CustomerId); commentModel.CustomerInfo = customer.IsRegistered() ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest"); commentModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc); commentModel.CommentTitle = newsComment.CommentTitle; commentModel.CommentText = Core.Html.HtmlHelper.FormatText(newsComment.CommentText, false, true, false, false, false, false); return(commentModel); }), Total = comments.Count, }; return(Json(gridModel)); }
public ActionResult Comments(int?filterByNewsItemId, DataSourceRequest command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews)) { return(AccessDeniedView()); } IList <NewsComment> comments = filterByNewsItemId.HasValue ? //filter comments by news item _newsService.GetNewsById(filterByNewsItemId.Value).NewsComments.OrderBy(bc => bc.CreatedOnUtc).ToList() : //load all news comments _newsService.GetAllComments(); var storeNames = _storeService.GetAllStores().ToDictionary(store => store.Id, store => store.Name); var gridModel = new DataSourceResult { Data = comments.PagedForCommand(command).Select(newsComment => { var commentModel = new NewsCommentModel(); commentModel.Id = newsComment.Id; commentModel.NewsItemId = newsComment.NewsItemId; commentModel.NewsItemTitle = newsComment.NewsItem.Title; commentModel.CustomerId = newsComment.CustomerId; var customer = newsComment.Customer; commentModel.CustomerInfo = customer.IsRegistered() ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest"); commentModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc); commentModel.CommentTitle = newsComment.CommentTitle; commentModel.CommentText = Core.Html.HtmlHelper.FormatText(newsComment.CommentText, false, true, false, false, false, false); commentModel.IsApproved = newsComment.IsApproved; commentModel.StoreId = newsComment.StoreId; commentModel.StoreName = storeNames.ContainsKey(newsComment.StoreId) ? storeNames[newsComment.StoreId] : "Deleted"; return(commentModel); }), Total = comments.Count, }; return(Json(gridModel)); }
public void PostCommentSuccess(NewsCommentModel comment) { handler.Post(() => { txtContent.Enabled = true; txtContent.Text = ""; proLoading.Visibility = ViewStates.Gone; btnComment.Visibility = ViewStates.Visible; var data = adapter.GetData(); if (data.Count > 0) { comment.Floor = data[data.Count - 1].Floor + 1; } else { comment.Floor = 1; } adapter.AddData(comment); adapter.AddData(comment); Toast.MakeText(this, Resources.GetString(Resource.String.comment_success), ToastLength.Short).Show(); }); }
public ActionResult CommentUpdate(NewsCommentModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews)) { return(AccessDeniedView()); } var comment = _newsService.GetNewsCommentById(model.Id); if (comment == null) { throw new ArgumentException("No comment found with the specified id"); } comment.IsApproved = model.IsApproved; _newsService.UpdateNews(comment.NewsItem); //activity log _customerActivityService.InsertActivity("EditNewsComment", _localizationService.GetResource("ActivityLog.EditNewsComment"), model.Id); return(new NullJsonResult()); }
public virtual async Task <(IEnumerable <NewsCommentModel> newsCommentModels, int totalCount)> PrepareNewsCommentModel(string filterByNewsItemId, int pageIndex, int pageSize) { IList <NewsComment> comments; if (!String.IsNullOrEmpty(filterByNewsItemId)) { //filter comments by news item var newsItem = await _newsService.GetNewsById(filterByNewsItemId); comments = newsItem.NewsComments.OrderBy(bc => bc.CreatedOnUtc).ToList(); } else { //load all news comments comments = await _newsService.GetAllComments(""); } var customerService = _serviceProvider.GetRequiredService <ICustomerService>(); var items = new List <NewsCommentModel>(); foreach (var newsComment in comments.PagedForCommand(pageIndex, pageSize)) { var commentModel = new NewsCommentModel { Id = newsComment.Id, NewsItemId = newsComment.NewsItemId, NewsItemTitle = (await _newsService.GetNewsById(newsComment.NewsItemId))?.Title, CustomerId = newsComment.CustomerId }; var customer = await customerService.GetCustomerById(newsComment.CustomerId); commentModel.CustomerInfo = customer.IsRegistered() ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest"); commentModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc); commentModel.CommentTitle = newsComment.CommentTitle; commentModel.CommentText = Core.Html.HtmlHelper.FormatText(newsComment.CommentText); items.Add(commentModel); } return(items, comments.Count); }
public JsResultObject submitComment(NewsCommentModel comment) { return(new JsResultObject()); }
protected virtual void PrepareNewsItemModel(NewsItemModel model, NewsItem newsItem, bool prepareComments) { if (newsItem == null) { throw new ArgumentNullException("newsItem"); } if (model == null) { throw new ArgumentNullException("model"); } model.Id = newsItem.Id; model.MetaTitle = newsItem.MetaTitle; model.MetaDescription = newsItem.MetaDescription; model.MetaKeywords = newsItem.MetaKeywords; model.SeName = newsItem.GetSeName(newsItem.LanguageId, ensureTwoPublishedLanguages: false); model.Title = newsItem.Title; model.Short = newsItem.Short; model.Full = newsItem.Full; model.AllowComments = newsItem.AllowComments; model.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.CreatedOnUtc, DateTimeKind.Utc); model.NumberOfComments = newsItem.CommentCount; model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnNewsCommentPage; if (prepareComments) { var newsComments = newsItem.NewsComments.OrderBy(pr => pr.CreatedOnUtc); foreach (var nc in newsComments) { var commentModel = new NewsCommentModel { Id = nc.Id, CustomerId = nc.CustomerId, CustomerName = nc.Customer.FormatUserName(), CommentTitle = nc.CommentTitle, CommentText = nc.CommentText, CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc), AllowViewingProfiles = _customerSettings.AllowViewingProfiles && nc.Customer != null && !nc.Customer.IsGuest(), }; if (_customerSettings.AllowCustomersToUploadAvatars) { commentModel.CustomerAvatarUrl = _pictureService.GetPictureUrl( nc.Customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId), _mediaSettings.AvatarPictureSize, _customerSettings.DefaultAvatarEnabled, defaultPictureType: PictureType.Avatar); } model.Comments.Add(commentModel); } } //prepare picture model int pictureSize = _mediaSettings.ProductThumbPictureSize; var newsitemPictureCacheKey = string.Format(ModelCacheEventConsumer.NEWSITEM_PICTURE_MODEL_KEY, newsItem.Id, pictureSize, true, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured(), _storeContext.CurrentStore.Id); model.PictureModel = _cacheManager.Get(newsitemPictureCacheKey, () => { var picture = _pictureService.GetPictureById(newsItem.PictureId); var pictureModel = new PictureModel { FullSizeImageUrl = _pictureService.GetPictureUrl(picture), ImageUrl = _pictureService.GetPictureUrl(picture, pictureSize), Title = newsItem.Title, AlternateText = newsItem.Title }; return(pictureModel); }); }
protected virtual void PrepareNewsItemModel(NewsItemModel model, NewsItem newsItem, bool prepareComments, bool preparePictureModel = true, int?newsThumbPictureSize = null) { if (newsItem == null) { throw new ArgumentNullException("newsItem"); } if (model == null) { throw new ArgumentNullException("model"); } model.Id = newsItem.Id; model.MetaTitle = newsItem.MetaTitle; model.MetaDescription = newsItem.MetaDescription; model.MetaKeywords = newsItem.MetaKeywords; model.SeName = newsItem.GetSeName(newsItem.LanguageId, ensureTwoPublishedLanguages: false); model.Title = newsItem.Title; model.Short = newsItem.Short; model.Full = newsItem.Full; model.AllowComments = newsItem.AllowComments; model.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.CreatedOnUtc, DateTimeKind.Utc); model.NumberOfComments = newsItem.CommentCount; model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnNewsCommentPage; if (preparePictureModel) { #region Prepare news picture //If a size has been set in the view, we use it in priority int pictureSize = newsThumbPictureSize.HasValue ? newsThumbPictureSize.Value : _mediaSettings.NewsThumbPictureSize; //prepare picture model var defaultNewsPictureCacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_DEFAULTPICTURE_MODEL_KEY, newsItem.Id, pictureSize, true, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured(), _storeContext.CurrentStore.Id); model.DefaultPictureModel = _cacheManager.Get(defaultNewsPictureCacheKey, () => { var picture = _pictureService.GetPicturesByNewsId(newsItem.Id, 1).FirstOrDefault(); var pictureModel = new PictureModel { ImageUrl = _pictureService.GetPictureUrl(picture, pictureSize), FullSizeImageUrl = _pictureService.GetPictureUrl(picture), Title = string.Format(_localizationService.GetResource("Media.News.ImageLinkTitleFormat"), model.Title), AlternateText = string.Format(_localizationService.GetResource("Media.News.ImageAlternateTextFormat"), model.Title) }; return(pictureModel); }); #endregion } if (prepareComments) { var newsComments = newsItem.NewsComments.OrderBy(pr => pr.CreatedOnUtc); foreach (var nc in newsComments) { var commentModel = new NewsCommentModel { Id = nc.Id, CustomerId = nc.CustomerId, CustomerName = nc.Customer.FormatUserName(), CommentTitle = nc.CommentTitle, CommentText = nc.CommentText, CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc), AllowViewingProfiles = _customerSettings.AllowViewingProfiles && nc.Customer != null && !nc.Customer.IsGuest(), }; if (_customerSettings.AllowCustomersToUploadAvatars) { commentModel.CustomerAvatarUrl = _pictureService.GetPictureUrl( nc.Customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId), _mediaSettings.AvatarPictureSize, _customerSettings.DefaultAvatarEnabled, defaultPictureType: PictureType.Avatar); } model.Comments.Add(commentModel); } } }
protected void PrepareNewsItemModel(NewsItemModel model, NewsItem newsItem, bool prepareComments) { if (newsItem == null) { throw new ArgumentNullException("newsItem"); } if (model == null) { throw new ArgumentNullException("model"); } switch (newsItem.ExtendedProfileOnly) { case (int)NewsDisplayEnum.Both: { model.MiniSite = _localizationService.GetResource("News.Manage.MiniSite.Location.Both"); break; } case (int)NewsDisplayEnum.Main: { model.MiniSite = _storeInformationSettings.StoreName; break; } case (int)NewsDisplayEnum.MiniSite: { model.MiniSite = _localizationService.GetResource("News.Manage.MiniSite.Location.MiniSite");; break; } } model.ExtendedProfileDisplay = newsItem.ExtendedProfileOnly; model.Language = newsItem.LanguageId; model.Featured = newsItem.Featured; model.Id = newsItem.Id; model.SeName = newsItem.GetSeName(newsItem.LanguageId, ensureTwoPublishedLanguages: false); model.Title = newsItem.Title; model.Short = newsItem.Short; model.Full = newsItem.Full; model.AllowComments = newsItem.AllowComments; model.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.CreatedOnUtc, DateTimeKind.Utc); model.NumberOfComments = newsItem.ApprovedCommentCount; model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnNewsCommentPage; model.CustomerId = newsItem.CustomerId.GetValueOrDefault(); model.PictureId = newsItem.GetAttribute <int>(SystemCustomerAttributeNames.PictureId); model.CatalogPictureId = newsItem.GetAttribute <int>(SystemCustomerAttributeNames.PictureCatalogId); if (model.PictureId != 0) { model.Picture = new PictureModel() { ImageUrl = _pictureService.GetPictureUrl(model.PictureId, showDefaultPicture: false) }; } if (model.CatalogPictureId != 0) { model.CatalogPicture = new PictureModel() { ImageUrl = _pictureService.GetPictureUrl(model.CatalogPictureId, showDefaultPicture: false) }; } model.Published = newsItem.Published; model.PublishingDate = newsItem.PublishingDate; if (newsItem.CustomerId.HasValue) { model.Company = newsItem.Customer.CompanyInformation.GetLocalized(x => x.CompanyName, newsItem.LanguageId); model.CompanySeName = newsItem.Customer.CompanyInformation.GetSeName(newsItem.LanguageId); if (model.Company == null) { model.Company = newsItem.Customer.CompanyInformation.GetLocalized(x => x.CompanyName, _languageService.GetAllLanguages().Where(x => x.LanguageCulture == "de-DE").First().Id); model.CompanySeName = newsItem.Customer.CompanyInformation.GetSeName(_languageService.GetAllLanguages().Where(x => x.LanguageCulture == "de-DE").First().Id); } if (model.Company == null) { model.Company = newsItem.Customer.CompanyInformation.GetLocalized(x => x.CompanyName, _languageService.GetAllLanguages().Where(x => x.LanguageCulture == "es-MX").First().Id); model.CompanySeName = newsItem.Customer.CompanyInformation.GetSeName(_languageService.GetAllLanguages().Where(x => x.LanguageCulture == "es-MX").First().Id); } if (model.Company == null) { model.Company = newsItem.Customer.CompanyInformation.GetLocalized(x => x.CompanyName, _languageService.GetAllLanguages().Where(x => x.LanguageCulture == "en-US").First().Id); model.CompanySeName = newsItem.Customer.CompanyInformation.GetSeName(_languageService.GetAllLanguages().Where(x => x.LanguageCulture == "en-US").First().Id); } if (model.Company == null) { model.Company = newsItem.Customer.CompanyInformation.GetLocalized(x => x.CompanyName, _languageService.GetAllLanguages().Where(x => x.LanguageCulture == "ru-RU").First().Id); model.CompanySeName = newsItem.Customer.CompanyInformation.GetSeName(_languageService.GetAllLanguages().Where(x => x.LanguageCulture == "ru-RU").First().Id); } model.CompanyId = newsItem.Customer.CompanyInformationId.GetValueOrDefault(); } if (prepareComments) { var newsComments = newsItem.NewsComments.Where(n => n.IsApproved).OrderBy(pr => pr.CreatedOnUtc); foreach (var nc in newsComments) { var commentModel = new NewsCommentModel() { Id = nc.Id, CustomerId = nc.CustomerId, CustomerName = nc.Customer.FormatUserName(), CommentTitle = nc.CommentTitle, CommentText = nc.CommentText, CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc), AllowViewingProfiles = _customerSettings.AllowViewingProfiles && nc.Customer != null && !nc.Customer.IsGuest(), }; if (_customerSettings.AllowCustomersToUploadAvatars) { var customer = nc.Customer; string avatarUrl = _pictureService.GetPictureUrl(customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId), _mediaSettings.AvatarPictureSize, false); if (String.IsNullOrEmpty(avatarUrl) && _customerSettings.DefaultAvatarEnabled) { avatarUrl = _pictureService.GetDefaultPictureUrl(_mediaSettings.AvatarPictureSize, PictureType.Avatar); } commentModel.CustomerAvatarUrl = avatarUrl; } model.Comments.Add(commentModel); } } }
public virtual async Task PrepareNewsItemModel(NewsItemModel model, NewsItem newsItem, bool prepareComments) { if (newsItem == null) { throw new ArgumentNullException("newsItem"); } if (model == null) { throw new ArgumentNullException("model"); } model.Id = newsItem.Id; model.MetaTitle = newsItem.GetLocalized(x => x.MetaTitle, _workContext.WorkingLanguage.Id); model.MetaDescription = newsItem.GetLocalized(x => x.MetaDescription, _workContext.WorkingLanguage.Id); model.MetaKeywords = newsItem.GetLocalized(x => x.MetaKeywords, _workContext.WorkingLanguage.Id); model.SeName = newsItem.GetSeName(_workContext.WorkingLanguage.Id); model.Title = newsItem.GetLocalized(x => x.Title, _workContext.WorkingLanguage.Id); model.Short = newsItem.GetLocalized(x => x.Short, _workContext.WorkingLanguage.Id); model.Full = newsItem.GetLocalized(x => x.Full, _workContext.WorkingLanguage.Id); model.AllowComments = newsItem.AllowComments; model.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.StartDateUtc ?? newsItem.CreatedOnUtc, DateTimeKind.Utc); model.NumberOfComments = newsItem.CommentCount; model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnNewsCommentPage; if (prepareComments) { var newsComments = newsItem.NewsComments.OrderBy(pr => pr.CreatedOnUtc); foreach (var nc in newsComments) { var customer = await _serviceProvider.GetRequiredService <ICustomerService>().GetCustomerById(nc.CustomerId); var commentModel = new NewsCommentModel { Id = nc.Id, CustomerId = nc.CustomerId, CustomerName = customer.FormatUserName(_customerSettings.CustomerNameFormat), CommentTitle = nc.CommentTitle, CommentText = nc.CommentText, CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc), AllowViewingProfiles = _customerSettings.AllowViewingProfiles && customer != null && !customer.IsGuest(), }; if (_customerSettings.AllowCustomersToUploadAvatars) { commentModel.CustomerAvatarUrl = await _pictureService.GetPictureUrl( customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.AvatarPictureId), _mediaSettings.AvatarPictureSize, _customerSettings.DefaultAvatarEnabled, defaultPictureType : PictureType.Avatar); } model.Comments.Add(commentModel); } } //prepare picture model if (!string.IsNullOrEmpty(newsItem.PictureId)) { int pictureSize = prepareComments ? _mediaSettings.NewsThumbPictureSize : _mediaSettings.NewsListThumbPictureSize; var categoryPictureCacheKey = string.Format(ModelCacheEventConsumer.NEWS_PICTURE_MODEL_KEY, newsItem.Id, pictureSize, true, _workContext.WorkingLanguage.Id, _webHelper.IsCurrentConnectionSecured(), _storeContext.CurrentStore.Id); model.PictureModel = await _cacheManager.GetAsync(categoryPictureCacheKey, async() => { var picture = await _pictureService.GetPictureById(newsItem.PictureId); var pictureModel = new PictureModel { Id = newsItem.PictureId, FullSizeImageUrl = await _pictureService.GetPictureUrl(picture), ImageUrl = await _pictureService.GetPictureUrl(picture, pictureSize), Title = string.Format(_localizationService.GetResource("Media.News.ImageLinkTitleFormat"), newsItem.Title), AlternateText = string.Format(_localizationService.GetResource("Media.News.ImageAlternateTextFormat"), newsItem.Title) }; return(pictureModel); }); } }
private void PrepareNewsItemDetailModel(NewsItemModel model, NewsItem newsItem, bool prepareComments, bool prepareProductModel = true) { if (newsItem == null) { throw new ArgumentNullException("newsItem"); } if (model == null) { throw new ArgumentNullException("model"); } model.Id = newsItem.Id; model.SeName = newsItem.GetSeName(); model.Title = newsItem.Title; model.Short = newsItem.Short; model.Full = newsItem.Full; model.MetaDescription = newsItem.MetaDescription; model.MetaTitle = newsItem.MetaTitle; model.MetaKeywords = newsItem.MetaKeywords; model.AllowComments = newsItem.AllowComments; model.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsItem.CreatedOnUtc, DateTimeKind.Utc); if (prepareComments) { model.NumberOfComments = newsItem.NewsComments.Count; } model.IsGuest = _workContext.CurrentCustomer.IsGuest(); #region pictures var pictures = _newsService.GetNewsItemPicturesByNewsItemId(newsItem.Id, NewsItemPictureType.Standard); if (pictures.Count > 0) { foreach (var newsItemPicture in pictures) { model.PictureModels.Add(new PictureModel() { ImageUrl = _pictureService.GetPictureUrl(_newsService.GetMediaPictureByNewsItemPictureId(newsItemPicture.PictureId), _mediaSettings.NewsItemDetailPictureSize), FullSizeImageUrl = _pictureService.GetPictureUrl(_newsService.GetMediaPictureByNewsItemPictureId(newsItemPicture.PictureId)), Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Title), AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Title), }); } model.DefaultPictureModel = model.PictureModels.FirstOrDefault(); } else { //no images. set the default one model.DefaultPictureModel = new PictureModel() { ImageUrl = _pictureService.GetDefaultPictureUrl( _mediaSettings.NewsItemDetailPictureSize), FullSizeImageUrl = _pictureService.GetDefaultPictureUrl(), Title = string.Format( _localizationService.GetResource( "Media.Product.ImageLinkTitleFormat"), model.Title), AlternateText = string.Format( _localizationService.GetResource( "Media.Product.ImageAlternateTextFormat"), model.Title), }; } #endregion pictures #region extra contents var extraContents = newsItem.ExtraContents.OrderBy(x => x.DisplayOrder).ToList(); if (extraContents.Count > 0) { foreach (var newItemExtraContent in extraContents) { model.ExtraContentModels.Add(new ExtraContentModel() { FullDescription = newItemExtraContent.FullDescription, Id = newItemExtraContent.Id, DisplayOrder = newItemExtraContent.DisplayOrder, Title = newItemExtraContent.Title }); } } #endregion extra contents #region comments if (prepareComments) { var newsComments = newsItem.NewsComments.Where(pr => pr.IsApproved).OrderBy(pr => pr.CreatedOnUtc); foreach (var nc in newsComments) { var commentModel = new NewsCommentModel() { Id = nc.Id, CustomerId = nc.CustomerId, CustomerName = nc.Customer.FormatUserName(), CommentTitle = nc.CommentTitle, CommentText = nc.CommentText, CreatedOn = _dateTimeHelper.ConvertToUserTime(nc.CreatedOnUtc, DateTimeKind.Utc), AllowViewingProfiles = _customerSettings.AllowViewingProfiles && nc.Customer != null && !nc.Customer.IsGuest(), }; if (_customerSettings.AllowCustomersToUploadAvatars) { var customer = nc.Customer; string avatarUrl = _pictureService.GetPictureUrl( customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId), _mediaSettings.AvatarPictureSize, false); if (String.IsNullOrEmpty(avatarUrl) && _customerSettings.DefaultAvatarEnabled) { avatarUrl = _pictureService.GetDefaultPictureUrl(_mediaSettings.AvatarPictureSize, PictureType.Avatar); } commentModel.CustomerAvatarUrl = avatarUrl; } model.Comments.Add(commentModel); } } #endregion comments #region products if (prepareProductModel) { //ViewBag.NewsItemProductsSummary = _newsService.GetNewsItemProductsSummaryByNewsItemId(newsItem.Id); //CatalogRepository cr = new CatalogRepository(); //var products = cr.ProductsByNewsItem(newsItem.Id); ////var products = _newsService.GetNewsItemProductsByNewsItemId(newsItem.Id); //model.ProductModels = products.Select(x => PrepareProductOverviewModel(x)).ToList(); CatalogRepository cr = new CatalogRepository(); var products = cr.ProductsSummaryByNewsItem(newsItem.Id); foreach (var p in products) { p.PictureUrl = _pictureService.GetPictureUrl(p.PictureId, 222); } ViewBag.Products = products; } #endregion products }