Esempio n. 1
0
        public CreateInputModel CreatePlayerScore(CreateInputModel model, string userIdentity)
        {
            var member = _memberRepository.FindBy(x => x.EmailAddress == userIdentity).
                         SingleOrDefault();

            var reservation = _reservationRepository.GetWithGolfCourse(model.ReservationID);

            var golfCourse = reservation.TeeTime.GolfCourse;

            var calculatedScore = model.Score - (golfCourse.Rating / golfCourse.Slope * 113);



            var playerScoreModel = new PlayerScores
            {
                ReservationID = model.ReservationID,
                MemberID      = member.ID,
                Score         = calculatedScore,
                HoleId        = model.HoleID,
                HandicapId    = model.HandicapID,
                DateCreated   = DateTime.UtcNow,
                DatePlayed    = model.DatePlayed,
            };

            _playerScoreRepository.Add(playerScoreModel);
            _playerScoreRepository.SaveChanges();

            return(model);
        }