public override PartialViewResult Last(byte?mct = null, int amount = 5, int?mid = null)
        {
            var data = (Repo as RepoArticle).GetLast(mct, amount, mid, new[] {
                SxMvcApplication.ModelCoreTypeProvider[nameof(Article)],
                SxMvcApplication.ModelCoreTypeProvider[nameof(News)]
            });

            var          viewModel = new VMMaterial[data.Length];
            SxVMMaterial item      = null;

            for (int i = 0; i < data.Length; i++)
            {
                item = data[i];
                switch (item.ModelCoreType)
                {
                case 1:
                    viewModel[i] = new VMArticle {
                        Title = item.Title, TitleUrl = item.TitleUrl, DateCreate = item.DateCreate, ModelCoreType = item.ModelCoreType
                    };
                    break;

                case 2:
                    viewModel[i] = new VMNews {
                        Title = item.Title, TitleUrl = item.TitleUrl, DateCreate = item.DateCreate, ModelCoreType = item.ModelCoreType
                    };
                    break;
                }
            }

            return(PartialView("_Last", viewModel));
        }
Beispiel #2
0
        public static void ReplaceInfographics(UrlHelper urlHelper, SxVMMaterial model)
        {
            if (string.IsNullOrEmpty(model.Html))
            {
                return;
            }

            var matches = Regex.Matches(model.Html, @"\[ig\]([^\]]+)\[/ig\]", RegexOptions.IgnoreCase);

            Guid pictureId = Guid.Empty;

            foreach (Match match in matches)
            {
                var strValue = match.Groups[1].Value;
                if (!Guid.TryParse(strValue, out pictureId))
                {
                    continue;
                }

                var picture = (model as VMMaterial).Infographics.FirstOrDefault(x => x.PictureId == pictureId);
                if (picture == null)
                {
                    continue;
                }

                var url   = urlHelper.ContentAbsUrl($"/infographics/{strValue.ToLower()}");
                var share = SX.WebCore.HtmlHelpers.SxExtantions.GetShareButtonTemplate(settings: new SX.WebCore.HtmlHelpers.SxExtantions.SxShareSettings {
                    ItemTemplate = b => $"<li data-type=\"{b.Net.Code}\" class=\"goodshare\" data-url=\"{url}\" data-title=\"{picture.Caption}\" data-text=\"{model.Title}\" data-image=\"{urlHelper.ContentAbsUrl(urlHelper.Action("Picture", "Pictures", new { id= picture.PictureId }))}\"><i class=\"{b.Net.LogoCssClass}\" style=\"background-color:{b.Net.Color}\"></i></li>"
                });
                model.Html = model.Html.Replace("[IG]" + strValue + "[/IG]", $"<div class=\"infographic-page-item\"><a href=\"{url}\"><img alt=\"{HttpUtility.HtmlEncode(picture.Caption)}\" src=\"/pictures/picture/{strValue.ToLower()}\" style=\"max-width:100%;\" /></a>{share}</div>");
            }
        }
        public override SxVMMaterial[] GetPopular(int?mct = null, int?mid = null, int amount = 10, DateTime?dateBegin = null, DateTime?dateEnd = null)
        {
            var data     = base.GetPopular(mct, mid, amount, dateBegin, dateEnd);
            var viewData = new SxVMMaterial[data.Length];

            for (var i = 0; i < data.Length; i++)
            {
                viewData[i] = GetFromMaterial(data[i]);
            }

            return(viewData);
        }
 private static VMMaterial GetFromMaterial(SxVMMaterial model)
 {
     return(new VMMaterial
     {
         Id = model.Id,
         DateCreate = model.DateCreate,
         DateOfPublication = model.DateOfPublication,
         ModelCoreType = model.ModelCoreType,
         CategoryId = model.CategoryId,
         Title = model.Title,
         TitleUrl = model.TitleUrl,
         CommentsCount = model.CommentsCount,
         LikeUpCount = model.LikeUpCount,
         LikeDownCount = model.LikeDownCount,
         ViewsCount = model.ViewsCount
     });
 }
        public sealed override PartialViewResult Popular(int?mct = default(int?), int?mid = default(int?), int amount = 4)
        {
            var          mctProvider = MvcApplication.ModelCoreTypeProvider;
            var          data        = Repo.GetPopular(mct, mid, amount);
            var          viewModel   = new VMMaterial[data.Length];
            SxVMMaterial item        = null;

            for (int i = 0; i < data.Length; i++)
            {
                item = data[i];
                if (item.ModelCoreType == 1)
                {
                    viewModel[i] = Mapper.Map <SxVMMaterial, VMArticle>(item);
                }
            }
            return(PartialView("_Popular", viewModel));
        }
Beispiel #6
0
        private static string getSteamColumnTemplate(SxVMMaterial model)
        {
            var template = ((VMNews)model).SteamNewsGid == null ? null : "<button class=\"btn btn-xs btn-primary\"><i class=\"fa fa-steam-square\" area-hidden=\"true\"></i></button>";

            return(template);
        }
Beispiel #7
0
 private void replaceInfographics(SxVMMaterial model)
 {
     BBCodeParserConfig.ReplaceInfographics(Url, model);
 }