Пример #1
0
        public ActionResult Detail(string key)
        {
            key = key.ToLower();

            ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 190 : 400;
            ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 285 : 600;

            var modelOut = new ContentModel();
            string cacheKey = string.Concat(Lib.BOL.UserContent.Content.Key, key, Utilities.GetCurrentLanguageCode());

            if (HttpRuntime.Cache[cacheKey] == null)
            {
                var model = new Content(key);

                modelOut.ThumbIcon = Utilities.S3ContentPath(model.ContentPhotoThumbURL);

                var otherNews = new Content();

                otherNews.GetPreviousNews(model.ReleaseDate);
                if (otherNews.ContentID > 0)
                {
                    modelOut.PreviousNews = otherNews.ToUnorderdListItem;
                }

                otherNews = new Content();
                otherNews.GetNextNews(model.ReleaseDate);

                if (otherNews.ContentID > 0)
                {
                    modelOut.NextNews = otherNews.ToUnorderdListItem;
                }

                if (!string.IsNullOrWhiteSpace(model.ContentVideoURL2) &&
                    string.IsNullOrWhiteSpace(model.ContentVideoURL))
                {
                    // TODO: parse just the key, it's currently requiring the embed
                    model.ContentVideoURL2 = string.Concat(model.ContentVideoURL2, "?rel=0");
                    modelOut.VideoWidth = "100%";
                }

                modelOut.ContentID = model.ContentID;
                modelOut.ContentKey = model.ContentKey;
                modelOut.ContentPhotoThumbURL = model.ContentPhotoThumbURL;
                modelOut.ContentPhotoURL = model.ContentPhotoURL;
                modelOut.ContentTypeID = model.ContentTypeID;
                modelOut.ContentVideoURL = model.ContentVideoURL;
                modelOut.ContentVideoURL2 = model.ContentVideoURL2;
                modelOut.CurrentStatus = model.CurrentStatus;
                modelOut.Detail = model.Detail;
                modelOut.IsEnabled = model.IsEnabled;
                modelOut.Language = model.Language;
                modelOut.MetaDescription = model.MetaDescription;
                modelOut.MetaKeywords = model.MetaKeywords;
                modelOut.OutboundURL = model.OutboundURL;
                modelOut.ReleaseDate = model.ReleaseDate;
                modelOut.SiteDomainID = model.SiteDomainID;
                modelOut.Title = model.Title;
                modelOut.UrlTo = model.UrlTo;
                modelOut.CreateDate = model.CreateDate;
                modelOut.CreatedByUserID = model.CreatedByUserID;
                modelOut.UpdateDate = model.UpdateDate;
                modelOut.UpdatedByUserID = model.UpdatedByUserID;

                HttpRuntime.Cache.AddObjToCache(modelOut, cacheKey);
            }
            else
            {
                modelOut = (ContentModel) HttpRuntime.Cache[cacheKey];
            }

            return View(modelOut);
        }