public void RegisterTeam(TeamWithPlayers teamWithPlayers)
        {
            var ratings = _ratingService.Get().ToList();

            var team   = _teamMapper.Map(teamWithPlayers, ratings);
            var teamId = _teamService.Insert(team).Id;

            var players = _playerMapper.Map(teamWithPlayers.Players, ratings, teamId);

            _playerService.InsertMany(players);
        }
Exemplo n.º 2
0
        public Team Map(TeamWithPlayers teamWithPlayers, IEnumerable <Rating> ratings)
        {
            var rid = ratings.SingleOrDefault(x => x.Ntrp == teamWithPlayers.Ntrp) == null ? 1 : ratings.Single(x => x.Ntrp == teamWithPlayers.Ntrp).Id;

            return(new Team()
            {
                Name = teamWithPlayers.Name,
                Gender = teamWithPlayers.Gender,
                RatingId = rid
            });
        }
Exemplo n.º 3
0
        public async Task <TeamWithPlayers> GetTeamWithPlayers(int id)
        {
            var BaseTeam = await _dbService.Teams.FindAsync(id);

            TeamWithPlayers TeamWP = new TeamWithPlayers();

            Mapper.Map(BaseTeam, TeamWP);
            TeamWP.Players = await _dbService.Players.Where(x => x.TeamID == id).ToListAsync();

            return(TeamWP);
        }
Exemplo n.º 4
0
        public async Task <TeamInDraft> CreateTestTeam(int TestTeamID)
        {
            TeamInDraft TestTeamIM = new TeamInDraft();

            TeamWithPlayers TeamWP = await _teamService.GetTeamWithPlayers(TestTeamID);

            TestTeamIM.id   = TeamWP.id;
            TestTeamIM.Name = TeamWP.Name;

            foreach (var Player in TeamWP.Players)
            {
                var newPlayer = new PlayerInDraft();
                Mapper.Map(Player, newPlayer);
                TestTeamIM.Players.Add(newPlayer);
            }

            return(TestTeamIM);
        }
Exemplo n.º 5
0
        public IHttpActionResult RegisterTeam(TeamWithPlayers teamWithPlayers, StripePaymentRequest stripePaymentRequest)
        {
            try
            {
                _stripePaymentService.Charge(stripePaymentRequest);
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(
                          new HttpResponseMessage(HttpStatusCode.PaymentRequired)
                {
                    StatusCode   = HttpStatusCode.InternalServerError,
                    ReasonPhrase = ex.Message
                });
            }

            _registerFacade.RegisterTeam(teamWithPlayers);

            return(Ok());
        }