public bool IsNonPlascEstablishment(CheckingWindow checkingWindow, URN urn) { var school = GetByURN(checkingWindow, urn); var nfType = school.InstitutionTypeNumber; return(NonPlascNfTypes.Contains(nfType.GetValueOrDefault())); }
private string GetStatus(CheckingWindow checkingWindow, rscd_Amendment amendment) { // TODO: Branching on checking window is ugly - we need to refactor this class if (checkingWindow == CheckingWindow.KS4Late && amendment.rscd_Checkingwindow == rscd_Checkingwindow.KS4June) { switch (amendment.rscd_Outcome) { case rscd_Outcome.AwaitingDfEreview: case rscd_Outcome.AwaitingReviewer2: case rscd_Outcome.AwaitingReviewer3: return("Requested"); default: return(amendment.rscd_Outcome.ToString()); } } switch (amendment.rscd_Outcome) { case rscd_Outcome.Awaitingevidence: case rscd_Outcome.Cancelled: return(amendment.rscd_Outcome.ToString()); default: return("Requested"); } }
private bool ValidAmendmentForCheckingWindow(CheckingWindow checkingWindow, rscd_Amendment amendment) { switch (checkingWindow) { case CheckingWindow.KS4June: return(amendment.rscd_Checkingwindow == rscd_Checkingwindow.KS4June); case CheckingWindow.KS4Late: return(amendment.rscd_Checkingwindow == rscd_Checkingwindow.KS4June && new[] { rscd_Outcome.Approvedandfinal, rscd_Outcome.Rejectedandfinal, rscd_Outcome.Autoapproved, rscd_Outcome.Autorejected }.Any(s => s == amendment.rscd_Outcome) || amendment.rscd_Checkingwindow == rscd_Checkingwindow.KS4Late); case CheckingWindow.KS5: return(amendment.rscd_Checkingwindow == rscd_Checkingwindow.KS5); } return(false); }
public static string ToCheckingWindowLabel(CheckingWindow checkingWindow) { switch (checkingWindow) { case CheckingWindow.Unknown: break; case CheckingWindow.KS2: break; case CheckingWindow.KS2Errata: break; case CheckingWindow.KS4June: return("June"); case CheckingWindow.KS4Late: return("Sep"); case CheckingWindow.KS4Errata: break; case CheckingWindow.KS5: return("Sep"); case CheckingWindow.KS5Errata: break; default: break; } return(string.Empty); }
private Amendment Convert(CheckingWindow checkingWindow, rscd_Amendment amendment) { CurrentBuilder = RetrieveBuilderForAmendment(amendment.rscd_Amendmenttype); var amendmentDomain = CurrentBuilder.CreateAmendment(); amendmentDomain.Id = amendment.Id.ToString(); amendmentDomain.CheckingWindow = amendment.rscd_Checkingwindow.Value.ToDomainCheckingWindow(); amendmentDomain.Reference = amendment.rscd_Referencenumber; amendmentDomain.URN = amendment.rscd_URN; amendmentDomain.Pupil = new Pupil { Forename = amendment.rscd_Firstname, Surname = amendment.rscd_Lastname, Gender = amendment.rscd_Gender.Value.ToDomainGenderType(), DOB = amendment.rscd_Dateofbirth.Value, Age = amendment.rscd_Age.HasValue ? amendment.rscd_Age.Value : 0, AdmissionDate = amendment.rscd_Dateofadmission.GetValueOrDefault(), YearGroup = amendment.rscd_Yeargroup, UPN = amendment.rscd_UPN, ULN = amendment.rscd_ULN }; amendmentDomain.EvidenceStatus = amendment.rscd_Evidencestatus.Value.ToDomainEvidenceStatus(); amendmentDomain.CreatedDate = amendment.CreatedOn.Value; amendmentDomain.Status = GetStatus(checkingWindow, amendment); amendmentDomain.AmendmentDetail = GetAmendmentDetails(amendment); return(amendmentDomain); }
public static string GetCheckingWindowURL(CheckingWindow checkingWindow) { switch (checkingWindow) { case CheckingWindow.Unknown: break; case CheckingWindow.KS2: break; case CheckingWindow.KS2Errata: break; case CheckingWindow.KS4June: return("ks4-june"); case CheckingWindow.KS4Late: return("ks4-late"); case CheckingWindow.KS4Errata: break; case CheckingWindow.KS5: return("ks5"); case CheckingWindow.KS5Errata: break; } return(string.Empty); }
public string GetLeadText() { if (!ReviewChecked) { return("View your data before requesting amendments or confirming data."); } if (!DataConfirmed) { return("You can now request amendments or confirm data."); } var checkingWindow = CheckingWindow.ToString(); if (checkingWindow.StartsWith("KS2")) { return ($"You have confirmed your Key stage 2 data on {ConfirmationDate:dd/MM/yyyy}. You can continue to request further amendments until the end of the checking exercise window."); } if (checkingWindow.StartsWith("KS4")) { return ($"You have confirmed your Key stage 4 data on {ConfirmationDate:dd/MM/yyyy}. You can continue to request further amendments until the end of the checking exercise window."); } return ($"You have confirmed your data. You can continue to request further amendments until the end of the checking exercise window."); }
public PupilViewModel(Rscd.Web.ApiClient.Pupil pupil) { _pupil = pupil; ID = pupil.Id; Keystage = CheckingWindow.ToKeyStage(); URN = pupil.Urn; SchoolID = pupil.DfesNumber; UPN = pupil.Upn; ULN = pupil.Uln; FirstName = pupil.Forename; LastName = pupil.Surname; DateOfBirth = pupil.Dob.Date; Age = pupil.Age; Gender = pupil.Gender; DateOfAdmission = pupil.AdmissionDate?.Date; YearGroup = pupil.YearGroup; AllocationYears = GetAllocationYears(pupil.Allocations); Allocations = pupil.Allocations; PincludeCode = pupil.Pincl != null ? pupil.Pincl.Code : string.Empty; EthnicCodeGroup = pupil.Ethnicity; SEN = pupil.SpecialEducationNeed; FirstLanguage = pupil.FirstLanguage; FreeSchoolsInLast6Years = pupil.FreeSchoolMealsLast6Years; ChildrenLookedAfter = pupil.LookedAfterEver; PortlandStudendId = pupil.PortlandStudentID; }
public static string GetCheckingWindowDescription(CheckingWindow checkingWindow) { switch (checkingWindow) { case CheckingWindow.Unknown: break; case CheckingWindow.KS2: break; case CheckingWindow.KS2Errata: break; case CheckingWindow.KS4June: return("Key stage 4 June checking exercise"); case CheckingWindow.KS4Late: return("Key stage 4 Late results"); case CheckingWindow.KS4Errata: break; case CheckingWindow.KS5: return("16 to 18 September checking exercise"); case CheckingWindow.KS5Errata: break; } return(string.Empty); }
public static rscd_Checkingwindow ToCRMCheckingWindow(this CheckingWindow checkingwindow) { switch (checkingwindow) { case CheckingWindow.KS2: return(rscd_Checkingwindow.KS2); case CheckingWindow.KS2Errata: return(rscd_Checkingwindow.KS2Errata); case CheckingWindow.KS4June: return(rscd_Checkingwindow.KS4June); case CheckingWindow.KS4Late: return(rscd_Checkingwindow.KS4Late); case CheckingWindow.KS4Errata: return(rscd_Checkingwindow.KS4Errata); case CheckingWindow.KS5: return(rscd_Checkingwindow.KS5); case CheckingWindow.KS5Errata: return(rscd_Checkingwindow.KS5Errata); default: throw new ApplicationException(); } }
private rscd_Establishment GetOrCreateEstablishment(CheckingWindow checkingWindow, string id) { using (var context = new CrmServiceContext(_organizationService)) { var establishmentDto = context.rscd_EstablishmentSet.SingleOrDefault( e => e.rscd_URN == id); if (establishmentDto == null) { establishmentDto = context.rscd_EstablishmentSet.SingleOrDefault( e => e.rscd_LAEstab == id); } if (establishmentDto != null) { return(establishmentDto); } School establishment = null; try { establishment = _establishmentService.GetByURN(checkingWindow, new URN(id)); } catch { } if (establishment == null) { establishment = _establishmentService.GetByDFESNumber(checkingWindow, id); } if (establishment == null) { return(null); } establishmentDto = new rscd_Establishment() { rscd_Name = establishment.SchoolName, rscd_URN = establishment.Urn.Value, rscd_LAEstab = establishment.DfesNumber.ToString(), rscd_Schooltype = establishment.SchoolType, rscd_NumberofAmendments = 0 }; context.AddObject(establishmentDto); var result = context.SaveChanges(); if (result.HasError) { throw result.FirstOrDefault(e => e.Error != null)?.Error ?? new ApplicationException(); } return(establishmentDto); } }
private Amendment GetAmendment(CheckingWindow checkingWindow, Guid amendmentId) { using (var context = new CrmServiceContext(_organizationService)) { var amendment = context.rscd_AmendmentSet.FirstOrDefault( x => x.Id == amendmentId); return(amendment != null?Convert(checkingWindow, amendment) : null); } }
public IEnumerable <Amendment> GetAmendments(CheckingWindow checkingWindow, string urn) { using (var context = new CrmServiceContext(_organizationService)) { var amendments = context.rscd_AmendmentSet.Where(a => a.rscd_URN == urn).ToList(); return(amendments.Where(a => ValidAmendmentForCheckingWindow(checkingWindow, a)) .OrderByDescending(o => o.CreatedOn) .Select(x => Convert(checkingWindow, x))); } }
public Pupil GetById(CheckingWindow checkingWindow, string id) { var pupilDtos = _documentRepository .Get <PupilDTO>(GetCollection(checkingWindow)) .Where(x => x.id == id) .ToList(); if (pupilDtos.Any()) { return(GetPupil(checkingWindow, pupilDtos.First(), _allocationYear)); } return(null); }
public IActionResult Get( [FromRoute] [SwaggerParameter("The id of the pupil requesting amendments", Required = true)] string id, [FromRoute] [SwaggerParameter("The checking window to request pupil from", Required = true)] CheckingWindow checkingWindow) { var pupil = _pupilService.GetById(checkingWindow, id); var response = new GetResponse<Pupil> { Result = pupil, Error = new Error() }; return Ok(response); }
public IActionResult Delete([FromRoute][SwaggerParameter("The id of the amendment to cancel", Required = true)] string id, [FromRoute] [SwaggerParameter("The checking window to request amendments from", Required = false)] CheckingWindow checkingWindow) { var result = _amendmentService.CancelAmendment(id); var response = new GetResponse <bool> { Result = result, Error = new Error() }; return(Ok(response)); }
public IList <AmendmentReason> GetAmendmentReasons(CheckingWindow checkingWindow, AmendmentType amendmentType) { return(new List <AmendmentReason> { new AmendmentReason { Description = "Admitted following permanent exclusion from a maintained school", ReasonId = 10, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Admitted from abroad with English not first language", ReasonId = 8, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Deceased", ReasonId = 12, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Permanently left England", ReasonId = 11, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Dual registration", ReasonId = 13, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Other", ReasonId = 19, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Other - EAL exceptional circumstances", ReasonId = 1901, ParentReasonId = 19, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Other - Elective home education", ReasonId = 1902, ParentReasonId = 19, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Other - In prison/remand centre/secure unit", ReasonId = 1903, ParentReasonId = 19, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Other - Permanently excluded from this school", ReasonId = 1904, ParentReasonId = 19, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Other - Police involvement/bail restrictions", ReasonId = 1905, ParentReasonId = 19, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Other - Pupil missing in education", ReasonId = 1906, ParentReasonId = 19, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Other - Safeguarding/FAP", ReasonId = 1907, ParentReasonId = 19, AmendmentType = AmendmentType.RemovePupil }, new AmendmentReason { Description = "Other - Terminal/Long illness", ReasonId = 1908, ParentReasonId = 19, AmendmentType = AmendmentType.RemovePupil } }.Where(x => x.AmendmentType == amendmentType).ToList()); }
public IActionResult GetAmendment( [FromRoute][SwaggerParameter("The id of the requested amendment", Required = true)] string id, [FromRoute][SwaggerParameter("The checking window to request amendments from", Required = true)] CheckingWindow checkingWindow) { var amendment = _amendmentService.GetAmendment(checkingWindow, id); var response = new GetResponse <Amendment> { Result = amendment, Error = new Error() }; return(Ok(response)); }
public IActionResult RelateEvidence( [FromBody][SwaggerRequestBody("Amendment to add to CRM", Required = true)] string amendmentId, string evidenceFolderName, [FromRoute] [SwaggerParameter("The checking window to request amendments from", Required = false)] CheckingWindow checkingWindow) { _amendmentService.RelateEvidence(amendmentId, evidenceFolderName, true); var response = new GetResponse <bool> { Result = true, Error = new Error() }; return(Ok(response)); }
public IActionResult GetAmendmentReasons( [FromRoute][SwaggerParameter("The type of amendment", Required = true)] AmendmentType amendmentType, [FromRoute][SwaggerParameter("The checking window to request amendments from", Required = true)] CheckingWindow checkingWindow ) { var list = _dataService.GetAmendmentReasons(checkingWindow, amendmentType); var response = new GetResponse <IEnumerable <AmendmentReason> > { Result = list, Error = new Error() }; return(Ok(response)); }
public IActionResult Get( [FromRoute][SwaggerParameter("The URN of the school requesting amendments", Required = true)] string urn, [FromRoute][SwaggerParameter("The checking window to request amendments from", Required = true)] CheckingWindow checkingWindow) { var urnValue = new URN(urn); var establishmentData = _establishmentService.GetByURN(checkingWindow, urnValue); var response = new GetResponse <School> { Result = establishmentData, Error = new Error() }; return(Ok(response)); }
private School Get(Expression <Func <EstablishmentDTO, bool> > predicate, CheckingWindow checkingWindow) { var collectionName = $"{checkingWindow.ToString().ToLower()}_establishments_{_allocationYear}"; var establishmentDtos = _documentRepository .Get <EstablishmentDTO>(collectionName) .Where(predicate) .ToList(); if (establishmentDtos.Any()) { return(GetEstablishment(establishmentDtos.First())); } return(null); }
public IActionResult Search( [FromQuery] [SwaggerParameter("Pupil search criteria.", Required = true)] PupilsSearchRequest request, [FromRoute] [SwaggerParameter("The checking window to request pupil or pupils from", Required = true)] CheckingWindow checkingWindow) { if (!ModelState.IsValid) return BadRequest(ModelState); var pupils = _pupilService.QueryPupils(checkingWindow, request); var response = new GetResponse<IEnumerable<PupilRecord>> { Result = pupils, Error = new Error() }; return Ok(response); }
public string GetReviewedRowText() { var checkingWindow = CheckingWindow.ToString(); if (checkingWindow.StartsWith("KS2")) { return ($"You have confirmed your Key stage 2 data on {ConfirmationDate:dd/MM/yyyy}. You can continue to request further amendments until the end of the checking exercise window."); } if (checkingWindow.StartsWith("KS4")) { return ($"You have confirmed your Key stage 4 data on {ConfirmationDate:dd/MM/yyyy}. You can continue to request further amendments until the end of the checking exercise window."); } return ($"You have confirmed your 16 to 18 data on {ConfirmationDate:dd/MM/yyyy}. You can continue to request further amendments until the end of the checking exercise window."); }
public IActionResult GetAmendments( [FromRoute][SwaggerParameter("The URN of the school requesting amendments", Required = true)] string urn, [FromRoute][SwaggerParameter("The checking window to request amendments from", Required = true)] CheckingWindow checkingWindow) { var amendments = _amendmentService .GetAmendments(checkingWindow, urn) .ToList(); var response = new GetResponse <List <Amendment> > { Result = amendments, Error = new Error() }; return(Ok(response)); }
private string GetNavClass(CheckingWindow checkingWindow) { switch (checkingWindow) { case CheckingWindow.KS4Late: case CheckingWindow.KS5: return("app-ribbon-nav__list-item--tall"); case CheckingWindow.Unknown: case CheckingWindow.KS2: case CheckingWindow.KS2Errata: case CheckingWindow.KS4June: case CheckingWindow.KS4Errata: case CheckingWindow.KS5Errata: default: return(string.Empty); } }
private string GetPupilListLabel(CheckingWindow checkingWindow) { switch (checkingWindow) { case CheckingWindow.KS5: return("Student list"); case CheckingWindow.Unknown: case CheckingWindow.KS2: case CheckingWindow.KS2Errata: case CheckingWindow.KS4June: case CheckingWindow.KS4Late: case CheckingWindow.KS4Errata: case CheckingWindow.KS5Errata: default: return("Pupil list"); } }
private string GetSchoolPerformanceLabel(CheckingWindow checkingWindow) { switch (checkingWindow) { case CheckingWindow.KS4Late: case CheckingWindow.KS5: return("School performance<br>summary"); case CheckingWindow.Unknown: case CheckingWindow.KS2: case CheckingWindow.KS2Errata: case CheckingWindow.KS4June: case CheckingWindow.KS4Errata: case CheckingWindow.KS5Errata: default: return("School performance"); } }
public static Keystage ToKeyStage(this CheckingWindow checkingWindow) { var checkingWindowString = checkingWindow.ToString(); if (checkingWindowString.ToLower().StartsWith("ks2")) { return(Keystage.KS2); } if (checkingWindowString.ToLower().StartsWith("ks4")) { return(Keystage.KS4); } if (checkingWindowString.ToLower().StartsWith("ks5")) { return(Keystage.KS5); } return(Keystage.Unknown); }
public IActionResult Search( [FromQuery][SwaggerParameter("Event search criteria.", Required = true)] EstablishmentsSearchRequest request, [FromRoute][SwaggerParameter("The checking window to request amendments from", Required = true)] CheckingWindow checkingWindow) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var establishmentData = _establishmentService.GetByDFESNumber(checkingWindow, request.DFESNumber); var response = new GetResponse <School> { Result = establishmentData, Error = new Error() }; return(Ok(response)); }