private void ValidateApprenticeship(Favourite apprenticeship) { if (!_paramValidator.IsValidApprenticeshipId(apprenticeship.ApprenticeshipId)) { _logger.LogError($"The apprenticeship id {apprenticeship.ApprenticeshipId} is invalid"); throw new ArgumentException("An apprenticeship id is invalid"); } apprenticeship.Providers.ToList().ForEach(ValidateProviders); }
public async Task <IActionResult> DeletePost(string employerAccountId, string apprenticeshipId, bool confirmDelete) { if (!_paramValidator.IsValidEmployerAccountId(employerAccountId) || !_paramValidator.IsValidApprenticeshipId(apprenticeshipId)) { _logger.LogDebug($"Invalid parameters in the following: {nameof(employerAccountId)}({employerAccountId}), {nameof(apprenticeshipId)}({apprenticeshipId})"); return(BadRequest()); } if (confirmDelete) { await _mediator.Send(new DeleteApprenticeshipFavouriteCommand() { ApprenticeshipId = apprenticeshipId, EmployerAccountId = employerAccountId }); } return(RedirectToAction("Index", new { employerAccountId })); }