feat: 添加删除按钮
parent
102f150fa4
commit
c346691b54
|
|
@ -11,6 +11,8 @@ public interface IUserService
|
|||
Task<PageResultDto<User>> GetUsers(GetUserDto req);
|
||||
|
||||
Task CreateUser(User input);
|
||||
|
||||
Task DeleteUser(int userId);
|
||||
}
|
||||
|
||||
public class UserService : IUserService
|
||||
|
|
@ -42,4 +44,13 @@ public class UserService : IUserService
|
|||
_userPointManagementDbContext.Users.Add(input);
|
||||
await _userPointManagementDbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task DeleteUser(int userId)
|
||||
{
|
||||
var user = await _userPointManagementDbContext.Users.FirstOrDefaultAsync(x => x.Id == userId)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
_userPointManagementDbContext.Users.Remove(user);
|
||||
await _userPointManagementDbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
@inherits MyAntDesignAppServer.Pages.UserManagement.UserManagementBase
|
||||
@page "/"
|
||||
@using UserPointManagement.Application.Services
|
||||
@using UserPointManagement.Model.Dtos
|
||||
@using UserPointManagement.Model.Entities
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using System.Text.Json
|
||||
|
|
@ -37,7 +36,7 @@
|
|||
<ActionColumn Title="操作" Width="220">
|
||||
<Space Size=@("middle")>
|
||||
<SpaceItem>
|
||||
<button>编辑</button>
|
||||
<SpaceItem><Button Danger OnClick="()=>Delete(context.Id)">Delete</Button></SpaceItem>
|
||||
</SpaceItem>
|
||||
</Space>
|
||||
</ActionColumn>
|
||||
|
|
|
|||
|
|
@ -59,4 +59,10 @@ public class UserManagementBase : ComponentBase
|
|||
_pageSize = args.PageSize;
|
||||
await RefreshTable();
|
||||
}
|
||||
|
||||
protected async Task Delete(int userId)
|
||||
{
|
||||
await _userService.DeleteUser(userId).ConfigureAwait(false);
|
||||
await RefreshTable();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue