public JsonResult AddMoudleOperate(MoudleOperateInfo model) { if (model != null && ModelState.IsValid) { var entity = ChannelMoudleOperateBll.GetMoudleOperateById(model.MoudleOperateId); if (entity != null) { return(Json(JsonHandler.CreateMessage(0, Suggestion.PrimaryRepeat), JsonRequestBehavior.AllowGet)); } entity = new MoudleOperateInfo { MoudleOperateId = model.MoudleId + model.KeyCode, Name = model.Name, MoudleId = model.MoudleId, KeyCode = model.KeyCode, IsValid = model.IsValid, Sort = model.Sort }; if (ChannelMoudleOperateBll.AddMoudleOperate(model, ref _errors)) { return(Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed), JsonRequestBehavior.AllowGet)); } string err = _errors.Error; return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + err), JsonRequestBehavior.AllowGet)); } return(Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail), JsonRequestBehavior.AllowGet)); }
/// <summary> /// 修改模块操作 /// </summary> /// <param name="model"></param> /// <param name="errors"></param> /// <returns></returns> public bool EditMoudleOperate(MoudleOperateInfo model, ref ValidationErrors errors) { try { ChannelMoudleOperate entity = ChannelMoudleOperateRepository.GetMoudleOperateById(model.MoudleOperateId); if (entity == null) { errors.Add(Suggestion.Disable); return(false); } entity.MoudleOperateId = model.MoudleOperateId; entity.Name = model.Name; entity.MoudleId = model.MoudleId; entity.KeyCode = model.KeyCode; entity.IsValid = model.IsValid; entity.Sort = model.Sort; if (ChannelMoudleOperateRepository.EditMoudleOperate(entity) == 1) { return(true); } errors.Add(Suggestion.EditFail); return(false); } catch (Exception ex) { errors.Add(ex.Message); return(false); } }
/// <summary> /// 添加模块操作 /// </summary> /// <param name="model"></param> /// <param name="errors"></param> /// <returns></returns> public bool AddMoudleOperate(MoudleOperateInfo model, ref ValidationErrors errors) { try { ChannelMoudleOperate entity = ChannelMoudleOperateRepository.GetMoudleOperateById(model.MoudleOperateId); if (entity != null) { errors.Add(Suggestion.PrimaryRepeat); return(false); } entity = new ChannelMoudleOperate { MoudleOperateId = model.MoudleOperateId, Name = model.Name, MoudleId = model.MoudleId, KeyCode = model.KeyCode, IsValid = model.IsValid, Sort = model.Sort }; if (ChannelMoudleOperateRepository.AddMoudleOperate(entity) == 1) { return(true); } errors.Add(Suggestion.InsertFail); return(false); } catch (Exception ex) { errors.Add(ex.Message); return(false); } }
public ActionResult AddMoudleOperate(string moudleId) { //ViewBag.Permis = GetPermission(); var entity = new MoudleOperateInfo { MoudleId = moudleId, IsValid = 1 }; return(View(entity)); }
/// <summary> /// 根据模块操作Id,获取模块操作 /// </summary> /// <param name="moudleOperateId"></param> /// <returns></returns> public MoudleOperateInfo GetMoudleOperateById(string moudleOperateId) { if (MoudleOperateExistsById(moudleOperateId)) { ChannelMoudleOperate entity = ChannelMoudleOperateRepository.GetMoudleOperateById(moudleOperateId); var model = new MoudleOperateInfo { MoudleOperateId = entity.MoudleOperateId, Name = entity.Name, MoudleId = entity.MoudleId, KeyCode = entity.KeyCode, IsValid = entity.IsValid, Sort = entity.Sort }; return(model); } return(null); }