public IActionResult Save(AdminViewData updatedModel) { ApplicationContext appContext = new ApplicationContext(this.Cache); if (ModelState.IsValid) { UserSessionContext userContext = new UserSessionContext(this.HttpContext); LessonBusiness businessManager = new LessonBusiness(DbContext); businessManager.SaveReferenceList(updatedModel.ReferenceValueEnabled, updatedModel.ReferenceValueDisabled, (Enumerations.ReferenceType)updatedModel.EditReferenceType, userContext.CurrentUser); businessManager.SaveDisciplineUserList(updatedModel.DisciplineUsers, updatedModel.PrimaryDisciplineUser, updatedModel.EditingDisciplineUsersReferenceValue, userContext.CurrentUser); businessManager.SavePrimaryAdminUser(updatedModel.PrimaryAdminUser, userContext.CurrentUser); //Update the cache appContext.AllUsers = businessManager.GetAllUsers(); appContext.AllReferenceValues = businessManager.GetAllReferenceValues(); this.SetSuccessfulSave(); return(RedirectToActionPermanent("Index")); } switch ((Enumerations.ReferenceType)updatedModel.EditReferenceType) { case Enumerations.ReferenceType.Project: updatedModel.EditingReferenceValueList = appContext.Projects; break; case Enumerations.ReferenceType.Phase: updatedModel.EditingReferenceValueList = appContext.Phases; break; case Enumerations.ReferenceType.Classification: updatedModel.EditingReferenceValueList = appContext.Classifications; break; case Enumerations.ReferenceType.Location: updatedModel.EditingReferenceValueList = appContext.Locations; break; case Enumerations.ReferenceType.ImpactBenefitRange: updatedModel.EditingReferenceValueList = appContext.ImpactBenefitRanges; break; case Enumerations.ReferenceType.CostImpact: updatedModel.EditingReferenceValueList = appContext.CostImpacts; break; case Enumerations.ReferenceType.RiskRanking: updatedModel.EditingReferenceValueList = appContext.RiskRankings; break; case Enumerations.ReferenceType.Discipline: updatedModel.EditingReferenceValueList = appContext.Disciplines; break; case Enumerations.ReferenceType.CredibilityChecklist: updatedModel.EditingReferenceValueList = appContext.CredibilityChecklists; break; case Enumerations.ReferenceType.LessonTypeValid: updatedModel.EditingReferenceValueList = appContext.LessonTypesValid; break; case Enumerations.ReferenceType.LessonTypeInvalid: updatedModel.EditingReferenceValueList = appContext.LessonTypesInvalid; break; case Enumerations.ReferenceType.Theme: updatedModel.EditingReferenceValueList = appContext.Themes; break; default: throw new ArgumentOutOfRangeException(); } TempData["AdminData"] = updatedModel; return(Index()); }