public List <string> GetPars(int id) { var CourseData = _courseData.get(id); List <string> Pars = new List <string>(); Pars.Add((CourseData.Par01).ToString("00")); Pars.Add((CourseData.Par02).ToString("00")); Pars.Add((CourseData.Par03).ToString("00")); Pars.Add((CourseData.Par04).ToString("00")); Pars.Add((CourseData.Par05).ToString("00")); Pars.Add((CourseData.Par06).ToString("00")); Pars.Add((CourseData.Par07).ToString("00")); Pars.Add((CourseData.Par08).ToString("00")); Pars.Add((CourseData.Par09).ToString("00")); Pars.Add((CourseData.Par10).ToString("00")); Pars.Add((CourseData.Par11).ToString("00")); Pars.Add((CourseData.Par12).ToString("00")); Pars.Add((CourseData.Par13).ToString("00")); Pars.Add((CourseData.Par14).ToString("00")); Pars.Add((CourseData.Par15).ToString("00")); Pars.Add((CourseData.Par16).ToString("00")); Pars.Add((CourseData.Par17).ToString("00")); Pars.Add((CourseData.Par18).ToString("00")); return(Pars); }
// GET: TeeTime/Delete/5 public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } var teeTime = await _context.TeeTime .SingleOrDefaultAsync(m => m.TeeTimeId == id); if (teeTime == null) { return(NotFound()); } var model = new TeeTimeDisplayViewModel(); model.TeeTimeId = teeTime.TeeTimeId; model.TeeTimeTS = teeTime.TeeTimeTS; model.CourseName = _courseData.get(teeTime.CourseId).CourseName; model.NumPlayers = teeTime.NumPlayers; model.Member = _memberData.get(teeTime.ReservedById); return(View(model)); }
public async Task <IActionResult> Put(int id, [FromBody] ScoresInfo model) { try { Score Score = _context.Score.SingleOrDefault(m => m.ScoreId == id); //Score.CourseId = model.CourseId; //Score.Color = model.Color; //Score.ScoreDate = model.ScoreDate; //Score.EnteredById = model.EnteredBy.MemberId; Score.Hole01 = model.Hole01; Score.Hole02 = model.Hole02; Score.Hole03 = model.Hole03; Score.Hole04 = model.Hole04; Score.Hole05 = model.Hole05; Score.Hole06 = model.Hole06; Score.Hole07 = model.Hole07; Score.Hole08 = model.Hole08; Score.Hole09 = model.Hole09; Score.Hole10 = model.Hole10; Score.Hole11 = model.Hole11; Score.Hole12 = model.Hole12; Score.Hole13 = model.Hole13; Score.Hole14 = model.Hole14; Score.Hole15 = model.Hole15; Score.Hole16 = model.Hole16; Score.Hole17 = model.Hole17; Score.Hole18 = model.Hole18; Score.HoleIn = model.HoleIn; Score.HoleOut = model.HoleOut; Score.HoleTotal = model.HoleTotal; Score.Round = model.Round; Score.MatchGrp = model.MatchGrp; Score.MatchPlayerNum = model.MatchPlayerNum; Score.MatchPoints = model.MatchPoints; int holesPlayed = 0; if (Score.Hole01 > 0) { holesPlayed++; } if (Score.Hole02 > 0) { holesPlayed++; } if (Score.Hole03 > 0) { holesPlayed++; } if (Score.Hole04 > 0) { holesPlayed++; } if (Score.Hole05 > 0) { holesPlayed++; } if (Score.Hole06 > 0) { holesPlayed++; } if (Score.Hole07 > 0) { holesPlayed++; } if (Score.Hole08 > 0) { holesPlayed++; } if (Score.Hole09 > 0) { holesPlayed++; } if (Score.Hole10 > 0) { holesPlayed++; } if (Score.Hole11 > 0) { holesPlayed++; } if (Score.Hole12 > 0) { holesPlayed++; } if (Score.Hole13 > 0) { holesPlayed++; } if (Score.Hole14 > 0) { holesPlayed++; } if (Score.Hole15 > 0) { holesPlayed++; } if (Score.Hole16 > 0) { holesPlayed++; } if (Score.Hole17 > 0) { holesPlayed++; } if (Score.Hole18 > 0) { holesPlayed++; } int lastHolePlayed = 0; lastHolePlayed = setLastHolePlayed(lastHolePlayed, 1, model.Hole01); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 2, model.Hole02); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 3, model.Hole03); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 4, model.Hole04); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 5, model.Hole05); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 6, model.Hole06); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 7, model.Hole07); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 8, model.Hole08); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 9, model.Hole09); if (lastHolePlayed == 0 || lastHolePlayed >= 9) { lastHolePlayed = setLastHolePlayed(lastHolePlayed, 10, model.Hole10); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 11, model.Hole11); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 12, model.Hole12); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 13, model.Hole13); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 14, model.Hole14); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 15, model.Hole15); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 16, model.Hole16); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 17, model.Hole17); lastHolePlayed = setLastHolePlayed(lastHolePlayed, 18, model.Hole18); } Score.LastHolePlayed = lastHolePlayed; //Score.TourEvent = model.TourEvent; //Score.TourId = model.TourId; //if (model.AboutGame == null) model.AboutGame = ""; //Score.AboutGame = model.AboutGame; Score.NetScore = 199; Score.TourScore = 199; float HcpAllowPct = 100.0F; float MultiAdj = 0.0F; Tour Tour; Handicap Handicap = _handicap.getHandicapForDate(Score.MemberId, Score.ScoreDate); CourseDetail CourseDetail = _courseDetail.get(Score.CourseId, Score.Color); Course Course = _courseData.get(Score.CourseId); if (Score.TourEvent == true && (Tour = _tourInfo.getTour(Score.TourId)) != null) { HcpAllowPct = Tour.HcpAllowPct; if (Tour.AllowMultiTee == true) { CourseDetail BaseCourse = _courseDetail.get(Course.CourseId, Tour.BaseColor.ToString()); MultiAdj = (float)(BaseCourse.Rating - CourseDetail.Rating); } } if (Handicap != null && Handicap.HcpIndex > 0) { float courseHandicap = Handicap.HcpIndex * CourseDetail.Slope / 113; float courseHandicapT = (Handicap.HcpIndex * CourseDetail.Slope / 113 - MultiAdj) * (HcpAllowPct / 100); Score.NetScore = (int)Math.Round(model.HoleTotal - courseHandicap * holesPlayed / 18.0); Score.TourScore = (int)Math.Round(model.HoleTotal - courseHandicapT * holesPlayed / 18.0); } else { float courseHandicap = getS36Hcp(Score, Course) * CourseDetail.Slope / 113; float courseHandicapT = getS36Hcp(Score, Course) * (HcpAllowPct / 100) * CourseDetail.Slope / 113; Score.NetScore = (int)Math.Round(model.HoleTotal - courseHandicap * holesPlayed / 18.0); Score.TourScore = (int)Math.Round(model.HoleTotal - courseHandicapT * holesPlayed / 18.0); } countScores(Score, Course); Score.Tiebreaker = _scoreInfo.getTiebreaker(Score); //Score.LastUpdatedBy = User.Identity.Name; Score.LastUpdatedBy = "Live Score"; Score.LastUpdatedTs = DateTime.Now; _context.Update(Score); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ScoreExists(model.ScoreId)) { return(NotFound()); } else { throw; } } return(Ok()); }