예제 #1
0
        private async Task ValidatePlayerToDivision(int id, ParticipantViewModel participant)
        {
            var division = await DivisionRepository.FindAsync(id);

            if (division.IsGradeBased.HasValue && division.IsGradeBased.Value)
            {
                if (participant.NextGrade < division.GradeLowerLimit.Value || participant.NextGrade > division.GradeUpperLimit.Value)
                {
                    ModelState.AddModelError("Grade", $"Your team is registered for players between grades {division.GradeLowerLimit.Value} and {division.GradeUpperLimit.Value}.");
                }
            }
            if (division.IsHeightBased.HasValue && division.IsHeightBased.Value)
            {
                int overallHeight = participant.HeightFeet * 12 + participant.HeightInches;
                if (overallHeight < division.HeightLowerLimit.Value || overallHeight > division.HeightUpperLimit.Value)
                {
                    ModelState.AddModelError("HeightFeet", $"Your team is registered for players between {division.HeightLowerLimit.Value} and {division.HeightUpperLimit.Value} inches.");
                }
            }
        }