Example #1
0
 public async Task<int> GetHandicap(RepoProvider repoProvider, WeekModel week, Guid playerId)
 {
     var result = 0;
     if (week.BeenPlayed)
     {
         result = repoProvider.RoundRepo.GetWeeklyRound(playerId, week.WeekId).Handicap;
     }
     else
     {
         result = await ServiceProvider.HandicapInstance.CalculateHandicap(playerId);
     }
     return result;
 }
 public async Task<IHttpActionResult> Post(AddNewPlayerMatchupViewModel vm)
 {
     if (ModelState.IsValid && vm.NewPlayerMatchups.Count > 0)
     {
         //Todo:Validate that each player is selected only once.
         using (var repoProvider = new RepoProvider())
         {
             WeekModel weekObj = new WeekModel() { WeekId = Guid.NewGuid(), BeenPlayed = false, WeekNbr = vm.WeekNbr, ScoreCreateDate = DateTime.Now };
             repoProvider.WeekRepo.Add(weekObj);
             for (int i = 0; i < vm.NewPlayerMatchups.Count; i++)
             {
                 MatchupModel matchupObj = new MatchupModel() { MatchupId = Guid.NewGuid(), WeekId = weekObj.WeekId, Player1 = vm.NewPlayerMatchups[i].Player1Id, Player2 = vm.NewPlayerMatchups[i].Player2Id };
                 repoProvider.MatchupRepo.Add(matchupObj);
             }
             await repoProvider.SaveAllRepoChangesAsync();
         }
         return Ok();
     }
     return BadRequest();
 }