protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { // Collect user input RawDependentEfcCalculatorArguments rawArgs = new RawDependentEfcCalculatorArguments(); rawArgs.OldestParentAge = inputOldestParentAge.Text; rawArgs.MaritalStatus = inputMaritalStatus.SelectedValue; rawArgs.StateOfResidency = inputStateOfResidency.SelectedValue; rawArgs.IsFirstParentWorking = inputFirstParentWorking.SelectedValue; rawArgs.FirstParentWorkIncome = inputFirstParentWorkIncome.Text; rawArgs.IsSecondParentWorking = inputSecondParentWorking.SelectedValue; rawArgs.SecondParentWorkIncome = inputSecondParentWorkIncome.Text; rawArgs.IsStudentWorking = inputStudentWorking.SelectedValue; rawArgs.StudentWorkIncome = inputStudentWorkIncome.Text; rawArgs.ParentAgi = inputParentAgi.Text; rawArgs.AreParentsTaxFilers = inputAreParentsTaxFilers.SelectedValue; rawArgs.ParentIncomeTax = inputParentIncomeTax.Text; rawArgs.ParentUntaxedIncomeAndBenefits = inputParentUntaxedIncomeAndBenefits.Text; rawArgs.ParentAdditionalFinancialInfo = inputParentAdditionalFinancialInfo.Text; rawArgs.StudentAgi = inputStudentAgi.Text; rawArgs.IsStudentTaxFiler = inputStudentTaxFiler.SelectedValue; rawArgs.StudentIncomeTax = inputStudentIncomeTax.Text; rawArgs.StudentUntaxedIncomeAndBenefits = inputStudentUntaxedIncomeAndBenefits.Text; rawArgs.StudentAdditionalFinancialInfo = inputStudentAdditionalFinancialInfo.Text; rawArgs.ParentCashSavingsChecking = inputParentCashSavingsChecking.Text; rawArgs.ParentInvestmentNetWorth = inputParentInvestmentNetWorth.Text; rawArgs.ParentBusinessFarmNetWorth = inputParentBusinessFarmNetWorth.Text; rawArgs.StudentCashSavingsChecking = inputStudentCashSavingsChecking.Text; rawArgs.StudentInvestmentNetWorth = inputStudentInvestmentNetWorth.Text; rawArgs.StudentBusinessFarmNetWorth = inputStudentBusinessFarmNetWorth.Text; rawArgs.NumberInHousehold = inputNumberInHousehold.Text; rawArgs.NumberInCollege = inputNumberInCollege.Text; rawArgs.MonthsOfEnrollment = "9"; rawArgs.IsQualifiedForSimplified = "false"; // Validate user input AidEstimationValidator validator = new AidEstimationValidator(); DependentEfcCalculatorArguments args = validator.ValidateDependentEfcCalculatorArguments(rawArgs); // If validation fails, display errors if (validator.Errors.Any()) { errorList.DataSource = validator.Errors; errorList.DataBind(); validationSummary.Visible = false; return; } else { validationSummary.Visible = true; } // Calculate EfcCalculator calculator = EfcCalculatorConfigurationManager.GetEfcCalculator("2021"); EfcProfile profile = calculator.GetDependentEfcProfile(args); // Display Results formPlaceholder.Visible = false; resultsPlaceholder.Visible = true; studentContributionOutput.Text = profile.StudentContribution.ToString("C0"); parentContributionOutput.Text = profile.ParentContribution.ToString("C0"); expectedFamilyContributionOutput.Text = profile.ExpectedFamilyContribution.ToString("C0"); CostOfAttendanceEstimator coaEstimator = CostOfAttendanceEstimatorConfigurationManager.GetCostOfAttendanceEstimator("2021"); CostOfAttendance coa = coaEstimator.GetCostOfAttendance(EducationLevel.Undergraduate, (HousingOption)Enum.Parse(typeof(HousingOption), inputHousing.SelectedValue)); tuitionFeesOutput.Text = coa.Items[0].Value.ToString("C0"); roomBoardOutput.Text = coa.Items[1].Value.ToString("C0"); booksSuppliesOutput.Text = coa.Items[2].Value.ToString("C0"); otherExpensesOutput.Text = coa.Items[3].Value.ToString("C0"); healthInsuranceOutput.Text = coa.Items[4].Value.ToString("C0"); totalCostOutput.Text = coa.Total.ToString("C0"); grantAwardOutput.Text = "$99,999"; // placeholder selfHelpAwardOutput.Text = "$99,999"; // placeholder familyHelpAwardOutput.Text = "$99,999"; // placeholder estimatedGrantOutput.Text = "$99,999"; // placeholder estimatedNetCostOutput.Text = "$99,999"; // placeholder percentageGrantOutput.Text = ConfigurationManager.AppSettings["PercentageGrant.Dependent.1920"]; } else { //Enable client-side validators where no default value is defined inputOldestParentAge.Attributes.Add("onblur", "ValidatorValidate(document.getElementById('" + inputOldestParentAge.ClientID + "').Validators[0]);"); inputFirstParentWorkIncome.Attributes.Add("onblur", "ValidatorValidate(document.getElementById('" + inputFirstParentWorkIncome.ClientID + "').Validators[0]);"); inputSecondParentWorkIncome.Attributes.Add("onblur", "ValidatorValidate(document.getElementById('" + inputSecondParentWorkIncome.ClientID + "').Validators[0]);"); inputStudentWorkIncome.Attributes.Add("onblur", "ValidatorValidate(document.getElementById('" + inputStudentWorkIncome.ClientID + "').Validators[0]);"); // enable or disable validators linked to radio button lists inputFirstParentWorking.Items[0].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputFirstParentWorkIncome.ClientID + "').Validators[0], true); "); inputFirstParentWorking.Items[1].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputFirstParentWorkIncome.ClientID + "').Validators[0], false); "); inputSecondParentWorking.Items[0].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputSecondParentWorkIncome.ClientID + "').Validators[0], true); "); inputSecondParentWorking.Items[1].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputSecondParentWorkIncome.ClientID + "').Validators[0], false); "); inputStudentWorking.Items[0].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputStudentWorkIncome.ClientID + "').Validators[0], true); "); inputStudentWorking.Items[1].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputStudentWorkIncome.ClientID + "').Validators[0], false); "); inputAreParentsTaxFilers.Items[0].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputParentIncomeTax.ClientID + "').Validators[0], true); ValidatorEnable(document.getElementById('" + inputParentAgi.ClientID + "').Validators[0], true);"); inputAreParentsTaxFilers.Items[1].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputParentIncomeTax.ClientID + "').Validators[0], false); ValidatorEnable(document.getElementById('" + inputParentAgi.ClientID + "').Validators[0], false);"); inputStudentTaxFiler.Items[0].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputStudentAgi.ClientID + "').Validators[0], true); ValidatorEnable(document.getElementById('" + inputStudentIncomeTax.ClientID + "').Validators[0], true);"); inputStudentTaxFiler.Items[1].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputStudentAgi.ClientID + "').Validators[0], false); ValidatorEnable(document.getElementById('" + inputStudentIncomeTax.ClientID + "').Validators[0], false);"); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { // Collect user input RawDependentEfcCalculatorArguments rawArgs = new RawDependentEfcCalculatorArguments(); rawArgs.OldestParentAge = inputOldestParentAge.Text; rawArgs.MaritalStatus = inputMaritalStatus.SelectedValue; rawArgs.StateOfResidency = inputStateOfResidency.SelectedValue; rawArgs.IsFirstParentWorking = inputFirstParentWorking.SelectedValue; rawArgs.FirstParentWorkIncome = inputFirstParentWorkIncome.Text; rawArgs.IsSecondParentWorking = inputSecondParentWorking.SelectedValue; rawArgs.SecondParentWorkIncome = inputSecondParentWorkIncome.Text; rawArgs.IsStudentWorking = inputStudentWorking.SelectedValue; rawArgs.StudentWorkIncome = inputStudentWorkIncome.Text; rawArgs.ParentAgi = inputParentAgi.Text; rawArgs.AreParentsTaxFilers = inputAreParentsTaxFilers.SelectedValue; rawArgs.ParentIncomeTax = inputParentIncomeTax.Text; rawArgs.ParentUntaxedIncomeAndBenefits = inputParentUntaxedIncomeAndBenefits.Text; rawArgs.ParentAdditionalFinancialInfo = inputParentAdditionalFinancialInfo.Text; rawArgs.StudentAgi = inputStudentAgi.Text; rawArgs.IsStudentTaxFiler = inputStudentTaxFiler.SelectedValue; rawArgs.StudentIncomeTax = inputStudentIncomeTax.Text; rawArgs.StudentUntaxedIncomeAndBenefits = inputStudentUntaxedIncomeAndBenefits.Text; rawArgs.StudentAdditionalFinancialInfo = inputStudentAdditionalFinancialInfo.Text; rawArgs.ParentCashSavingsChecking = inputParentCashSavingsChecking.Text; rawArgs.ParentInvestmentNetWorth = inputParentInvestmentNetWorth.Text; rawArgs.ParentBusinessFarmNetWorth = inputParentBusinessFarmNetWorth.Text; rawArgs.StudentCashSavingsChecking = inputStudentCashSavingsChecking.Text; rawArgs.StudentInvestmentNetWorth = inputStudentInvestmentNetWorth.Text; rawArgs.StudentBusinessFarmNetWorth = inputStudentBusinessFarmNetWorth.Text; rawArgs.NumberInHousehold = inputNumberInHousehold.Text; rawArgs.NumberInCollege = inputNumberInCollege.Text; rawArgs.MonthsOfEnrollment = "9"; rawArgs.IsQualifiedForSimplified = "false"; // Validate user input AidEstimationValidator validator = new AidEstimationValidator(); DependentEfcCalculatorArguments args = validator.ValidateDependentEfcCalculatorArguments(rawArgs); // If validation fails, display errors if (validator.Errors.Count > 0) { errorList.DataSource = validator.Errors; errorList.DataBind(); return; } // Calculate EfcCalculator calculator = EfcCalculatorConfigurationManager.GetEfcCalculator("2122"); EfcProfile profile = calculator.GetDependentEfcProfile(args); // Display Results formPlaceholder.Visible = false; resultsPlaceholder.Visible = true; studentContributionOutput.Text = profile.StudentContribution.ToString(); parentContributionOutput.Text = profile.ParentContribution.ToString(); expectedFamilyContributionOutput.Text = profile.ExpectedFamilyContribution.ToString(); } }
public IActionResult Estimate(int NumberInHousehold, int NumberInCollege, string StateOfResidency, string Housing, int OldestParentAge, string MaritalStatus, bool FirstParentWorking, decimal FirstParentWorkIncome, bool SecondParentWorking, decimal SecondParentWorkIncome, bool ParentsTaxFilers, decimal ParentAgi, decimal ParentIncomeTax, decimal ParentUntaxedIncomeAndBenefits, decimal ParentAdditionalFinancialInfo, decimal ParentCashSavingsChecking, decimal ParentInvestmentNetWorth, decimal ParentBusinessFarmNetWorth, bool StudentWorking, decimal StudentWorkIncome, bool StudentTaxFiler, decimal StudentAgi, decimal StudentIncomeTax, decimal StudentUntaxedIncomeAndBenefits, decimal StudentAdditionalFinancialInfo, decimal StudentCashSavingsChecking, decimal StudentInvestmentNetWorth, decimal StudentBusinessFarmNetWorth) { ViewData["Title"] = "Dependent Estimate "; ViewData["EstimateHeaderText"] = "PLACEHOLDER Estimate Text"; // Collect user input RawDependentEfcCalculatorArguments rawArgs = new RawDependentEfcCalculatorArguments(); rawArgs.OldestParentAge = OldestParentAge.ToString(); rawArgs.MaritalStatus = MaritalStatus; rawArgs.StateOfResidency = StateOfResidency; rawArgs.IsFirstParentWorking = FirstParentWorking.ToString(); rawArgs.FirstParentWorkIncome = FirstParentWorkIncome.ToString(); rawArgs.IsSecondParentWorking = SecondParentWorking.ToString(); rawArgs.SecondParentWorkIncome = SecondParentWorkIncome.ToString(); rawArgs.IsStudentWorking = StudentWorking.ToString(); rawArgs.StudentWorkIncome = StudentWorkIncome.ToString(); rawArgs.ParentAgi = ParentAgi.ToString(); rawArgs.AreParentsTaxFilers = ParentsTaxFilers.ToString(); rawArgs.ParentIncomeTax = ParentIncomeTax.ToString(); rawArgs.ParentUntaxedIncomeAndBenefits = ParentUntaxedIncomeAndBenefits.ToString(); rawArgs.ParentAdditionalFinancialInfo = ParentAdditionalFinancialInfo.ToString(); rawArgs.StudentAgi = StudentAgi.ToString(); rawArgs.IsStudentTaxFiler = StudentTaxFiler.ToString(); rawArgs.StudentIncomeTax = StudentIncomeTax.ToString(); rawArgs.StudentUntaxedIncomeAndBenefits = StudentUntaxedIncomeAndBenefits.ToString(); rawArgs.StudentAdditionalFinancialInfo = StudentAdditionalFinancialInfo.ToString(); rawArgs.ParentCashSavingsChecking = ParentCashSavingsChecking.ToString(); rawArgs.ParentInvestmentNetWorth = ParentInvestmentNetWorth.ToString(); rawArgs.ParentBusinessFarmNetWorth = ParentBusinessFarmNetWorth.ToString(); rawArgs.StudentCashSavingsChecking = StudentCashSavingsChecking.ToString(); rawArgs.StudentInvestmentNetWorth = StudentInvestmentNetWorth.ToString(); rawArgs.StudentBusinessFarmNetWorth = StudentBusinessFarmNetWorth.ToString(); rawArgs.NumberInHousehold = NumberInHousehold.ToString(); rawArgs.NumberInCollege = NumberInCollege.ToString(); rawArgs.MonthsOfEnrollment = "9"; rawArgs.IsQualifiedForSimplified = "false"; // Validate user input AidEstimationValidator validator = new AidEstimationValidator(); DependentEfcCalculatorArguments args = validator.ValidateDependentEfcCalculatorArguments(rawArgs); // If validation fails, display errors if (validator.Errors.Any()) { string errors = "Errors found: <ul>"; foreach (ValidationError err in validator.Errors) { errors += "<li>" + err.Message + "</li>"; } errors += "</ul>"; ViewData["Errors"] = errors; ViewData["HeaderText"] = "PLACEHOLDER Header Text"; Dictionary <string, string> FormValues = GetModelDictionary(NumberInHousehold, NumberInCollege, StateOfResidency, Housing, OldestParentAge, MaritalStatus, FirstParentWorking, FirstParentWorkIncome, SecondParentWorking, SecondParentWorkIncome, ParentsTaxFilers, ParentAgi, ParentIncomeTax, ParentUntaxedIncomeAndBenefits, ParentAdditionalFinancialInfo, ParentCashSavingsChecking, ParentInvestmentNetWorth, ParentBusinessFarmNetWorth, StudentWorking, StudentWorkIncome, StudentTaxFiler, StudentAgi, StudentIncomeTax, StudentUntaxedIncomeAndBenefits, StudentAdditionalFinancialInfo, StudentCashSavingsChecking, StudentInvestmentNetWorth, StudentBusinessFarmNetWorth); return(View("Index", FormValues)); } else { ViewData["Errors"] = ""; EfcCalculator calculator = EfcCalculatorConfigurationManager.GetEfcCalculator("1920", AppSettings.EfcCalculationConstants); EfcProfile profile = calculator.GetDependentEfcProfile(args); CostOfAttendanceEstimator coaEstimator = CostOfAttendanceEstimatorConfigurationManager.GetCostOfAttendanceEstimator("1920", AppSettings.AidEstimationConstants); HousingOption ho = (HousingOption)Enum.Parse(typeof(HousingOption), Housing.ToString()); CostOfAttendance coa = coaEstimator.GetCostOfAttendance(EducationLevel.Undergraduate, ho); double grantAward = 0; double selfHelp = Math.Max(0, AppSettings.SelfHelpConstant - profile.ExpectedFamilyContribution); double maxCosts = profile.ExpectedFamilyContribution + selfHelp + AppSettings.MaxLoanAmount; double subCosts = Math.Min(maxCosts, coa.Total); string AY = AppSettings.AidYear; if (StateOfResidency == "California") { grantAward = coa.Total - subCosts; ViewData["ShowOutOfState"] = false; } else { grantAward = GetGrantAmount(AY, profile.ExpectedFamilyContribution, coa.Total + coa.OutOfStateFees); ViewData["ShowOutOfState"] = true; } double parentLoan = Math.Max(0, coa.Total - grantAward - selfHelp); double netCosts = coa.Total - grantAward; double totalCOA = coa.Total; if (StateOfResidency != "California") { parentLoan += coa.OutOfStateFees; netCosts += coa.OutOfStateFees; totalCOA += coa.OutOfStateFees; } Dictionary <string, string> EstimatedAwards = new Dictionary <string, string>(); EstimatedAwards.Add("GrantAwards", grantAward.ToString("C0")); EstimatedAwards.Add("SelfHelp", selfHelp.ToString("C0")); EstimatedAwards.Add("ParentLoans", parentLoan.ToString("C0")); EstimatedAwards.Add("GrantAwardsPct", AppSettings.PercentageGrantDependant); EstimatedAwards.Add("NetCost", Math.Max(0, netCosts).ToString("C0")); EstimatedAwards.Add("OutOfStateFee", coa.OutOfStateFees.ToString("C0")); EstimatedAwards.Add("TotalCOA", totalCOA.ToString("C0")); ViewData["EstimatedAwards"] = EstimatedAwards; var tuple = (EfcProfile : profile, CostOfAttendance : coa); return(View(tuple)); } }