public ActionResult ModuleTypeInfo(ModuleTypeDTO dto) { if (ModelState.IsValid) { if (string.IsNullOrEmpty(dto.Id)) { string result = ModuleTypeSrv.InsertModuleType(dto); if (!string.IsNullOrEmpty(result) && result != "-2") { result = "1"; } return(Content(result, "text/plain")); } else { ModuleTypeSrv.UpdateModuleType(dto); return(Content("1")); } } //获取ErrorMessage string errorMsg = ModelState.Values.First(x => x.Errors.Count > 0).Errors[0].ErrorMessage; return(Content(errorMsg, "text/plain")); }
/// <summary> /// 更新模块分类。 /// </summary> /// <param name="dto">待更新模块分类的信息。</param> public static void UpdateModuleType(ModuleTypeDTO dto) { Db.SessionFactory.EvictQueries("ModuleType"); ModuleType mt = Db.Session.Load(typeof(ModuleType), dto.Id) as ModuleType; mt.Name = dto.Name; mt.Remark = dto.Remark; mt.OrderId = dto.OrderId; Db.TransUpdate(mt); }
/// <summary> /// 编辑moduletype /// </summary> /// <param name="Id"></param> /// <returns></returns> public ActionResult EditModuleType(string Id) { ModuleType mt = CommonSrv.LoadObjectById(typeof(ModuleType), Id) as ModuleType; ModuleTypeDTO modultTypeDTO = new ModuleTypeDTO(); modultTypeDTO.Id = mt.Id; modultTypeDTO.Name = mt.Name; modultTypeDTO.OrderId = mt.OrderId; modultTypeDTO.Remark = mt.Remark; modultTypeDTO.ParentModuleTypeId = mt.ParentModuleType == null ? "" : mt.ParentModuleType.Id; return(View("ModuleTypeInfo", modultTypeDTO)); }
/// <summary> /// 新增模块分类。 /// </summary> /// <param name="dto">待新增模块分类的信息。</param> /// <returns>新模块分类的Id。</returns> public static string InsertModuleType(ModuleTypeDTO dto) { Db.SessionFactory.EvictQueries("ModuleType"); ModuleType mt = new ModuleType(); mt.Id = IdGen.GetNextId(typeof(ModuleType)); mt.Name = dto.Name; mt.Remark = dto.Remark; mt.OrderId = dto.OrderId; if (dto.ParentModuleTypeId != null && dto.ParentModuleTypeId.Length > 0) { ModuleType pmt = Db.Session.Load(typeof(ModuleType), dto.ParentModuleTypeId) as ModuleType; pmt.AddSubModuleType(mt); } Db.TransInsert(mt); return(mt.Id); }
/// <summary> /// 获取moduletype 详情,返回json 数据 /// </summary> /// <param name="Id"></param> /// <returns></returns> public JsonResult ModuleTypeInfo(string Id) { JsonResult jresult = new JsonResult(); jresult.JsonRequestBehavior = JsonRequestBehavior.AllowGet; try { ModuleType mt = CommonSrv.LoadObjectById(typeof(ModuleType), Id) as ModuleType; ModuleTypeDTO modultTypeDTO = new ModuleTypeDTO(); modultTypeDTO.Id = mt.Id; modultTypeDTO.Name = mt.Name; modultTypeDTO.OrderId = mt.OrderId; modultTypeDTO.Remark = mt.Remark; jresult.Data = modultTypeDTO; } catch { //TODO js 异常判断 jresult.Data = "[{result:-1}]"; } return(jresult); }