Facebook
From Gruff Pig, 1 Year ago, written in C#.
This paste is a reply to Untitled from Toxic Lemur - view diff
Embed
Download Paste or View Raw
Hits: 139
  1. public class UsersAuthenticateCommand : IRequest<IActionResult>
  2. {
  3.     [Required]
  4.     public string Username { get; set; }
  5.  
  6.     [Required]
  7.     public string Password { get; set; }
  8. }
  9.  
  10. public class UsersAuthenticateCommandHandler : IRequestHandler<UsersAuthenticateCommand, IActionResult>
  11. {
  12.     private IUserService _userService;
  13.  
  14.     public UsersAuthenticateCommandHandler(IUserService userService)
  15.     {
  16.         _userService = userService;
  17.     }
  18.  
  19.     public async Task<IActionResult> Handle(UsersAuthenticateCommand command, CancellationToken cancellationToken)
  20.     {
  21.         UsersAuthenticateCommandResult response = _userService.Authenticate(command);
  22.  
  23.         if (response == null)
  24.             return new BadRequestObjectResult(new { result = "Username or password is incorrect" });
  25.  
  26.         return new OkObjectResult(response);
  27.     }
  28. }

Replies to Re: Untitled rss

Title Name Language When
Re: Re: Untitled Mature Macaque csharp 1 Year ago.