public ActionResult Delete(int id) { AjaxResult result = new AjaxResult(); try { LinksClass entity = m_FTISService.GetLinksClassById(id); //檢查底下的Links數量 IDictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("LinksClassId", id.ToString()); int subsCount = m_FTISService.GetLinksCount(conditions); if (subsCount > 0) { return(this.Json(new AjaxResult(AjaxResultStatus.Fail, string.Format("{0}底下尚有網路資源,不可刪除。", entity.Name)))); } m_FTISService.DeleteLinksClass(entity); result.ErrorCode = AjaxResultStatus.Success; result.Message = string.Format("{0}刪除成功", entity.Name); } catch (Exception ex) { result.ErrorCode = AjaxResultStatus.Exception; result.Message = ex.Message; } return(this.Json(result)); }
protected void LoadEntity(LinksClass entity) { if (entity != null) { EntityId = entity.LinksClassId; Name = entity.Name; SortId = entity.SortId; Status = entity.Status; LangId = entity.LangId; } }
private void Save(LinksClass entity) { entity.Name = Name; entity.SortId = SortId; entity.Status = Status; entity.LangId = LangId; if (entity.LinksClassId == 0) { m_FTISService.CreateLinksClass(entity); } else { m_FTISService.UpdateLinksClass(entity); } LoadEntity(entity.LinksClassId); }
public ActionResult SetSort(string entityId, string sortValue) { AjaxResult result = new AjaxResult(AjaxResultStatus.Success, string.Empty); StringBuilder sbMsg = new StringBuilder(); try { LinksClass entity = m_FTISService.GetLinksClassById(Convert.ToInt32(entityId)); entity.SortId = int.Parse(sortValue); m_FTISService.UpdateLinksClass(entity); } catch (Exception ex) { result.ErrorCode = AjaxResultStatus.Fail; sbMsg.AppendFormat(ex.Message + "<br/>"); } result.Message = sbMsg.ToString(); return(this.Json(result)); }
public ActionResult Index(string keyWord, string linksClassId, int?page) { linksClassId = DecryptId(linksClassId); if (string.IsNullOrWhiteSpace(linksClassId)) { linksClassId = ((IList <LinksClass>)ViewData["LinksClassList"])[0].LinksClassId.ToString(); } LinksClass linksClass = m_FTISService.GetLinksClassById(int.Parse(linksClassId)); ViewData["LinksClass"] = linksClass; SetConditions(string.Empty, linksClassId, "2"); m_Conditions.Add("Status", "1"); int total = GetGridTotal(); int pageIndex = page.HasValue ? page.Value - 1 : 0; m_Conditions.Add("PageIndex", pageIndex.ToString()); m_Conditions.Add("PageSize", AppSettings.InSitePageSize.ToString()); var data = GetGridData(); return(View(data.ToPagedList(pageIndex, AppSettings.InSitePageSize, total))); }
public ActionResult MultiDelete(string allId) { AjaxResult result = new AjaxResult(AjaxResultStatus.Success, string.Empty); StringBuilder sbMsg = new StringBuilder(); string[] ids = allId.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string id in ids) { try { LinksClass entity = m_FTISService.GetLinksClassById(Convert.ToInt32(id)); //檢查底下的Links數量 IDictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("LinksClassId", id.ToString()); int subsCount = m_FTISService.GetLinksCount(conditions); if (subsCount == 0) { m_FTISService.DeleteLinksClass(entity); } else { result.ErrorCode = AjaxResultStatus.Fail; sbMsg.AppendFormat("{0},底下尚有網路資源,不可刪除。<br/>", entity.Name); } } catch (Exception ex) { result.ErrorCode = AjaxResultStatus.Fail; sbMsg.AppendFormat(ex.Message + "<br/>"); } } result.Message = sbMsg.ToString(); return(this.Json(result)); }
public void Update() { LinksClass entity = m_FTISService.GetLinksClassById(EntityId); Save(entity); }
public void Insert() { LinksClass entity = new LinksClass(); Save(entity); }
protected void LoadEntity(int id) { LinksClass entity = m_FTISService.GetLinksClassById(id); LoadEntity(entity); }