public async Task <IActionResult> Get()
        {
            if (await _mediator.Send(
                    new VerifyUser
            {
                Email = User.Claims.Single(c => c.Type == ClaimTypes.Email).Value
            }
                    ))
            {
                return(Ok());
            }


            return(Unauthorized());
        }
示例#2
0
 public async Task <IEnumerable <GameViewModel> > SearchGames(SearchModel model)
 {
     return(await _mediator.Send(new SearchForGames
     {
         Text = model.Text,
         MostRecentlyAdded = model.MostRecentlyAdded
     }));
 }
        public async Task <GameViewModel> Handle(RegisterGame request, CancellationToken cancellationToken)
        {
            var title = await _mediator.Send(
                new RegisterTitle { Name = request.Name, Subtitle = request.Subtitle }, cancellationToken);

            var game = await RegisterGame(request, title);

            await _mediator.Send(new AddCopy
            {
                GameId = game.Id
            }, cancellationToken);

            return(new GameViewModel
            {
                Id = game.Id,
                Name = title.Name,
                Subtitle = title.Subtitle,
                Platform = _context.Platforms.Single(p => p.Id == request.Platform).Name,
                Registered = game.Registered,
                Code = game.Code
            });
        }
示例#4
0
        public async Task <bool> Handle(VerifyUser request, CancellationToken cancellationToken)
        {
            var user = _context.Users.SingleOrDefault(u => u.Email == request.Email);

            if (user == null)
            {
                var registration = await _mediator.Send(new RegisterUser
                {
                    Email = request.Email
                }, cancellationToken);

                if (registration == null)
                {
                    return(false);
                }
            }

            return(true);
        }
示例#5
0
 public async Task <IEnumerable <PlatformViewModel> > GetPlatforms()
 {
     return(await _mediator.Send(new GetPlatforms()));
 }
        public async Task <IActionResult> AddNewGame(GameModel model)
        {
            var result = await _mediator.Send(new RegisterGame
            {
                Name     = model.Name,
                Subtitle = model.Subtitle,
                Code     = model.Code,
                Platform = model.Platform
            });

            return(result != null ? (IActionResult)Created($"/games/codes/{result.Code}", result) : Conflict());
        }