public ActionResult DeleteCard(ScoreCardView scoreCardView) { try { _golfScoreCardLogic.DeleteScores(scoreCardView.Id); return(RedirectToAction("ViewScoreCard")); } catch (Exception ex) { ViewBag.ErrorMessage = $"Error occurered while deleting the score \n {ex}"; return(View()); } }
private List <Shot> MapShots(ScoreCardView playerScores) { var shots = new List <Shot>(); for (int i = 0; i < playerScores.Hole.Count; i++) { shots.Add(new Shot { Id = playerScores.Id, Tee = _teeRepository.GetTeeByIndex(i), Shots = playerScores.Hole[i] }); } return(shots); }
public ActionResult EditCard(ScoreCardView scoreCardView) { if (scoreCardView.Player != null && !scoreCardView.Hole.Contains(0)) { var scores = _golfScoreCardLogic.WorkOutScore(_golfScoreMapper.MapToGameModel(new List <ScoreCardView>() { scoreCardView })).Result; _golfScoreCardLogic.EditScores(scores.FirstOrDefault()); return(RedirectToAction("ViewScoreCard")); } else { ViewBag.ErrorMessage = "The scorecard contains invalid entries.\nPlease insert all the shots before clicking on the SUBMIT button."; return(View()); } }