// DELETE: api/UserRole/5 detach a userRole, id is userId public async Task <HandleResult> Delete(string id, string roleId) { var command = new DetachUserRole(id, roleId); var result = await ExecuteCommandAsync(command); if (result.IsSuccess()) { return(HandleResult.FromSuccess("移除成功")); } return(HandleResult.FromFail(result.GetErrorMessage())); }
/// <summary>移除用户角色 /// </summary> public void Handle(ICommandContext context, DetachUserRole command) { context.Get <User>(command.AggregateRootId).DetachUserRole(command.RoleId); }