public async Task <UserEnrollment> SaveEnrollment(UserEnrollment userEnrollment)
        {
            var validator = new ValidateUserEnrollment();
            var results   = await validator.ValidateAsync(userEnrollment);

            if (!results.IsValid)
            {
                throw new Exception(results.ToString());
            }

            //if (!results.IsValid)
            //{
            //    var errorMessages = results.Errors.Select(failure => "Property " + failure.PropertyName + " failed validation. Error was: " + failure.ErrorMessage).ToList();

            //    throw new Exception(errorMessages.ToString());
            //}


            if (userEnrollment == null)
            {
                throw new ArgumentNullException(nameof(userEnrollment));
            }

            return(await _userEnrollmentRepository.SaveEnrollment(userEnrollment));
        }
Beispiel #2
0
        public async Task <UserEnrollment> SaveEnrollment(UserEnrollment userEnrollment)
        {
            var validator = new ValidateUserEnrollment();
            var results   = await validator.ValidateAsync(userEnrollment);

            if (!results.IsValid)
            {
                throw new Exception(results.ToString());
            }


            if (userEnrollment == null)
            {
                throw new ArgumentNullException(nameof(userEnrollment));
            }

            return(await _userEnrollmentRepository.SaveEnrollment(userEnrollment));
        }