public EitherAsync <Error, Unit> Handle(Request request)
            {
                var player = _repo.Get(_currentUser.Tenant, request.PlayerId);

                var result = player
                             .Map(p =>
                {
                    p.ChangeName(request.FirstName, request.LastName);
                    return(_repo.Update(p, request.EntityVersion));
                })
                             .MatchAsync(
                    RightAsync: async right => await right.ToEither(),
                    Left: l => l)
                             .ToAsync()
                             .Do(p => DomainEvents.Add(new PlayerNameCorrected
                {
                    TenantId  = p.Tenant,
                    PlayerId  = p.Id,
                    Version   = p.Version,
                    FirstName = p.FirstName,
                    LastName  = p.LastName
                }))
                             .Map(p => Unit.Default);

                return(result);
            }
        public Task <Player> MockPlayerExists(TestPlayerDto player)
        {
            var p = new Player(CurrentTenant, player.Version,
                               player.Id, player.FirstName, player.LastName);

            _repoMock.Get(CurrentTenant, player.Id)
            .Returns(p);

            return(Task.FromResult(p));
        }
Exemple #3
0
        public async Task <PlayerGet> Handle(PlayerGetRequest request, CancellationToken cancellationToken)
        {
            var player = await _repository.Get(request.Id);

            if (player == null)
            {
                throw ApiException.NotFound(request.Id);
            }
            player.Badges = await _badgesClient.Get(request.Id);

            return(player);
        }
Exemple #4
0
 public JsonResult GetPlayer(int playerId)
 {
     var player = _playersRepository.Get(playerId);
     dynamic obj = new
     {
         player.Id,
         player.Name,
         player.IsEable,
         Keys = player.Keys.Split(',')
     };
     return Json(obj);
 }
 public EitherAsync <Error, Player> Get(TenantId tenant, PlayerId id)
 {
     return(_decoratee.Get(tenant, id));
 }
Exemple #6
0
 public Task <Player> GetByCode([FromRoute] string code)
 {
     return(_playerRepository.Get(code));
 }
 public async Task <Player> Get(Guid id)
 {
     return(await repo.Get(id));
 }