在ASP.NET MVC 样板API 控制器中从应用程序服务动态生成。例如,我需要在请求进入操作/方法之前抛出异常。如何处理请求?谢谢!
public class UserAppService : PlatformAppServiceBase, IUserAppService
{
private readonly IRepository<User, long> _userRepository;
public UserAppService(IRepository<User, long> userRepository)
{
_userRepository = userRepository;
}
// handle request before request executes this action
public async Task<ListResultOutput<UserDto>> GetUsers()
{
var users = await _userRepository.GetAllListAsync();
return new ListResultOutput<UserDto>(users.MapTo<List<UserDto>>());
}
}