-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDegree.cs
215 lines (206 loc) · 8.37 KB
/
Degree.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
//using System.ComponentModel.DataAnnotations;
namespace DegreeMapperWebAPI
{
public class Degree
{
public int Id { get; set; }
[DisplayName("Institution Id")]
public int InstitutionId { get; set; }
public string Name { get; set; }
[DisplayName("Degree Type")]
public string DegreeType { get; set; }
public string GPA { get; set; }
[DisplayName("Limited Access")]
public bool LimitedAccess { get; set; }
[DisplayName("Restricted Access")]
public bool RestrictedAccess { get; set; }
public string Description { get; set; }
[DisplayName("Catalog Year")]
public string CatalogYear { get; set; }
public int CatalogId { get; set; }
public bool Active { get; set; }
public string Institution { get; set; }
public DateTime AddDate { get; set; }
public DateTime UpdateDate { get; set; }
public string NID { get; set; }
public int? UCFDegreeId { get; set; }
[DisplayName("UCF Degree Name")]
public string UCFDegreeName { get; set; }
[DisplayName("College Name")]
public string CollegeName { get; set; }
public int CollegeId { get; set; }
[DisplayName("Degree URL")]
public string DegreeURL { get; set; }
[DisplayName("Catalog URL")]
public string CatalogUrl { get; set; }
public string UndergraduateCatalogUrl { get; set; }
public int? CloneDegreeId { get; set; }
public Degree()
{
}
public Degree(int? catalogId)
{
Active = true;
LimitedAccess = false;
RestrictedAccess = false;
//NID = HttpContext.Current.User.Identity.Name;
GPA = "2.0";
UCFDegreeId = null;
CatalogId = (catalogId.HasValue) ? catalogId.Value : new Catalog(true).Id;
CatalogYear = (catalogId.HasValue) ? Catalog.Get(catalogId.Value).Year : new Catalog(true).Year;
}
public Degree(int institutionId, int? catalogId)
{
Active = true;
LimitedAccess = false;
RestrictedAccess = false;
InstitutionId = institutionId;
Institution = DegreeMapperWebAPI.Institution.Get(institutionId).Name;
//NID = HttpContext.Current.User.Identity.Name;
GPA = "2.0";
UCFDegreeId = null;
CatalogId = (catalogId.HasValue) ? catalogId.Value : new DegreeMapperWebAPI.Catalog(true).Id;
CatalogYear = (catalogId.HasValue) ? DegreeMapperWebAPI.Catalog.Get(catalogId.Value).Year : new DegreeMapperWebAPI.Catalog(true).Year;
}
public static List<Degree> List(int? instiutionId, int? catalogId)
{
List<Degree> list_d = new List<Degree>();
using (SqlConnection cn = new SqlConnection(Database.DC_DegreeMapping))
{
cn.Open();
SqlCommand cmd = cn.CreateCommand();
cmd.CommandText = "GetDegree";
cmd.CommandType = CommandType.StoredProcedure;
if (instiutionId.HasValue)
{
cmd.Parameters.AddWithValue("@InstitutionId", instiutionId.Value);
}
if (catalogId.HasValue)
{
cmd.Parameters.AddWithValue("@CatalogId", catalogId.Value);
}
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
Degree d = new Degree(null);
Set(dr, ref d);
list_d.Add(d);
}
}
cn.Close();
}
return list_d;
}
public static Degree Get(int id)
{
Degree d = new Degree(null);
using (SqlConnection cn = new SqlConnection(Database.DC_DegreeMapping))
{
cn.Open();
SqlCommand cmd = cn.CreateCommand();
cmd.CommandText = "GetDegree";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Id", id);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
Set(dr, ref d);
}
}
cn.Close();
}
return d;
}
/// <summary>
/// returns partner institutions only
/// NOT USED NOT REFERENCE AND STORED PROCEDURE DOES NOT EXISTS
/// DELETE
/// institutionId != 1
/// </summary>
/// <param name="id"></param>
/// <param name="catalogId"></param>
/// <param name="institutionId"></param>
/// <returns></returns>
public static List<Degree> GetPartnerDegrees(int? id, int? catalogId, int? institutionId)
{
List<Degree> list_degrees = new List<Degree>();
using (SqlConnection cn = new SqlConnection(Database.DC_DegreeMapping))
{
cn.Open();
SqlCommand cmd = cn.CreateCommand();
cmd.CommandText = "GetPartnerDegree";
cmd.CommandType = CommandType.StoredProcedure;
if (id.HasValue)
{
cmd.Parameters.AddWithValue("@Id", id.Value);
}
if (catalogId.HasValue)
{
cmd.Parameters.AddWithValue("@CatalogId", catalogId.Value);
}
if (institutionId.HasValue)
{
cmd.Parameters.AddWithValue("@InstitutionId", institutionId.Value);
}
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
Degree d = new Degree();
Set(dr, ref d);
list_degrees.Add(d);
}
}
cn.Close();
}
return list_degrees;
}
private static void Set(SqlDataReader dr, ref Degree d)
{
if (dr.HasRows)
{
d.Id = Convert.ToInt32(dr["Id"].ToString());
d.Name = dr["Name"].ToString();
d.GPA = dr["GPA"].ToString();
d.DegreeType = dr["DegreeType"].ToString();
d.LimitedAccess = Convert.ToBoolean(dr["LimitedAccess"].ToString());
d.RestrictedAccess = Convert.ToBoolean(dr["RestrictedAccess"].ToString());
d.Description = dr["Description"].ToString();
d.CatalogYear = dr["CatalogYear"].ToString();
d.Institution = dr["Institution"].ToString();
d.Active = Convert.ToBoolean(dr["Active"].ToString());
d.InstitutionId = Convert.ToInt32(dr["InstitutionId"].ToString());
d.AddDate = Convert.ToDateTime(dr["AddDate"].ToString());
d.UpdateDate = Convert.ToDateTime(dr["UpdateDate"].ToString());
d.CollegeName = dr["CollegeName"].ToString();
d.CollegeId = (!string.IsNullOrEmpty(d.CollegeName)) ? Convert.ToInt32(dr["CollegeId"].ToString()) : 0;
d.DegreeURL = dr["DegreeUrl"].ToString();
d.CatalogUrl = dr["CatalogUrl"].ToString();
d.UndergraduateCatalogUrl = dr["UndergraduateCatalogUrl"].ToString();
d.CatalogId = Convert.ToInt32(dr["CatalogId"].ToString());
d.NID = dr["NID"].ToString();
int ucfDegreeId;
Int32.TryParse(dr["UCFDegreeId"].ToString(), out ucfDegreeId);
d.UCFDegreeId = ucfDegreeId;
d.UCFDegreeName = dr["UCFDegreeName"].ToString();
d.CatalogYear = DegreeMapperWebAPI.Catalog.Get(d.CatalogId).Year;
int clonedegreeId;
Int32.TryParse(dr["CloneDegreeId"].ToString(), out clonedegreeId);
d.CloneDegreeId = clonedegreeId;
}
}
}
}