private void ValidateProviders(Provider provider)
        {
            if (!_paramValidator.IsValidProviderUkprn(provider.Ukprn))
            {
                _logger.LogError($"The Ukprn {provider.Ukprn} is invalid");
                throw new ArgumentException("A ukprn is invalid");
            }

            provider.LocationIds.ForEach(ValidateLocationId);
        }
Esempio n. 2
0
        public async Task <IActionResult> DeleteProviderPost(string employerAccountId, string apprenticeshipId, int ukprn, bool confirmDelete)
        {
            if (!_paramValidator.IsValidEmployerAccountId(employerAccountId) ||
                !_paramValidator.IsValidApprenticeshipId(apprenticeshipId) ||
                !_paramValidator.IsValidProviderUkprn(ukprn))
            {
                _logger.LogDebug($"Invalid parameters in the following: {nameof(employerAccountId)}({employerAccountId}), {nameof(apprenticeshipId)}({apprenticeshipId}), {nameof(ukprn)}({ukprn})");
                return(BadRequest());
            }

            if (confirmDelete)
            {
                await _mediator.Send(new DeleteApprenticeshipProviderFavouriteCommand()
                {
                    ApprenticeshipId  = apprenticeshipId,
                    EmployerAccountId = employerAccountId,
                    Ukprn             = ukprn
                });
            }

            return(RedirectToAction("TrainingProvider", new { apprenticeshipId, employerAccountId }));
        }