-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomCourseSemester.cs
More file actions
120 lines (112 loc) · 4.34 KB
/
Copy pathCustomCourseSemester.cs
File metadata and controls
120 lines (112 loc) · 4.34 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace DegreeMapperWebAPI
{
public class CustomCourseSemester
{
//public int Id { get; set; }
//public int InstitutionId { get; set; }
//public int DegreeId { get; set; }
public int Semester { get; set; }
public string Term { get; set; }
//public string SemesterTerm { get; set; }
public string Note { get; set; }
//public int CatalogId { get; set; }
//public string CatalogYear { get; set; }
//public string Degree { get; set; }
//public string Institution { get; set; }
//public int? CloneId { get; set; }
public CustomCourseSemester()
{
this.Note = string.Empty;
}
public CustomCourseSemester(int degreeId)
{
//Degree d = DegreeMapperWebAPI.Degree.Get(degreeId);
//this.DegreeId = d.Id;
//this.Degree = d.Name;
//this.InstitutionId = d.InstitutionId;
//this.Institution = d.Institution;
//this.CatalogId = d.CatalogId;
//this.CatalogYear = d.CatalogYear;
this.Note = string.Empty;
}
public static CustomCourseSemester Get(int id)
{
CustomCourseSemester ccs = new CustomCourseSemester();
using (SqlConnection cn = new SqlConnection(Database.DC_DegreeMapping))
{
cn.Open();
SqlCommand cmd = cn.CreateCommand();
cmd.CommandText = "GetCustomCourseSemester";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Id", id);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
set(dr, ref ccs);
}
}
cn.Close();
}
return ccs;
}
public static List<CustomCourseSemester> List(int? degreeId, int? catalogId)
{
List<CustomCourseSemester> list_ccs = new List<CustomCourseSemester>();
using (SqlConnection cn = new SqlConnection(Database.DC_DegreeMapping))
{
cn.Open();
SqlCommand cmd = cn.CreateCommand();
cmd.CommandText = "GetCustomCourseSemester";
cmd.CommandType = CommandType.StoredProcedure;
if (degreeId.HasValue)
{
cmd.Parameters.AddWithValue("@DegreeId", degreeId.Value);
}
if (catalogId.HasValue)
{
cmd.Parameters.AddWithValue("@CatalogId", catalogId.Value);
}
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
CustomCourseSemester ccs = new CustomCourseSemester();
set(dr, ref ccs);
list_ccs.Add(ccs);
}
}
cn.Close();
}
return list_ccs;
}
public static void set(SqlDataReader dr, ref CustomCourseSemester ccs)
{
if (dr.HasRows)
{
//ccs.Id = Convert.ToInt32(dr["Id"].ToString());
//ccs.InstitutionId = Convert.ToInt32(dr["InstitutionId"].ToString());
//ccs.DegreeId = Convert.ToInt32(dr["DegreeId"].ToString());
ccs.Semester = Convert.ToInt32(dr["Semester"].ToString());
//ccs.SemesterTerm = string.Format("{0}{1}", dr["Term"].ToString(), dr["Semester"].ToString()).Trim(); //dr["Term"].ToString();
ccs.Term = dr["Term"].ToString();
ccs.Note = dr["Note"].ToString();
//ccs.CatalogId = Convert.ToInt32(dr["CatalogId"].ToString());
//ccs.CatalogYear = dr["CatalogYear"].ToString();
//ccs.Institution = dr["Institution"].ToString();
//int cloneId;
//Int32.TryParse(dr["CloneId"].ToString(), out cloneId);
//ccs.CloneId = cloneId;
}
}
}
}