コード例 #1
0
        public LayoutContentItem GetItemById(int id)
        {
            var key = string.Format("LayoutContentRepositoryGetItemById{0}", id);

            var product = new LayoutContentItem();

            if (!this.TryGetCache<LayoutContentItem>(out product, key))
            {
                var result = GetById(id);

                product = new LayoutContentItem()
                {
                    ID = result.ID,
                    Name = result.Name,
                    NameAscii = result.NameAscii,
                    SEOTitle = result.SEOTitle,
                    SEODescription = result.SEODescription,
                    SEOKeyword = result.SEOKeyword,
                    DateCreated = result.DateCreated,
                    DateUpdated = result.DateUpdated,
                    PictureID = result.PictureID,
                    Summary = result.Summary,
                    Detail = result.Detail,
                    IsShow = result.IsShow,
                    UrlPicture = result.tblPicture != null ? result.tblPicture.FileName : string.Empty
                };

                this.SetCache(key, product, 10);
            }

            return product;
        }
コード例 #2
0
        public ActionResult EditForm(int? id)
        {
            var obj = new LayoutContentItem();

            if (id.HasValue)
                obj = layoutContentRepository.GetItemById<LayoutContentItem>(id.Value);

            return Json(new
            {
                data = obj
            }, JsonRequestBehavior.AllowGet);
        }