public JsonResult GetAction(int id = 0) { IDAL.IActionToPageRepository actionPageRepository = EnterRepository.GetRepositoryEnter().GetActionToPageRepository; var result = actionPageRepository.LoadEntities(m => m.PageId == id).FirstOrDefault(); return(Json(new { state = "success", actionList = result == null ? "" : result.ActionList })); }
public JsonResult UpdateAction(string ActionListId, int id = 0) { IDAL.IActionToPageRepository actionPageRepository = EnterRepository.GetRepositoryEnter().GetActionToPageRepository; var result = actionPageRepository.LoadEntities(m => m.PageId == id).FirstOrDefault(); if (result == null) { Model.ActionToPage actionPage = new Model.ActionToPage() { ActionList = ActionListId, PageId = id, IsDelete = string.IsNullOrEmpty(ActionListId) ? (byte)1 : (byte)0 }; actionPageRepository.AddEntity(actionPage); PublicFunction.AddOperation(1, string.Format("编辑页面与页面按钮"), string.Format("编辑页面与页面按钮成功")); if (EnterRepository.GetRepositoryEnter().SaveChange() > 0) { return(Json(new { state = "success", message = "添加页面按钮成功" })); } else { PublicFunction.AddOperation(1, string.Format("编辑页面与页面按钮"), string.Format("编辑页面与页面按钮失败")); EnterRepository.GetRepositoryEnter().SaveChange(); return(Json(new { state = "error", message = "服务器泡妞去了" })); } } else { result.ActionList = ActionListId; result.IsDelete = string.IsNullOrEmpty(ActionListId) ? (byte)1 : (byte)0; PublicFunction.AddOperation(1, string.Format("编辑页面与页面按钮"), string.Format("编辑页面与页面按钮成功")); if (EnterRepository.GetRepositoryEnter().SaveChange() > 0) { return(Json(new { state = "success", message = "修改页面按钮成功" })); } else { PublicFunction.AddOperation(1, string.Format("编辑页面与页面按钮"), string.Format("编辑页面与页面按钮失败")); EnterRepository.GetRepositoryEnter().SaveChange(); return(Json(new { state = "error", message = "服务器泡妞去了" })); } } }