public async Task <MatchModel> AddAsync(MatchModel matchModel) { var matchEntity = mapper.Map <MatchEntity>(matchModel); var response = await matchRepository.AddAsync(matchEntity); return(mapper.Map <MatchModel>(response)); }
public async Task <Guid> Handle(CreateMatchCommand request, CancellationToken cancellationToken) { var match = Match.CreateNew(request.Name, new TeamId(request.HomeTeamId), new TeamId(request.AwayTeamId), request.Score, request.Season, request.UtcDate, request.ExternalId, request.Status); await _matchRepository.AddAsync(match); return(match.Id.Value); }
public async Task <MatchDTO> CreateMatch(CreateMatchModel createMatch) { var participantHome = await _participantRepository.GetAsync(createMatch.IdParticipantHome); if (participantHome == null) { throw new AppException("Home participant doesn't exist."); } var participantAway = await _participantRepository.GetAsync(createMatch.IdParticipantAway); if (participantAway == null) { throw new AppException("Away participant doesn't exist."); } var matchParticipant = new ParticipantsMatch(participantHome, participantAway); var match = new Match(new Guid(), matchParticipant, DateTime.Now, createMatch.BeginsAt); await _matchRepository.AddAsync(match); return(_mapper.Map <MatchDTO>(match)); }
public async Task <IActionResult> Create(MatchCreateDto model) { var teamA = await _teamRepository.GetByIdAsync(model.TeamAId); if (teamA == null) { return(BadRequest($"Invalid Team A Id { model.TeamAId }")); } var teamB = await _teamRepository.GetByIdAsync(model.TeamBId); if (teamB == null) { return(BadRequest($"Invalid Team B Id { model.TeamBId }")); } var match = new Match(teamA, teamB, model.MatchDate); await _matchRepository.AddAsync(match); await _unitOfWork.Commit(); return(CreatedAtAction(nameof(GetById), new { id = match.Id }, MatchDto.FromEntity(match))); }
public async Task SaveChessMatchOnDatabase(string roomId) { var chessMatch = await GetChessMatch(roomId); await _matchRepository.AddAsync(chessMatch.Match); }
public async Task AddMatch(Match newMatch) { await _matchRepository.AddAsync(_mapper.Map <DataRepository.DataEntities.Match>(newMatch)); }