public void AddNewRole(RoleDto roleDto) { ValidateParameter.Validate(roleDto); var role = roleDto.ConvertToModel<RoleDto, Role>(); Repository.Create<Role>().Add(role); UnitOfWork.Commit(); }
public void ModifyRole(RoleDto roleDto) { ValidateParameter.Validate(roleDto); var role = roleDto.ConvertToModel<RoleDto, Role>(); var roleResult = Query.FindOne(SpecificationFactory.Create<Role>(internalRole => internalRole.Id == role.Id)); if (roleResult == null) { throw new BusinessException("该角色可能已被删除,请刷新后再试"); } roleResult.ModifyRoleName(role.Name).ModifyRoleIdentity(role.RoleIdentity); Repository.Create<Role>().Update(roleResult); UnitOfWork.Commit(); }