public GovernanceController(IEstablishmentReadService establishmentReadService, IEstablishmentWriteService establishmentWriteService, IGroupsWriteService groupWriteService, LayoutHelper layoutHelper) { _establishmentReadService = establishmentReadService; _establishmentWriteService = establishmentWriteService; _groupWriteService = groupWriteService; _layoutHelper = layoutHelper; }
public DownloadsController(IDownloadsService downloadsService, IEstablishmentReadService establishmentReadService, IGroupDownloadService groupDownloadService, HttpClientWrapper httpClientHelper) { _downloadsService = downloadsService; _establishmentReadService = establishmentReadService; _groupDownloadService = groupDownloadService; _httpClientHelper = httpClientHelper; }
public EstablishmentsSearchController(IEstablishmentReadService establishmentReadService, IEstablishmentDownloadService establishmentDownloadService, ICachedLookupService lookupService) { _establishmentReadService = establishmentReadService; _establishmentDownloadService = establishmentDownloadService; _lookupService = lookupService; }
public ChangeHistoryController(IChangeHistoryService svc, ICachedLookupService lookupService, IEstablishmentReadService establishmentReadService, IGroupReadService groupReadService, IGroupDownloadService groupDownloadService) { _svc = svc; _lookupService = lookupService; _establishmentReadService = establishmentReadService; _groupReadService = groupReadService; _groupDownloadService = groupDownloadService; }
public AcademyOpeningsApiController(IEstablishmentReadService establishmentReadService, IEstablishmentWriteService establishmentWriteService, ICachedLookupService lookupService) { _establishmentReadService = establishmentReadService; _lookupService = lookupService; _establishmentWriteService = establishmentWriteService; }
public BulkCreateAcademiesApiController(IEstablishmentReadService establishmentReadService, IEstablishmentWriteService establishmentWriteService, ICachedLookupService lookupService) { _establishmentReadService = establishmentReadService; _lookupService = lookupService; _establishmentWriteService = establishmentWriteService; }
public AmalgamateMergeController(IEstablishmentReadService establishmentReadService, IEstablishmentWriteService establishmentWriteService, ICachedLookupService lookupService) { _establishmentReadService = establishmentReadService; _establishmentWriteService = establishmentWriteService; _lookupService = lookupService; }
public EditEstablishmentModelValidator(IEstablishmentReadService establishmentReadService) { When(x => x.ActionSpecifierParam == EditEstablishmentModel.ASSaveDetail, () => { RuleFor(x => x.EducationPhaseId) .Must((m, x) => !x.HasValue || (establishmentReadService.GetEstabType2EducationPhaseMap().AsInts()[m.TypeId.Value]).Contains(x.Value)) .WithMessage("Education phase is not valid for the selected type of establishment"); }); }
public ToolsController(ISecurityService securityService, IEstablishmentReadService establishmentReadService, ICachedLookupService lookup, IClientStorage clientStorage, ILocalAuthoritySetRepository localAuthoritySetRepository, IEstablishmentDownloadService establishmentDownloadService) { _securityService = securityService; _establishmentReadService = establishmentReadService; _lookup = lookup; _clientStorage = clientStorage; _localAuthoritySetRepository = localAuthoritySetRepository; _establishmentDownloadService = establishmentDownloadService; }
public EstablishmentsSearchController(IEstablishmentReadService establishmentReadService, IEstablishmentDownloadService establishmentDownloadService, ICachedLookupService lookupService, IUserPreferenceRepository userPreferenceRepository) { _establishmentReadService = establishmentReadService; _establishmentDownloadService = establishmentDownloadService; _lookupService = lookupService; _userPreferenceRepository = userPreferenceRepository; }
public SitemapController(IEstablishmentReadService establishmentReadService, IGroupReadService groupReadService, ICacheAccessor cacheAccessor, ICachedLookupService lookupService) { _establishmentReadService = establishmentReadService; _groupReadService = groupReadService; _cacheAccessor = cacheAccessor; _lookupService = lookupService; }
public SearchController(IEstablishmentReadService establishmentReadService, ICachedLookupService cachedLookupService, IGroupReadService groupReadService, IPlacesLookupService placesService) { _placesService = placesService; _cachedLookupService = cachedLookupService; _establishmentReadService = establishmentReadService; _groupReadService = groupReadService; }
public LayoutHelper( NomenclatureService nomenclatureService, IGroupReadService groupReadService, IEstablishmentReadService establishmentReadService, ICachedLookupService cls) { _nomenclatureService = nomenclatureService; _establishmentReadService = establishmentReadService; _groupReadService = groupReadService; _cls = cls; }
public GovernorSearchController(IGovernorDownloadService governorDownloadService, IGovernorsReadService governorsReadService, ICachedLookupService cachedLookupService, IGroupReadService groupReadService, IEstablishmentReadService establishmentReadService) { _governorDownloadService = governorDownloadService; _governorsReadService = governorsReadService; _cachedLookupService = cachedLookupService; _establishmentReadService = establishmentReadService; _groupReadService = groupReadService; }
public GovernorController( IGovernorsReadService governorsReadService, NomenclatureService nomenclatureService, ICachedLookupService cachedLookupService, IGovernorsWriteService governorsWriteService, IGroupReadService groupReadService, IEstablishmentReadService establishmentReadService, ILayoutHelper layoutHelper) { _governorsReadService = governorsReadService; _nomenclatureService = nomenclatureService; _cachedLookupService = cachedLookupService; _governorsWriteService = governorsWriteService; _groupReadService = groupReadService; _establishmentReadService = establishmentReadService; _layoutHelper = layoutHelper; }
public GroupController( ICachedLookupService cachedLookupService, ISecurityService securityService, IGroupReadService groupReadService, IEstablishmentReadService establishmentReadService, IGroupsWriteService groupWriteService, ICompaniesHouseService companiesHouseService, NomenclatureService nomenclatureService) { _lookup = cachedLookupService; _securityService = securityService; _groupReadService = groupReadService; _establishmentReadService = establishmentReadService; _groupWriteService = groupWriteService; _companiesHouseService = companiesHouseService; _nomenclatureService = nomenclatureService; }
public CreateEstablishmentViewModelValidator(IEstablishmentReadService establishmentReadService) { RuleFor(x => x.Name).NotEmpty().WithMessage("Please enter an establishment name"); RuleFor(x => x.LocalAuthorityId).NotEmpty().WithMessage("Please select a local authority"); RuleFor(x => x.EducationPhaseId) .Cascade(CascadeMode.StopOnFirstFailure) .NotNull().WithMessage("Please select a a phase of education") .NotEmpty().WithMessage("Please select a a phase of education") .Must((m, x) => establishmentReadService.GetEstabType2EducationPhaseMap().AsInts()[m.EstablishmentTypeId].Contains(x.Value)) .WithMessage("Education phase is not valid for the selected type of establishment"); RuleFor(x => x.EstablishmentTypeId).NotEmpty().WithMessage("Please select an establishment type"); RuleFor(x => x.GenerateEstabNumber).NotNull().WithMessage("Please select 'Generate number' or 'Enter number'"); RuleFor(x => x.EstablishmentNumber) .NotEmpty().WithMessage("Please enter an establishment number") .When(x => x.GenerateEstabNumber.HasValue && !x.GenerateEstabNumber.GetValueOrDefault()); }
public SearchForEstablishmentViewModelValidator(IEstablishmentReadService establishmentReadService, IPrincipal principal) { RuleFor(x => x.SearchUrn) .Cascade(CascadeMode.StopOnFirstFailure) .Must(x => x.ToInteger().HasValue) .WithMessage("Please enter a valid URN") .Must((vm, x) => x.ToInteger() != vm.Urn) .WithMessage("Establishment cannot link to itself") .MustAsync(async(vm, x, ct) => { var links = await establishmentReadService.GetLinkedEstablishmentsAsync(vm.Urn.Value, principal); return(links.All(a => a.Urn != x.ToInteger())); }).WithMessage("This URN is already linked to this establishment") .MustAsync(async(vm, x, ct) => (await establishmentReadService.GetAsync(x.ToInteger().Value, principal)).ReturnValue != null) .WithMessage("Establishment not found"); }
public EstablishmentApiController(IEstablishmentReadService establishmentReadService) { _establishmentReadService = establishmentReadService; }
public CreateChildrensCentreViewModelValidator(IEstablishmentReadService establishmentReadService) { RuleFor(x => x.Name).NotEmpty().WithMessage("Please enter an establishment name"); RuleFor(x => x.LocalAuthorityId).NotEmpty().WithMessage("Please select a local authority"); RuleFor(x => x.EducationPhaseId) .Cascade(CascadeMode.StopOnFirstFailure) .NotNull().WithMessage("Please select a a phase of education") .NotEmpty().WithMessage("Please select a a phase of education") .Must((m, x) => establishmentReadService.GetEstabType2EducationPhaseMap().AsInts()[m.EstablishmentTypeId].Contains(x.Value)) .WithMessage("Education phase is not valid for the selected type of establishment") .When(x => x.EstablishmentTypeId != 41); RuleFor(x => x.EstablishmentTypeId) .NotEmpty() .WithMessage("Please select an establishment type"); RuleFor(x => x.GenerateEstabNumber) .NotNull() .WithMessage("Please select 'Generate number' or 'Enter number'") .When(x => x.EstablishmentTypeId != 41); RuleFor(x => x.EstablishmentNumber) .NotEmpty().WithMessage("Please enter an establishment number") .When(x => x.GenerateEstabNumber.HasValue && !x.GenerateEstabNumber.GetValueOrDefault()); When(x => x.EstablishmentTypeId == 41, () => { RuleFor(x => x.OpenDate) .Must(x => x.IsValid() && x.IsNotEmpty()) .WithMessage("Please enter the date of opening"); RuleFor(x => x.Address.Line1) .Must(x => !string.IsNullOrWhiteSpace(x)) .WithMessage("Please enter the street"); RuleFor(x => x.Address.CityOrTown) .Must(x => !string.IsNullOrWhiteSpace(x)) .WithMessage("Please enter the town"); RuleFor(x => x.Address.County) .Must(x => x != null) .WithMessage("Please select the county"); RuleFor(x => x.Address.PostCode) .Must(x => !string.IsNullOrWhiteSpace(x)) .WithMessage("Please enter the postcode"); RuleFor(x => x.ManagerFirstName) .Must(x => !string.IsNullOrWhiteSpace(x)) .WithMessage("Please enter the manager first name"); RuleFor(x => x.ManagerLastName) .Must(x => !string.IsNullOrWhiteSpace(x)) .WithMessage("Please enter the manager last name"); RuleFor(x => x.CentreEmail) .Must(x => !string.IsNullOrWhiteSpace(x)) .WithMessage("Please enter the manager email"); RuleFor(x => x.Telephone) .Must(x => !string.IsNullOrWhiteSpace(x)) .WithMessage("Please enter the telephone"); RuleFor(x => x.OperationalHoursId) .Must(x => x != null) .WithMessage("Please select the operational hours"); RuleFor(x => x.NumberOfUnderFives) .Must(x => x != null) .WithMessage("Please enter the number of under 5s"); RuleFor(x => x.GovernanceId) .Must(x => x != null) .WithMessage("Please select the governance type"); RuleFor(x => x.DisadvantagedAreaId) .Must(x => x != null) .WithMessage("Please select a disadvantaged area option"); RuleFor(x => x.DirectProvisionOfEarlyYears) .Must(x => x != null) .WithMessage("Please select a direct provision of early years option"); RuleFor(x => x.GovernanceDetail) .Must(x => !string.IsNullOrWhiteSpace(x)) .WithMessage("Please enter governance detail"); }); }
public GroupEditorViewModelValidator(IGroupReadService groupReadService, IEstablishmentReadService establishmentReadService, IPrincipal principal, ISecurityService securityService) { _groupReadService = groupReadService; _establishmentReadService = establishmentReadService; CascadeMode = CascadeMode.StopOnFirstFailure; // Searching for an establishment to link.... When(x => x.Action == ActionLinkedEstablishmentSearch, () => { RuleFor(x => x.LinkedEstablishments.LinkedEstablishmentSearch.Urn) .Cascade(CascadeMode.StopOnFirstFailure) .Must(x => x.IsInteger()) .WithMessage("Please enter a valid URN") .WithSummaryMessage("The supplied URN is not valid") .Must((model, x) => !model.LinkedEstablishments.Establishments.Select(e => e.Urn).Contains(x.ToInteger().Value)) .WithMessage("This establishment is already in this group. Please enter a different URN") .WithSummaryMessage("This establishment is already in this group. Please enter a different URN") .MustAsync(async(x, ct) => { return((await _establishmentReadService.GetAsync(x.ToInteger().Value, principal).ConfigureAwait(false)).ReturnValue != null); }).WithMessage("The establishment was not found").WithSummaryMessage("The establishment was not found"); }); // Having found an establishment to link, validate the joined date if supplied... When(x => x.Action == ActionLinkedEstablishmentAdd, () => { RuleFor(x => x.LinkedEstablishments.LinkedEstablishmentSearch.JoinedDate) .Must(x => x.IsValid()) .WithMessage("This is not a valid date") .WithSummaryMessage("The Joined Date specified is not valid") .Must((model, joinDate) => VerifyJoinedDate(joinDate.ToDateTime(), model)) .WithMessage("The join date you entered is before the {0}'s open date of {1}. Please enter a later date.", m => m.GroupType, m => m.OpenDate); }); // Having edited a joined date, validate the date... When(x => x.Action == ActionLinkedEstablishmentSave, () => { RuleFor(x => x.LinkedEstablishments.Establishments.Single(e => e.EditMode).JoinedDateEditable).Must(x => x.IsValid()) .WithMessage("This is not a valid date") .WithSummaryMessage("The Joined Date specified is not valid") .Must((model, joinDate) => VerifyJoinedDate(joinDate.ToDateTime(), model)) .WithMessage("The join date you entered is before the {0}'s open date of {1}. Please enter a later date.", m => m.GroupType, m => m.OpenDate); }); // On saving the group record.... When(x => x.Action == ActionSave, () => { When(m => m.GroupTypeMode == eGroupTypeMode.ChildrensCentre, () => { RuleFor(x => x.LocalAuthorityId).NotNull() .WithMessage("This field is mandatory") .WithSummaryMessage("Please select a local authority for the group") .When(x => x.SaveGroupDetail); }); RuleFor(x => x.GroupTypeId).NotNull().WithMessage("Group Type must be supplied"); RuleFor(x => x.OpenDate) .Must(x => !x.IsEmpty()) .WithMessage("{0} missing. Please enter the date", x => x.OpenDateLabel) .When(x => !x.GroupUId.HasValue, ApplyConditionTo.CurrentValidator) .Must(x => x.IsValid() || x.IsEmpty()) .WithMessage("{0} is invalid. Please enter a valid date", x => x.OpenDateLabel); RuleFor(x => x.GroupName) .Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty() .WithMessage("Please enter the {0} name", x => x.FieldNamePrefix.ToLower()) .When(x => x.SaveGroupDetail); RuleFor(x => x.GroupId) .Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty() .WithMessage("This field is mandatory") .WithSummaryMessage("Please enter a Group ID") .MustAsync(async(model, groupId, ct) => !(await _groupReadService.ExistsAsync(securityService.CreateAnonymousPrincipal(), groupId: groupId, existingGroupUId: model.GroupUId))) .WithMessage("Group ID already exists. Enter a different group ID.") .When(x => x.GroupTypeMode.OneOfThese(eGroupTypeMode.AcademyTrust, eGroupTypeMode.Sponsor) && x.SaveGroupDetail, ApplyConditionTo.AllValidators); RuleForEach(x => x.LinkedEstablishments.Establishments) .Must((model, estab) => VerifyJoinedDate(estab.JoinedDateEditable.ToDateTime() ?? estab.JoinedDate, model)) .When(x => x.OpenDate.ToDateTime().Value.Date == DateTime.Now.Date) .WithMessage("The join date you entered is before today. Please enter a later date.") .WithSummaryMessage("The join date you entered is before today. Please enter a later date.") .Must((model, estab) => VerifyJoinedDate(estab.JoinedDateEditable.ToDateTime() ?? estab.JoinedDate, model)) .When(x => x.OpenDate.ToDateTime().Value.Date != DateTime.Now.Date) .WithMessage("The join date you entered is before the {0}'s open date of {1}. Please enter a later date.", m => m.GroupType, m => m.OpenDate); }); }
public EstablishmentApiController(IEstablishmentReadService establishmentReadService, ICachedLookupService lookupService) { _establishmentReadService = establishmentReadService; _lookupService = lookupService; }
public GroupEditorViewModelValidator(IGroupReadService groupReadService, IEstablishmentReadService establishmentReadService, IPrincipal principal, ISecurityService securityService) { _groupReadService = groupReadService; _establishmentReadService = establishmentReadService; CascadeMode = CascadeMode.StopOnFirstFailure; // Searching for an establishment to link.... When(x => x.Action == ActionLinkedEstablishmentSearch, () => { RuleFor(x => x.LinkedEstablishments.LinkedEstablishmentSearch.Urn) .Cascade(CascadeMode.StopOnFirstFailure) .Must(x => x.IsInteger()) .WithMessage("Please enter a valid URN") .WithSummaryMessage("The supplied URN is not valid") .Must((model, x) => !model.LinkedEstablishments.Establishments.Select(e => e.Urn).Contains(x.ToInteger().Value)) .WithMessage("This establishment is already in this group. Please enter a different URN") .WithSummaryMessage("This establishment is already in this group. Please enter a different URN") .MustAsync(async(x, ct) => { return((await _establishmentReadService.GetAsync(x.ToInteger().Value, principal).ConfigureAwait(false)).ReturnValue != null); }).WithMessage("The establishment was not found").WithSummaryMessage("The establishment was not found"); }); // Having found an establishment to link, validate the joined date if supplied... When(x => x.Action == ActionLinkedEstablishmentAdd, () => { RuleFor(x => x.LinkedEstablishments.LinkedEstablishmentSearch.JoinedDate) .Must(x => x.IsValid()) .WithMessage("This is not a valid date") .WithSummaryMessage("The Joined Date specified is not valid") .Must((model, joinDate) => VerifyJoinedDate(joinDate.ToDateTime(), model)) .WithMessage(x => $"The join date you entered is before the {x.GroupType}'s open date of {x.OpenDate}. Please enter a later date."); }); // Having edited a joined date, validate the date... When(x => x.Action == ActionLinkedEstablishmentSave, () => { RuleFor(x => x.LinkedEstablishments.Establishments.Single(e => e.EditMode).JoinedDateEditable).Must(x => x.IsValid()) .WithMessage("This is not a valid date") .WithSummaryMessage("The Joined Date specified is not valid") .Must((model, joinDate) => VerifyJoinedDate(joinDate.ToDateTime(), model)) .WithMessage(x => $"The join date you entered is before the {x.GroupType}'s open date of {x.OpenDate}. Please enter a later date."); }); // On getting to the save page.... When(x => x.Action == ActionSave || x.Action == ActionDetails, () => { When(m => m.GroupTypeMode == eGroupTypeMode.ChildrensCentre, () => { RuleFor(x => x.LocalAuthorityId).NotNull() .WithMessage("This field is mandatory") .WithSummaryMessage("Please select a local authority for the group") .When(x => x.SaveGroupDetail); }); RuleFor(x => x.GroupTypeId).NotNull().WithMessage("Group Type must be supplied"); RuleFor(x => x.OpenDate) .Must(x => !x.IsEmpty()) .WithMessage(x => $"{x.OpenDateLabel} missing. Please enter the date") .When(x => !x.GroupUId.HasValue, ApplyConditionTo.CurrentValidator) .Must(x => x.IsValid() || x.IsEmpty()) .WithMessage(x => $"{x.OpenDateLabel} is invalid. Please enter a valid date"); When(x => x.CanUserEditClosedDate && x.GroupType == eLookupGroupType.MultiacademyTrust && x.OriginalStatusId != (int)eLookupGroupStatus.Closed && x.StatusId == (int)eLookupGroupStatus.Closed && x.SaveGroupDetail, () => { RuleFor(x => x.ClosedDate) .Must(x => !x.IsEmpty()) .WithMessage("Please enter a date for the closure of this multi-academy trust") .Must(x => x.IsValid() || x.IsEmpty()) .WithMessage("Closed date is invalid. Please enter a valid date."); }); RuleFor(x => x.GroupName) .Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty() .WithMessage(x => $"Please enter the {x.FieldNamePrefix.ToLower()} name") .When(x => x.SaveGroupDetail); RuleFor(x => x.GroupId) .Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty() .WithMessage("Please enter a Group ID") .WithSummaryMessage("Please enter a Group ID") .MustAsync(async(model, groupId, ct) => !(await _groupReadService.ExistsAsync(securityService.CreateAnonymousPrincipal(), groupId: groupId, existingGroupUId: model.GroupUId))) .WithMessage("Group ID already exists. Enter a different group ID.") .When(x => x.GroupTypeMode.OneOfThese(eGroupTypeMode.AcademyTrust, eGroupTypeMode.Sponsor) && x.SaveGroupDetail, ApplyConditionTo.AllValidators); When(x => x.OpenDate.ToDateTime().HasValue, () => { RuleForEach(x => x.LinkedEstablishments.Establishments) .Must((model, estab) => VerifyJoinedDate(estab.JoinedDateEditable.ToDateTime() ?? estab.JoinedDate, model)) .When(x => x.OpenDate.ToDateTime().GetValueOrDefault().Date == DateTime.Now.Date) .WithMessage("The join date you entered is before today. Please enter a later date.") .WithSummaryMessage("The join date you entered is before today. Please enter a later date.") .Must((model, estab) => VerifyJoinedDate(estab.JoinedDateEditable.ToDateTime() ?? estab.JoinedDate, model)) .When(x => x.OpenDate.ToDateTime().GetValueOrDefault().Date != DateTime.Now.Date) .WithMessage(x => $"The join date you entered is before the {x.GroupType}'s open date of {x.OpenDate}. Please enter a later date."); }); }); // Specific addition only triggered upon Saving ChildrensCentres through the creation tool When(x => x.Action == ActionSave && x.ActionName == eChildrensCentreActions.Step3, () => { When(m => m.GroupTypeMode == eGroupTypeMode.ChildrensCentre, () => { RuleFor(x => x.LinkedEstablishments.Establishments) .Must(x => x.Count >= 2) .WithMessage("Add more centres to the group") .WithSummaryMessage("You need to add at least two centres"); }); }); }
public SearchApiController(IEstablishmentReadService establishmentReadService, ITokenRepository tokenRepository) { _establishmentReadService = establishmentReadService; _tokenRepository = tokenRepository; }
public GovernorsReadApiService(HttpClientWrapper httpClient, IEstablishmentReadService establishmentReadService) { _httpClient = httpClient; _establishmentReadService = establishmentReadService; }
public EstablishmentWriteApiService(HttpClientWrapper httpClient, IEstablishmentReadService establishmentReadService) { _httpClient = httpClient; _establishmentReadService = establishmentReadService; }
public DownloadsController(IDownloadsService downloadsService, IEstablishmentReadService establishmentReadService, IGroupDownloadService groupDownloadService) { _downloadsService = downloadsService; _establishmentReadService = establishmentReadService; _groupDownloadService = groupDownloadService; }