forked from ucsbfinaid/Financial-Aid-Estimator-.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CostOfAttendanceEstimatorFactory.cs
117 lines (103 loc) · 4.69 KB
/
CostOfAttendanceEstimatorFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections.Generic;
using System.Xml;
namespace Ucsb.Sa.FinAid.AidEstimation.Utility
{
public class CostOfAttendanceEstimatorFactory
{
private readonly XmlConstantsSource _source;
public CostOfAttendanceEstimatorFactory(string sourcePath)
{
_source = new XmlConstantsSource(sourcePath);
}
public CostOfAttendanceEstimatorFactory(XmlDocument sourceDoc)
{
_source = new XmlConstantsSource(sourceDoc);
}
public CostOfAttendanceEstimator GetCostOfAttendanceEstimator()
{
Dictionary<CostOfAttendanceKey, CostOfAttendance> coaList = new Dictionary<CostOfAttendanceKey, CostOfAttendance>();
// It's possible that some of these budgets will not be specified. Instead of displaying an error in these cases,
// skip past the particular budget
// Undergrad Off-Campus
try
{
CostOfAttendanceKey undergradOffCampusCoaKey = new CostOfAttendanceKey(EducationLevel.Undergraduate, HousingOption.OffCampus);
CostOfAttendanceItem[] undergradOffCampusCoaItems = _source.GetCostOfAttendanceItemArray("CoaUndergraduateOffCampus");
CostOfAttendance undergradOffCampusCoa = new CostOfAttendance(undergradOffCampusCoaItems);
coaList.Add(undergradOffCampusCoaKey, undergradOffCampusCoa);
}
catch (Exception)
{
}
// Undergrad On-Campus
try
{
CostOfAttendanceKey undergradOnCampusCoaKey = new CostOfAttendanceKey(EducationLevel.Undergraduate, HousingOption.OnCampus);
CostOfAttendanceItem[] undergradOnCampusCoaItems = _source.GetCostOfAttendanceItemArray("CoaUndergraduateOnCampus");
CostOfAttendance undergradOnCampusCoa = new CostOfAttendance(undergradOnCampusCoaItems);
coaList.Add(undergradOnCampusCoaKey, undergradOnCampusCoa);
}
catch (Exception)
{
}
// Undergrad Commuter
try
{
CostOfAttendanceKey undergradCommuterCoaKey = new CostOfAttendanceKey(EducationLevel.Undergraduate, HousingOption.Commuter);
CostOfAttendanceItem[] undergradCommuterCoaItems = _source.GetCostOfAttendanceItemArray("CoaUndergraduateCommuter");
CostOfAttendance undergradCommuterCoa = new CostOfAttendance(undergradCommuterCoaItems);
coaList.Add(undergradCommuterCoaKey, undergradCommuterCoa);
}
catch (Exception)
{
}
// Grad Off-Campus
try
{
CostOfAttendanceKey gradOffCampusCoaKey = new CostOfAttendanceKey(EducationLevel.Graduate, HousingOption.OffCampus);
CostOfAttendanceItem[] gradOffCampusCoaItems = _source.GetCostOfAttendanceItemArray("CoaGraduateOffCampus");
CostOfAttendance gradOffCampusCoa = new CostOfAttendance(gradOffCampusCoaItems);
coaList.Add(gradOffCampusCoaKey, gradOffCampusCoa);
}
catch (Exception)
{
}
// Grad On-Campus
try
{
CostOfAttendanceKey gradOnCampusCoaKey = new CostOfAttendanceKey(EducationLevel.Graduate, HousingOption.OnCampus);
CostOfAttendanceItem[] gradOnCampusCoaItems = _source.GetCostOfAttendanceItemArray("CoaGraduateOnCampus");
CostOfAttendance gradOnCampusCoa = new CostOfAttendance(gradOnCampusCoaItems);
coaList.Add(gradOnCampusCoaKey, gradOnCampusCoa);
}
catch (Exception)
{
}
// Grad Commuter
try
{
CostOfAttendanceKey gradCommuterCoaKey = new CostOfAttendanceKey(EducationLevel.Graduate, HousingOption.Commuter);
CostOfAttendanceItem[] gradCommuterCoaItems = _source.GetCostOfAttendanceItemArray("CoaGraduateCommuter");
CostOfAttendance gradCommuterCoa = new CostOfAttendance(gradCommuterCoaItems);
coaList.Add(gradCommuterCoaKey, gradCommuterCoa);
}
catch (Exception)
{
}
// Out of State Fees
try
{
double outOfStateFees = _source.GetValue<double>("OutOfStateFees");
foreach (CostOfAttendance coa in coaList.Values)
{
coa.OutOfStateFees = outOfStateFees;
}
}
catch (Exception)
{
}
return new CostOfAttendanceEstimator(coaList);
}
}
}