Ejemplo n.º 1
0
        public ActionResult EditForm(int? id)
        {
            var obj = new ArticleTypeItem();

            var listType = articleTypeRepository.GetListForTree<object>();
            var listGroup = articleGroupTypeRepository.GetListForTree<object>();

            if (id.HasValue)
                obj = articleTypeRepository.GetItemById<ArticleTypeItem>(id.Value);

            return Json(new
            {
                data = obj,
                listType = listType,
                listGroup = listGroup
            }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 2
0
        public ArticleTypeItem GetItemByNameAscii(string nameAscii, bool isShow = true, bool isDeleted = false)
        {
            var key = string.Format("ArticleTypeRepositoryGetItemByNameAscii{0}", nameAscii);

            var articleType = new ArticleTypeItem();

            if (!this.TryGetCache<ArticleTypeItem>(out articleType, key))
            {
                articleType = (from p in web365db.tblTypeArticle
                               where p.NameAscii == nameAscii && p.LanguageId == LanguageId && p.IsShow == isShow && p.IsDeleted == isDeleted
                               orderby p.ID descending
                               select new ArticleTypeItem()
                          {
                              ID = p.ID,
                              Parent = p.Parent,
                              Name = p.Name,
                              NameAscii = p.NameAscii,
                              SEOTitle = p.SEOTitle,
                              SEODescription = p.SEODescription,
                              SEOKeyword = p.SEOKeyword,
                              DateCreated = p.DateCreated,
                              DateUpdated = p.DateUpdated,
                              Number = p.Number,
                              PictureID = p.PictureID,
                              Summary = p.Summary,
                              Detail = p.Detail,
                              IsShow = p.IsShow
                          }).FirstOrDefault();

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

            return articleType;
        }
Ejemplo n.º 3
0
        public ArticleTypeItem GetItemById(int id)
        {
            var key = string.Format("ArticleTypeRepositoryGetItemById{0}", id);

            var articleType = new ArticleTypeItem();

            if (!this.TryGetCache<ArticleTypeItem>(out articleType, key))
            {
                var result = (from p in web365db.tblTypeArticle
                              where p.ID == id && p.IsShow == true && p.IsDeleted == false
                              select p).FirstOrDefault();

                articleType = new ArticleTypeItem()
                            {
                                ID = result.ID,
                                Parent = result.Parent,
                                Name = result.Name,
                                NameAscii = result.NameAscii,
                                SEOTitle = result.SEOTitle,
                                SEODescription = result.SEODescription,
                                SEOKeyword = result.SEOKeyword,
                                DateCreated = result.DateCreated,
                                DateUpdated = result.DateUpdated,
                                Number = result.Number,
                                PictureID = result.PictureID,
                                Summary = result.Summary,
                                Detail = result.Detail,
                                IsShow = result.IsShow,
                                ListChildID = result.tblTypeArticle1.Where(t => t.IsShow == true && t.IsDeleted == false).OrderByDescending(t => t.Number).ThenByDescending(t => t.ID).Select(t => t.ID).ToArray()
                            };

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

            return articleType;
        }