public async Task <IActionResult> DeleteVenue(Guid venueId) => await _mediator.SendAndMapResponse( new Query { VenueId = venueId, ProviderId = _providerContextProvider.GetProviderContext().ProviderInfo.ProviderId }, vm => View(vm));
public Task <IActionResult> DeleteVenue(Guid venueId) => _mediator.SendAndMapResponse( new Query { VenueId = venueId, ProviderId = _providerContextProvider.GetProviderContext().ProviderInfo.ProviderId }, r => r.Match <IActionResult>( _ => NotFound(), vm => View(vm)));
public async Task <IActionResult> Upload(Upload.Command command) { var file = Request.Form.Files?.GetFile(nameof(command.File)); return(await _mediator.SendAndMapResponse( new Upload.Command() { File = file }, response => response.Match( errors => RedirectToAction(nameof(Validation)) .WithProviderContext(_providerContextProvider.GetProviderContext()), success => RedirectToAction(nameof(CheckAndPublish))) .WithProviderContext(_providerContextProvider.GetProviderContext()))); }
public IActionResult LandingOptions(CoursesLandingViewModel model) { switch (model.CoursesLandingOptions) { case CoursesLandingOptions.Add: { if (_featureFlagProvider.HaveFeature(FeatureFlags.CoursesChooseQualification)) { return(RedirectToAction("ChooseQualification", "ChooseQualification").WithProviderContext(_providerContextProvider.GetProviderContext(withLegacyFallback: true)));; } else { return(RedirectToAction("Index", "RegulatedQualification")); } } case CoursesLandingOptions.Upload: return(RedirectToAction("Index", "CoursesDataManagement") .WithProviderContext(_providerContextProvider.GetProviderContext(withLegacyFallback: true))); case CoursesLandingOptions.View: return(RedirectToAction("Index", "ProviderCourses")); default: return(RedirectToAction("LandingOptions", "Qualifications")); } }
public async Task <Response> Handle(Query request, CancellationToken cancellationToken) { var providerContext = _providerContextProvider.GetProviderContext(); var courses = await _sqlQueryDispatcher.ExecuteQuery(new GetCoursesForProvider() { ProviderId = providerContext.ProviderInfo.ProviderId }); var allRegions = await _regionCache.GetAllRegions(); var rows = courses.OrderBy(x => x.LearnAimRef) .ThenBy(x => x.CourseId) .SelectMany(course => CsvCourseRow.FromModel(course, allRegions)) .ToList(); var fileName = FileNameHelper.SanitizeFileName( $"{providerContext.ProviderInfo.ProviderName}_courses_{_clock.UtcNow:yyyyMMddHHmm}.csv"); return(new Response() { FileName = fileName, Rows = rows }); }
protected override Task HandleRequirementAsync( AuthorizationHandlerContext context, ProviderTypeRequirement requirement) { var providerContext = _providerContextProvider.GetProviderContext(); if (providerContext == null) { context.Fail(); return(Task.CompletedTask); } var providerType = providerContext.ProviderInfo.ProviderType; if ((providerType & requirement.ProviderType) != 0) { context.Succeed(requirement); } else { context.Fail(); } return(Task.CompletedTask); }
public async Task <Response> Handle(Query request, CancellationToken cancellationToken) { var providerContext = _providerContextProvider.GetProviderContext(); var apprenticeships = await _sqlQueryDispatcher.ExecuteQuery(new GetApprenticeshipsForProvider() { ProviderId = providerContext.ProviderInfo.ProviderId }); var allRegions = await _regionCache.GetAllRegions(); var rows = apprenticeships .OrderBy(x => x.Standard.StandardCode) .ThenBy(x => x.Standard.Version) .SelectMany(app => CsvApprenticeshipRow.FromModel(app, allRegions)) .ToList(); var fileName = FileNameHelper.SanitizeFileName( $"{providerContext.ProviderInfo.ProviderName}_apprenticeships_{_clock.UtcNow:yyyyMMddHHmm}.csv"); return(new Response() { FileName = fileName, Rows = rows }); }
public async Task <IViewComponentResult> InvokeAsync() { var providerId = _providerContextProvider.GetProviderContext().ProviderInfo.ProviderId; var qaStatus = await _sqlQueryDispatcher.ExecuteQuery( new GetProviderApprenticeshipQAStatus() { ProviderId = providerId }); var submission = await _sqlQueryDispatcher.ExecuteQuery( new GetLatestApprenticeshipQASubmissionForProvider() { ProviderId = providerId }); var providerInfo = await _providerInfoCache.GetProviderInfo(providerId); var vm = new QANotificationsViewModel() { ProviderType = providerInfo.ProviderType, Status = qaStatus.ValueOrDefault(), HidePassedNotication = submission.Match(none => qaStatus == ApprenticeshipQAStatus.Passed, sub => sub.HidePassedNotification) }; return(View("~/Features/NewApprenticeshipProvider/QANotifications.cshtml", vm)); }
public async Task <Success> Handle(Command request, CancellationToken cancellationToken) { ThrowIfFlowStateNotValid(); var journeyInstance = _journeyInstanceProvider.GetInstance <AddVenueJourneyModel>(); var venueId = Guid.NewGuid(); var providerUkprn = _providerContextProvider.GetProviderContext().ProviderInfo.Ukprn; await _cosmosDbQueryDispatcher.ExecuteQuery(new CreateVenue() { VenueId = venueId, ProviderUkprn = providerUkprn, Name = journeyInstance.State.Name, Email = journeyInstance.State.Email, Telephone = journeyInstance.State.Telephone, Website = journeyInstance.State.Website, AddressLine1 = journeyInstance.State.AddressLine1, AddressLine2 = journeyInstance.State.AddressLine2, Town = journeyInstance.State.Town, County = journeyInstance.State.County, Postcode = journeyInstance.State.Postcode, Latitude = journeyInstance.State.Latitude, Longitude = journeyInstance.State.Longitude, CreatedBy = _currentUserProvider.GetCurrentUser(), CreatedDate = _clock.UtcNow }); journeyInstance.UpdateState(state => state.VenueId = venueId); // Complete JourneyInstance so state can no longer be changed journeyInstance.Complete(); return(new Success()); }
public EditProviderTypeController( IMediator mediator, ICurrentUserProvider currentUserProvider, IProviderContextProvider providerContextProvider) { _mediator = mediator; _currentUserProvider = currentUserProvider; _providerContext = providerContextProvider.GetProviderContext(); }
public AddTLevelController( JourneyInstanceProvider JourneyInstanceProvider, IMediator mediator, IProviderContextProvider providerContextProvider) { _journeyInstanceProvider = JourneyInstanceProvider; _mediator = mediator; _journeyInstance = JourneyInstanceProvider.GetInstance <AddTLevelJourneyModel>(); _providerContext = providerContextProvider.GetProviderContext(); }
public Task <IActionResult> Post( Guid tLevelId, [FromServices] IProviderContextProvider providerContextProvider, Command request) => _mediator.SendAndMapResponse( request, response => response.Match <IActionResult>( errors => this.ViewFromErrors(errors), vm => RedirectToAction(nameof(Deleted), new { tLevelId }) .WithProviderContext(providerContextProvider.GetProviderContext())));
public async Task <IActionResult> Save(Guid venueId, Save.Command command) { command.VenueId = venueId; return(await _mediator.SendAndMapResponse( command, success => { TempData[TempDataKeys.UpdatedVenueId] = venueId; return RedirectToAction("ViewVenues", "ViewVenues").WithProviderContext(_providerContextProvider.GetProviderContext()); })); }
public IActionResult Index([FromQuery] string postcode, [FromQuery] string returnUrl) { var journeyInstance = _journeyInstanceProvider.GetOrCreateInstance( () => new AddVenueJourneyModel(), new PropertiesBuilder() .Add(ReturnUrlJourneyInstancePropertyKey, returnUrl) .Build()); if (!_journeyInstanceProvider.IsCurrentInstance(journeyInstance)) { return(RedirectToAction() .WithProviderContext(_providerContextProvider.GetProviderContext()) .WithJourneyInstanceUniqueKey(journeyInstance)); } return(View( nameof(PostcodeSearch), new PostcodeSearch.SearchCommand() { Postcode = postcode })); }
public async Task <ViewModel> Handle(Query request, CancellationToken cancellationToken) { var providerContext = _providerContextProvider.GetProviderContext(); var counts = await _sqlQueryDispatcher.ExecuteQuery(new GetProviderDashboardCounts() { ProviderId = providerContext.ProviderInfo.ProviderId, Date = _clock.UtcNow.Date }); var qaStatus = await _sqlQueryDispatcher.ExecuteQuery( new GetProviderApprenticeshipQAStatus() { ProviderId = providerContext.ProviderInfo.ProviderId, }); var providerType = providerContext.ProviderInfo.ProviderType; var venueUploadStatus = await _sqlQueryDispatcher.ExecuteQuery( new GetLatestUnpublishedVenueUploadForProvider() { ProviderId = providerContext.ProviderInfo.ProviderId }); var courseUploadStatus = await _sqlQueryDispatcher.ExecuteQuery( new GetLatestUnpublishedCourseUploadForProvider() { ProviderId = providerContext.ProviderInfo.ProviderId }); var apprenticeshipUploadStatus = await _sqlQueryDispatcher.ExecuteQuery( new GetLatestUnpublishedApprenticeshipUploadForProvider() { ProviderId = providerContext.ProviderInfo.ProviderId }); return(new ViewModel() { PublishedApprenticeshipsCount = counts.ApprenticeshipCounts.GetValueOrDefault(ApprenticeshipStatus.Live, 0), PublishedCourseCount = counts.CourseRunCount, PublishedVenueCount = counts.VenueCount, ShowApprenticeships = providerType.HasFlag(ProviderType.Apprenticeships) && qaStatus == ApprenticeshipQAStatus.Passed, ShowCourses = providerType.HasFlag(ProviderType.FE), VenueUploadInProgress = venueUploadStatus != null && (venueUploadStatus.UploadStatus == UploadStatus.Processing || venueUploadStatus.UploadStatus == UploadStatus.Created), UnpublishedVenueCount = counts.UnpublishedVenueCount, UnpublishedCourseCount = counts.UnpublishedCourseCount, CourseUploadInProgress = courseUploadStatus != null && (courseUploadStatus.UploadStatus == UploadStatus.Processing || courseUploadStatus.UploadStatus == UploadStatus.Created), ApprenticeshipUploadInProgress = apprenticeshipUploadStatus != null && (apprenticeshipUploadStatus.UploadStatus == UploadStatus.Processing || apprenticeshipUploadStatus.UploadStatus == UploadStatus.Created), UnpublishedApprenticeshipCount = counts.UnpublishedApprenticeshipCount }); }
public async Task <IActionResult> AddAnotherLocation( Guid tLevelId, Save.Command command) { await _mediator.Send(command); return(RedirectToAction( "Index", "AddVenue", new { returnUrl = Url.Action( nameof(Edit), new { tLevelId, ffiid = _journeyInstance.InstanceId.UniqueKey }) }) .WithProviderContext(_providerContextProvider.GetProviderContext())); }
public IActionResult AddNewVenue(CourseRunRequestModel model) { EditCourseRunViewModel vm = new EditCourseRunViewModel { AwardOrgCode = model.AwardOrgCode, LearnAimRef = model.LearnAimRef, LearnAimRefTitle = model.LearnAimRefTitle, NotionalNVQLevelv2 = model.NotionalNVQLevelv2, Mode = model.Mode, CourseId = model.CourseId, CourseRunId = model.CourseRunId, CourseName = model.CourseName, //Venues = availableVenues VenueId = model.VenueId, //SelectRegion = regions, DeliveryMode = model.DeliveryMode, CourseProviderReference = model.CourseProviderReference, DurationUnit = model.DurationUnit, DurationLength = model.DurationLength.ToString(), StartDateType = model.StartDateType.ToUpper() == "SPECIFIEDSTARTDATE" ? StartDateType.SpecifiedStartDate : StartDateType.FlexibleStartDate, Day = model.Day, Month = model.Month, Year = model.Year, StudyMode = model.StudyMode, Url = model.Url, Cost = model.Cost.ToString(), CostDescription = model.CostDescription, AttendanceMode = model.AttendanceMode, }; Session.SetObject("EditCourseRunObject", vm); return(Json(new Url(Url.Action("Index", "AddVenue", new { returnUrl = Url.Action("Reload", "EditCourseRun") })) .WithProviderContext(_providerContextProvider.GetProviderContext(withLegacyFallback: true)) .ToString())); }
public async Task <Response> Handle(Query request, CancellationToken cancellationToken) { var providerContext = _providerContextProvider.GetProviderContext(); var venues = await _sqlQueryDispatcher.ExecuteQuery(new GetVenuesForProvider() { ProviderId = providerContext.ProviderInfo.ProviderId }); var rows = venues .OrderBy(v => v.ProviderVenueRef) .ThenBy(v => v.VenueName) .Select(VenueRow.FromModel) .ToList(); var fileName = FileNameHelper.SanitizeFileName( $"{providerContext.ProviderInfo.ProviderName}_venues_{_clock.UtcNow:yyyyMMddHHmm}.csv"); return(new Response() { FileName = fileName, Rows = rows }); }
public async Task <Response> Handle(Query request, CancellationToken cancellationToken) { var providerContext = _providerContextProvider.GetProviderContext(); var(uploadRows, uploadStatus) = await _fileUploadProcessor.GetCourseUploadRowsForProvider(providerContext.ProviderInfo.ProviderId); if (uploadStatus != UploadStatus.ProcessedWithErrors) { throw new InvalidUploadStatusException(uploadStatus, UploadStatus.ProcessedWithErrors); } var rows = uploadRows .Select(CsvCourseRowWithErrors.FromModel) .ToList(); var fileName = FileNameHelper.SanitizeFileName( $"{providerContext.ProviderInfo.ProviderName}_courses_errors_{_clock.UtcNow:yyyyMMddHHmm}.csv"); return(new Response() { FileName = fileName, Rows = rows }); }
public IActionResult Index() { return(RedirectToAction("Apprenticeships", "BulkUpload") .WithProviderContext(_providerContextProvider.GetProviderContext(withLegacyFallback: true))); }
public async Task <IViewComponentResult> InvokeAsync(DashboardModel model) { var actualModel = model ?? new DashboardModel(); int UKPRN = 0; if (Session.GetInt32("UKPRN").HasValue) { UKPRN = Session.GetInt32("UKPRN").Value; } var allVenues = await _venueService.SearchAsync(new VenueSearchCriteria(UKPRN.ToString(), "")); try { var getCoursesResult = _courseService.GetYourCoursesByUKPRNAsync(new CourseSearchCriteria(UKPRN)).Result; IEnumerable <Course> courses = getCoursesResult .Value .Value .SelectMany(o => o.Value) .SelectMany(i => i.Value); IEnumerable <CourseRun> bulkUploadReadyToGoLive = courses.SelectMany(c => c.CourseRuns) .Where(x => x.RecordStatus == RecordStatus.BulkUploadReadyToGoLive); IEnumerable <Course> validCourses = courses.Where(c => c.IsValid); IEnumerable <CourseValidationResult> results = _courseService.CourseValidationMessages(validCourses.Where(x => ((int)x.CourseStatus & (int)RecordStatus.Live) > 0), ValidationMode.DataQualityIndicator).Value; IEnumerable <string> courseMessages = results.SelectMany(c => c.Issues); IEnumerable <string> runMessages = results.SelectMany(c => c.RunValidationResults).SelectMany(r => r.Issues); IEnumerable <string> messages = courseMessages.Concat(runMessages) .GroupBy(i => i) .Select(g => $"{ g.LongCount() } { g.Key }"); IEnumerable <Course> bulkUploadCoursesPending = courses.Where(x => ((int)x.CourseStatus & (int)RecordStatus.BulkUploadPending) > 0); IEnumerable <CourseRun> bulkUploadRunsPending = courses.SelectMany(c => c.CourseRuns) .Where(x => x.RecordStatus == RecordStatus.BulkUploadPending); IEnumerable <CourseRun> migrationPendingCourses = courses.SelectMany(c => c.CourseRuns).Where(x => x.RecordStatus == RecordStatus.MigrationPending || x.RecordStatus == RecordStatus.MigrationReadyToGoLive); IEnumerable <Course> inValidCourses = courses.Where(c => c.IsValid == false); var getApprenticeshipResult = _apprenticeshipService.GetApprenticeshipByUKPRN(UKPRN.ToString()).Result; var ApprenticeshipBulkUploadReadyToGoLive = _apprenticeshipService.GetApprenticeshipByUKPRN(UKPRN.ToString()).Result.Value.Where(x => x.RecordStatus == RecordStatus.BulkUploadReadyToGoLive); actualModel.ApprenticeshipBulkUploadReadyToGoLiveCount = ApprenticeshipBulkUploadReadyToGoLive.Count(); actualModel.BulkUploadPendingCount = bulkUploadRunsPending.Count(); actualModel.BulkUploadReadyToGoLiveCount = bulkUploadReadyToGoLive.Count(); actualModel.BulkUploadTotalCount = bulkUploadCoursesPending.Count() + bulkUploadReadyToGoLive.Count(); IEnumerable <Services.BlobStorageService.BlobFileInfo> list = _blobStorageService.GetFileList(UKPRN + "/Bulk Upload/Files/").OrderByDescending(x => x.DateUploaded).ToList(); if (list.Any()) { actualModel.FileUploadDate = list.FirstOrDefault().DateUploaded.Value; } var courseMigrationReportResult = await _courseService.GetCourseMigrationReport(UKPRN); var larslessCoursesCount = courseMigrationReportResult.IsSuccess ? courseMigrationReportResult.Value.LarslessCourses.Count() : 0; actualModel.DisplayMigrationButton = false; //list.Any() to see if any bulkupload files exist. If they do we don't want to show migration error. if ((migrationPendingCourses.Count() > 0 || larslessCoursesCount > 0) && !list.Any()) { actualModel.DisplayMigrationButton = true; } actualModel.BulkUpLoadHasErrors = bulkUploadCoursesPending?.SelectMany(c => c.BulkUploadErrors).Count() + bulkUploadRunsPending?.SelectMany(r => r.BulkUploadErrors).Count() > 0; string BulkUpLoadErrorMessage = actualModel.BulkUploadTotalCount.ToString() + WebHelper.GetCourseTextToUse(actualModel.BulkUploadTotalCount) + " uploaded in a file on " + actualModel.FileUploadDate?.ToString("dd/MM/yyyy") + " have " + (bulkUploadCoursesPending?.SelectMany(c => c.BulkUploadErrors).Count() + bulkUploadRunsPending?.SelectMany(r => r.BulkUploadErrors).Count()).ToString() + " errors. Fix these to publish all of your courses."; string BulkUpLoadNoErrorMessage = "Your bulk upload is complete." + actualModel.BulkUploadTotalCount.ToString() + WebHelper.GetCourseTextToUse(actualModel.BulkUploadPendingCount) + " have been uploaded on " + actualModel.FileUploadDate?.ToString("dd/MM/yyyy") + " and ready to publish to the course directory."; actualModel.FileCount = list.Count(); int MigrationLiveCount = courses.Where(x => x.CourseStatus == RecordStatus.Live && x.CreatedBy == "DFC – Course Migration Tool") .SelectMany(c => c.CourseRuns) .Count(x => x.RecordStatus == RecordStatus.Live && x.CreatedBy == "DFC – Course Migration Tool"); actualModel.BulkUploadMessage = (actualModel.BulkUploadTotalCount > 0 & actualModel.BulkUploadPendingCount == 0) ? BulkUpLoadNoErrorMessage : BulkUpLoadErrorMessage; actualModel.ValidationMessages = messages; actualModel.VenueCount = 0; if (allVenues.Value != null) { actualModel.VenueCount = allVenues.Value.Value.Count(x => x.Status == VenueStatus.Live); } actualModel.PublishedCourseCount = courses .SelectMany(c => c.CourseRuns) .Count(x => x.RecordStatus == RecordStatus.Live); var result = await _apprenticeshipService.GetApprenticeshipByUKPRN(UKPRN.ToString()); var appResult = await _apprenticeshipService.GetApprenticeshipDashboardCounts(UKPRN); if (appResult.IsSuccess) { var counts = appResult.Value; IEnumerable <Services.BlobStorageService.BlobFileInfo> appList = _blobStorageService.GetFileList(UKPRN + "/Apprenticeship Bulk Upload/Files/").OrderByDescending(x => x.DateUploaded).ToList(); if (list.Any()) { counts.FileUploadDate = list.FirstOrDefault().DateUploaded.Value; } var appMessages = GenerateApprenticeshipDQIMessages(counts); if (!string.IsNullOrWhiteSpace(appMessages)) { actualModel.ApprenticeshipMessages = appMessages; actualModel.ApprenticeshipHasErrors = true; } if (counts.TotalErrors != null && counts.TotalErrors > 0) { actualModel.ApprenticeshipBulkUploadHasErrors = true; } else { actualModel.ApprenticeshipBulkUploadHasErrors = false; } } // provider has no apprenticeship but pending bulkupload if (!appResult.IsSuccess) { var counts = appResult.Value; if (counts == null && actualModel.ApprenticeshipBulkUploadReadyToGoLiveCount > 0) { //var appMessages = actualModel.ApprenticeshipBulkUploadReadyToGoLiveCount.ToString() + WebHelper.GetCourseTextToUse(actualModel.ApprenticeshipBulkUploadReadyToGoLiveCount) + " uploaded on " + actualModel.FileUploadDate?.ToString("dd/MM/yyyy") + " have no errors, but are not listed on the Course directory because you have not published them."; var appMessages = "Your bulk upload is complete." + actualModel.ApprenticeshipBulkUploadReadyToGoLiveCount.ToString() + WebHelper.GetApprenticeshipsTextToUse(actualModel.ApprenticeshipBulkUploadReadyToGoLiveCount) + " have been uploaded on " + actualModel.FileUploadDate?.ToString("dd/MM/yyyy") + "and ready to publish to the course directory."; if (!string.IsNullOrWhiteSpace(appMessages)) { actualModel.ApprenticeshipMessages = appMessages; } } } actualModel.PublishedApprenticeshipsCount = result.Value.Count(x => x.RecordStatus == RecordStatus.Live); var provider = FindProvider(UKPRN); if (null != provider) { if (null != provider.BulkUploadStatus) { actualModel.BulkUploadBackgroundInProgress = provider.BulkUploadStatus.InProgress; actualModel.BulkUploadBackgroundRowCount = provider.BulkUploadStatus.TotalRowCount; actualModel.BulkUploadBackgroundStartTimestamp = provider.BulkUploadStatus.StartedTimestamp; actualModel.BulkUploadPublishInProgress = provider.BulkUploadStatus.PublishInProgress; } actualModel.ProviderType = provider.ProviderType; } actualModel.EnvironmentType = _environmentHelper.GetEnvironmentType(); var providerId = _providerContextProvider.GetProviderContext().ProviderInfo.ProviderId; actualModel.ProviderQACurrentStatus = await _sqlQueryDispatcher.ExecuteQuery( new GetProviderApprenticeshipQAStatus() { ProviderId = providerId }) ?? Core.Models.ApprenticeshipQAStatus.NotStarted; } catch (Exception) { //@ToDo: decide how to handle this - should at least be logged. Caused by NPE during call to course service List <string> errors = new List <string>() { "There was a system problem whilst obtaining course data from the course directory. Please wait a few moments and refresh your browser page." }; actualModel.ValidationMessages = errors; } return(View("~/ViewComponents/Dashboard/Default.cshtml", actualModel)); }
public NewApprenticeshipProviderController(IMediator mediator, IProviderContextProvider providerContextProvider) { _mediator = mediator; _providerContext = providerContextProvider.GetProviderContext(); }
public ProviderContextModelBinderTestController(IProviderContextProvider providerContextProvider) { _providerContext = providerContextProvider.GetProviderContext(); }
public static Guid GetProviderId(this IProviderContextProvider providerContextProvider) => providerContextProvider.GetProviderContext().ProviderInfo.ProviderId;
public Task <IActionResult> ViewVenues() => _mediator.SendAndMapResponse <ViewModel, IActionResult>( new Query { ProviderId = _providerContextProvider.GetProviderContext().ProviderInfo.ProviderId }, vm => View(vm));
public async Task <IActionResult> Upload(Upload.Command command) { var file = Request.Form.Files?.GetFile(nameof(command.File)); return(await _mediator.SendAndMapResponse( new Upload.Command() { File = file }, response => response.Match <IActionResult>( errors => { ViewBag.MissingHeaders = errors.MissingHeaders; ViewBag.MissingStandardRows = errors.MissingStandardRows; ViewBag.InvalidStandardRows = errors.InvalidStandardRows; if (errors.MissingStandardRows.Count > 0 || errors.InvalidStandardRows.Count > 0) { ModelState.AddModelError(nameof(command.File), "The file contains errors"); } return this.ViewFromErrors(errors); }, success => RedirectToAction(nameof(InProgress)).WithProviderContext(_providerContextProvider.GetProviderContext())))); }
public FindStandardController(IMediator mediator, IProviderContextProvider providerContextProvider) { _mediator = mediator; _providerContext = providerContextProvider.GetProviderContext(); }
public ProvidersController(IMediator mediator, IProviderContextProvider providerContextProvider) { _mediator = mediator; _providerContext = providerContextProvider.GetProviderContext(); }
public static Guid GetProviderId( this IProviderContextProvider providerContextProvider, bool withLegacyFallback = false) => providerContextProvider.GetProviderContext(withLegacyFallback).ProviderInfo.ProviderId;
public async Task <IActionResult> Index(PublishMode publishMode, string notificationTitle, Guid?courseId, Guid?courseRunId, bool fromBulkUpload) { int?UKPRN = Session.GetInt32("UKPRN"); if (!UKPRN.HasValue) { return(RedirectToAction("Index", "Home", new { errmsg = "Please select a Provider." })); } var coursesByUKPRN = (await _courseService.GetYourCoursesByUKPRNAsync(new CourseSearchCriteria(UKPRN))).Value; // Only display courses that have Lars and Qualification titles var courses = coursesByUKPRN.Value .SelectMany(o => o.Value) .SelectMany(i => i.Value) .Where(c => !string.IsNullOrWhiteSpace(c.LearnAimRef) && !string.IsNullOrWhiteSpace(c.QualificationCourseTitle)) .ToList(); courses = GetErrorMessages(courses, ValidationMode.MigrateCourse).ToList(); PublishViewModel vm = new PublishViewModel(); switch (publishMode) { case PublishMode.Migration: if (courses.Where(x => x.CourseRuns.Any(cr => cr.RecordStatus == RecordStatus.MigrationPending || cr.RecordStatus == RecordStatus.MigrationReadyToGoLive) && x.IsValid == false).Any()) { vm.PublishMode = PublishMode.Migration; var migratedCourses = courses.Where(x => x.CourseRuns.Any(cr => cr.RecordStatus == RecordStatus.MigrationPending || cr.RecordStatus == RecordStatus.MigrationReadyToGoLive)); var migratedCoursesWithErrors = GetErrorMessages(migratedCourses, ValidationMode.MigrateCourse).ToList(); vm.NumberOfCoursesInFiles = migratedCoursesWithErrors.SelectMany(s => s.CourseRuns.Where(cr => cr.RecordStatus == RecordStatus.MigrationPending || cr.RecordStatus == RecordStatus.MigrationReadyToGoLive)).Count(); vm.Courses = migratedCoursesWithErrors.OrderBy(x => x.QualificationCourseTitle); vm.AreAllReadyToBePublished = CheckAreAllReadyToBePublished(migratedCoursesWithErrors, PublishMode.Migration); vm.Venues = VenueHelper.GetVenueNames(vm.Courses, _cosmosDbQueryDispatcher).Result; break; } else { return(View("../Migration/Complete/index")); } case PublishMode.BulkUpload: vm.PublishMode = PublishMode.BulkUpload; var bulkUploadedCourses = courses.Where(x => x.CourseRuns.Any(cr => cr.RecordStatus == RecordStatus.BulkUploadPending || cr.RecordStatus == RecordStatus.BulkUploadReadyToGoLive)).ToList(); vm.NumberOfCoursesInFiles = bulkUploadedCourses.SelectMany(s => s.CourseRuns.Where(cr => cr.RecordStatus == RecordStatus.BulkUploadPending || cr.RecordStatus == RecordStatus.BulkUploadReadyToGoLive)).Count(); vm.Courses = bulkUploadedCourses.OrderBy(x => x.QualificationCourseTitle); vm.AreAllReadyToBePublished = CheckAreAllReadyToBePublished(bulkUploadedCourses, PublishMode.BulkUpload); vm.Courses = GetErrorMessages(vm.Courses, ValidationMode.BulkUploadCourse); vm.Venues = VenueHelper.GetVenueNames(vm.Courses, _cosmosDbQueryDispatcher).Result; break; case PublishMode.DataQualityIndicator: vm.PublishMode = PublishMode.DataQualityIndicator; var validCourses = courses.Where(x => x.IsValid && ((int)x.CourseStatus & (int)RecordStatus.Live) > 0); var results = _courseService.CourseValidationMessages(validCourses, ValidationMode.DataQualityIndicator).Value.ToList(); var invalidCoursesResult = results.Where(c => c.RunValidationResults.Any(cr => cr.Issues.Count() > 0)); var invalidCourses = invalidCoursesResult.Select(c => (Course)c.Course).ToList(); var invalidCourseRuns = invalidCourses.Select(cr => cr.CourseRuns.Where(x => x.StartDate < DateTime.Today)); List <Course> filteredList = new List <Course>(); var allRegions = _courseService.GetRegions().RegionItems; foreach (var course in invalidCourses) { var invalidRuns = course.CourseRuns.Where(x => x.StartDate < DateTime.Today); if (invalidRuns.Any()) { course.CourseRuns = invalidRuns; filteredList.Add(course); } } if (invalidCourseRuns.Count() == 0 && courseId != null && courseRunId != null) { return(BadRequest()); } vm.NumberOfCoursesInFiles = invalidCourses.Count(); vm.Courses = filteredList.OrderBy(x => x.QualificationCourseTitle); vm.Venues = VenueHelper.GetVenueNames(vm.Courses, _cosmosDbQueryDispatcher).Result; vm.Regions = allRegions; break; } vm.NotificationTitle = notificationTitle; vm.CourseId = courseId; vm.CourseRunId = courseRunId; if (vm.AreAllReadyToBePublished) { if (publishMode == PublishMode.BulkUpload) { return(RedirectToAction("CoursesPublishFile", "Bulkupload", new { NumberOfCourses = courses.SelectMany(s => s.CourseRuns.Where(cr => cr.RecordStatus == RecordStatus.BulkUploadReadyToGoLive)).Count() }) .WithProviderContext(_providerContextProvider.GetProviderContext(withLegacyFallback: true))); } } else { if (publishMode == PublishMode.BulkUpload) { var message = ""; if (fromBulkUpload) { var invalidCourseCount = courses.Where(x => x.IsValid == false).Count(); var bulkUploadedPendingCourses = (courses.SelectMany(c => c.CourseRuns) .Where(x => x.RecordStatus == RecordStatus.BulkUploadPending) .Count()); message = "Your file contained " + bulkUploadedPendingCourses + @WebHelper.GetErrorTextValueToUse(bulkUploadedPendingCourses) + ". You must resolve all errors before your courses information can be published."; return(RedirectToAction("WhatDoYouWantToDoNext", "Bulkupload", new { message = message })); } } } return(View("Index", vm)); }