public async Task Persist(Match match) { using (DatabaseContext context = new DatabaseContext()) { context.Matches.Add(match); await context.SaveChangesAsync().ConfigureAwait(false); } }
public void UpdateUserRatings(Match match) { IList<Bet> betsForThisMatch = m_BetRepository.GetAllBetsByMatchId(match.Id); foreach (var betForThisMatch in betsForThisMatch) { User user = m_UserRepository.GetById(betForThisMatch.UserId).Result; IList<Bet> betsByUser = m_BetRepository.GetBetsByUserId(user.Id).Result; user.Rating = (double)betsByUser.Count(x => x.BoxerId == m_MatchRepository.GetById(x.MatchId).Result.WinnerId) / betsByUser.Count(); } }
public MatchDto MapToDto(Match match) { return new MatchDto { Id = match.Id, VenueId = match.VenueId, BoxerOneId = match.BoxerOneId, BoxerTwoId = match.BoxerTwoId, StartDate = match.StartDate, Description = match.Description, WinnerId = match.WinnerId }; }