public AddOrganisationViewModelValidator(IAddOrganisationValidator validator)
        {
            _validator = validator;

            RuleFor(vm => vm).Custom((vm, context) =>
            {
                var validationResult = _validator.ValidateOrganisationDetails(vm).Result;
                if (validationResult.IsValid)
                {
                    return;
                }
                foreach (var error in validationResult.Errors)
                {
                    context.AddFailure(error.Field, error.ErrorMessage);
                }
            });
        }
        public async Task <IActionResult> AddOrganisationPreview(AddOrganisationViewModel model)
        {
            model.OrganisationTypes = await _apiClient.GetOrganisationTypes(model.ProviderTypeId);

            model.ProviderTypes = await _apiClient.GetProviderTypes();

            var validationMessages = _validator.ValidateOrganisationDetails(model);

            if (validationMessages.Any())
            {
                model.ValidationErrors = new List <string>();
                model.ValidationErrors.AddRange(validationMessages);
                model.ProviderTypes = await _apiClient.GetProviderTypes();

                return(View("AddOrganisationDetails", model));
            }

            _sessionService.SetAddOrganisationDetails(model);

            return(View(model));
        }