public ActionResult EditForm(int?id) { var obj = new AdvertiesItem(); var listProductType = advertiesRepository.GetListForTree <object>(); if (id.HasValue) { obj = advertiesRepository.GetItemById <AdvertiesItem>(id.Value); } return(Json(new { data = obj, listType = listProductType }, JsonRequestBehavior.AllowGet)); }
public AdvertiesItem GetItemById(int id) { var key = string.Format("ArticleRepositoryGetItemById{0}", id); var advertise = new AdvertiesItem(); if (!this.TryGetCache <AdvertiesItem>(out advertise, key)) { var result = (from p in web365db.tblAdvertise where p.ID == id && p.IsShow == true && p.IsDeleted == false orderby p.ID descending select p).FirstOrDefault(); if (result != null) { advertise = new AdvertiesItem() { ID = result.ID, DateCreated = result.DateCreated, DateUpdated = result.DateUpdated, Detail = result.Detail, IsShow = result.IsShow, ListPicture = result.tblAdverties_Picture_Map.OrderByDescending(p => p.DisplayOrder).Select(p => new PictureItem() { ID = p.PictureID.Value, Link = p.tblPicture.Link, FileName = p.tblPicture.FileName, Summary = p.tblPicture.Summary }).ToList() }; } this.SetCache(key, advertise, 10); } return(advertise); }