public ViewResult Index() { var currentUserId = User.FindFirstValue(ClaimTypes.NameIdentifier); var instances = _getOdsInstanceRegistrationsByUserIdQuery.Execute(currentUserId); var model = new IndexModel { UserContext = _userContext, OdsInstances = instances.Select( x => new OdsInstanceModel { Id = x.Id, Name = x.Name, DatabaseName = x.DatabaseName, Description = x.Description, SchoolYearDescription = _getCurrentSchoolYear .Execute(x.Name, CloudOdsAdminAppSettings.Instance.Mode) ?.SchoolYearDescription ?? "Not Set" }).ToList() }; return(View(model)); }
public ActionResult Edit(string instanceName) { var currentSchoolYear = _getCurrentSchoolYear.Execute(instanceName, ApiMode)?.SchoolYear; var schoolYears = _getSchoolYears.Execute(instanceName, ApiMode); string warning = null; if (ApiMode == ApiMode.YearSpecific) { var instanceYear = instanceName.ExtractNumericInstanceSuffix(); var expectedSchoolYear = schoolYears.SingleOrDefault(x => x.SchoolYear == instanceYear); var recommendation = expectedSchoolYear == null ? $"{instanceYear - 1}-{instanceYear}" : expectedSchoolYear.SchoolYearDescription; warning = "The ODS / API is in Year-Specific mode. It is " + "strongly recommended that this instance be set " + $"to school year {recommendation}."; } return(PartialView( new EditSchoolYearModel { Warning = warning, InstanceName = instanceName, SchoolYear = currentSchoolYear, SchoolYears = schoolYears .ToSelectListItems( "Select School Year", x => x.SchoolYear.ToString(), x => x.SchoolYearDescription) })); }
public IViewComponentResult Invoke() { var apiMode = CloudOdsAdminAppSettings.Instance.Mode; if (apiMode.SupportsMultipleInstances) { throw new InvalidOperationException( $"Attempted to display {nameof(SingleInstanceCurrentYearViewComponent)}, but the " + $"ODS is configured with multi-instance API mode '{apiMode}'."); } var schoolYear = _getCurrentSchoolYear.Execute(_instanceContext.Name, apiMode); return(View( new Model { InstanceName = _instanceContext.Name, SchoolYearDescription = schoolYear?.SchoolYearDescription })); }