Пример #1
0
        public async Task <CommandResponse <UserView> > Handle(FindUserByUsernameCommand request, CancellationToken cancellationToken)
        {
            var query = new GetUserByQuery(x => x.Username == request.Username);

            var user = (await _mediator.Send(query)).FirstOrDefault();

            if (user is null)
            {
                return(CommandResponse <UserView> .FromFailure(FindUserByUsernameCommandException.UserNotFound));
            }

            var userView = UserView.FromUser(user);

            return(CommandResponse <UserView> .FromSuccess(userView));
        }
Пример #2
0
 public async Task <List <User> > Handle(GetUserByQuery request, CancellationToken cancellationToken)
 {
     return(await _context.Users.Where(request.Where).ToListAsync());
 }