/// <summary> /// 添加角色 /// </summary> /// <param name="tRole">角色信息</param> /// <param name="operational">操作信息</param> /// <returns>结果</returns> public static Result AddRole(TRole tRole, Operational operational) { Result result = new Result(); try { using (var roleRepository = DbContext.CreateIRoleRepository()) { if (tRole.Id == Guid.Empty) { tRole.Id = Guid.NewGuid(); } var mRole = tRole.ToMRole(); roleRepository.Add(mRole); } result.IsSucceed = true; result.Message = "添加成功"; } catch (Exception ex) { result.IsSucceed = false; result.Message = Const.ErrorMessage; LogService.WriteLog(ex, "添加角色"); } return(result); }
/// <summary> /// 修改角色 /// </summary> /// <param name="tRole">角色信息</param> /// <param name="operational">操作信息</param> /// <returns>结果</returns> public static Result UpdateRole(TRole tRole, Operational operational) { Result result = new Result(); try { using (var roleRepository = DbContext.CreateIRoleRepository()) { var mRole = tRole.ToMRole(); roleRepository.Update(mRole); } result.IsSucceed = true; result.Message = "修改成功"; } catch (Exception ex) { result.IsSucceed = false; result.Message = Const.ErrorMessage; LogService.WriteLog(ex, "修改角色"); } return(result); }