/// <summary> /// 添加角色 /// </summary> public void AddRoleExecute() { CurentRoleInfo = new RoleInfo(); CurentRoleInfo.RoleID = Guid.NewGuid().ToString("n"); ; AddOrEditRoleWindow window = new AddOrEditRoleWindow() { Owner = Application.Current.MainWindow, DataContext = this, }; if (window.ShowDialog() == true) { ErrType err = _businessService.AddRole(_loginID, CurentRoleInfo); if (err.Err == ERR.SUCCESS) { RoleList.Add(CurentRoleInfo); } else { MessageBox.Show(err.ErrMsg, err.ErrTitle, MessageBoxButton.OK, MessageBoxImage.Error); } } }
internal static RoleInfo ToRoleInfo(RoleEntity roleEntity) { RoleInfo roleInfo = new RoleInfo(); roleInfo.RoleID = roleEntity.RoleID; roleInfo.RoleName = roleEntity.RoleName; roleInfo.Remark = roleEntity.Remark; return roleInfo; }
/// <summary> /// 修改角色 /// </summary> /// <param name="loginID">登录ID</param> /// <param name="roleInfo">角色信息</param> /// <returns></returns> public ErrType UpdateRole(string loginID, RoleInfo roleInfo) { try { RoleEntity info = MyConverter.ToRoleEntity(roleInfo); EntityBase result = ManagerService.UpdateRole(loginID, info); if (!result.Result) return new ErrType(ERR.SERVICE, result.Desc); return GeneralErr.Success; } catch (TimeoutException te) { FileLog.WriteLog("", Assembly.GetExecutingAssembly().GetName().Name, this.GetType().Name, new StackTrace().GetFrame(0).GetMethod().Name, te.Message); return new ErrType(ERR.EXEPTION, ErrorText.TimeoutException); } catch (Exception ex) { FileLog.WriteLog("", Assembly.GetExecutingAssembly().GetName().Name, this.GetType().Name, new StackTrace().GetFrame(0).GetMethod().Name, ex.Message); return new ErrType(ERR.EXEPTION, ErrorText.OperationError); } }
internal static RoleEntity ToRoleEntity(RoleInfo roleInfo) { RoleEntity roleEntity = new RoleEntity(); roleEntity.RoleID = roleInfo.RoleID; roleEntity.RoleName = roleInfo.RoleName; roleEntity.Remark = roleInfo.Remark; return roleEntity; }