public AreasModel() { Areas = new List <Area>(); string query = "SELECT IdArea, Address, Comment FROM Areas WHERE IsDeleted=0 ORDER BY 1 ASC"; var table = DbMess.GetTable(query); for (int i = 0; i < table.Rows.Count; i++) { Areas.Add(new Area() { Id = table.Rows[i][0].ToString(), Address = table.Rows[i][1].ToString(), Comment = table.Rows[i][2].ToString() }); } }
public OrganizationsModel() { Organizations = new List <Organization>(); string query = "SELECT * FROM Organizations WHERE IsDeleted=0"; var res = DbMess.GetTable(query); for (int i = 0; i < res.Rows.Count; i++) { Organizations.Add(new Organization() { Id = Convert.ToInt32(res.Rows[i][0].ToString()), Name = res.Rows[i][1].ToString(), Email = res.Rows[i][2].ToString(), Phone = res.Rows[i][3].ToString(), ContactFio = res.Rows[i][4].ToString() }); } }
public CoursesModel() { Courses = new List <Course>(); string query = "SELECT IdCourse, Name, IsRemote, LengthInHours, ResultType FROM Courses WHERE IsDeleted=0"; var table = DbMess.GetTable(query); for (int i = 0; i < table.Rows.Count; i++) { Courses.Add(new Course() { Id = Convert.ToInt32(table.Rows[i][0]), Name = table.Rows[i][1].ToString(), IsRemote = Convert.ToBoolean(table.Rows[i][2].ToString()), LengthInHours = Globals.StringIsEmpty(table.Rows[i][3].ToString()) ? -1 : Convert.ToDouble(table.Rows[i][3].ToString()), ResultType = Globals.StringIsEmpty(table.Rows[i][4].ToString()) ? CourseResultType.Presence : Convert.ToBoolean(table.Rows[i][4].ToString()) ? CourseResultType.Mark : CourseResultType.Sertificate }); } }
public LecturersModel() { Lecturers = new List <Lecturer>(); OrganizationIds = new List <string>(); OrganizationNames = new List <string>(); string query = "SELECT L.IdLecturer, L.FIO, L.OrganizationId, L.AvatarFileId, L.Email, L.ContactPhone, F.RelativePath, O.Name FROM Lecturers AS L LEFT JOIN Organizations AS O ON L.OrganizationId=O.IdOrganization LEFT JOIN Files AS F ON L.AvatarFileId=F.IdFile WHERE L.IsDeleted=0"; var table = DbMess.GetTable(query); for (int i = 0; i < table.Rows.Count; i++) { Lecturers.Add(new Lecturer() { Id = Convert.ToInt32(table.Rows[i][0].ToString()), FIO = table.Rows[i][1].ToString(), OrganizationId = Globals.GetSafeIntVal(table.Rows[i][2].ToString()), FileId = Globals.GetSafeIntVal(table.Rows[i][3].ToString()), Email = table.Rows[i][4].ToString(), ContactPhone = table.Rows[i][5].ToString(), FilePath = table.Rows[i][6].ToString(), OrganizationName = table.Rows[i][7].ToString() }); } query = "SELECT IdOrganization, Name FROM Organizations WHERE IsDeleted=0"; table = DbMess.GetTable(query); for (int i = 0; i < table.Rows.Count; i++) { OrganizationIds.Add(table.Rows[i][0].ToString()); OrganizationNames.Add(table.Rows[i][1].ToString()); } JSCode1 = "var availableOrgs = ["; for (int i = 0; i < OrganizationIds.Count; i++) { JSCode1 += " {label:\"" + OrganizationNames[i] + "\", idwka:\"" + OrganizationIds[i] + "\", value:\"" + OrganizationNames[i] + "\"}"; if (i != OrganizationIds.Count - 1) { JSCode1 += ","; } } JSCode1 += "];"; JSCode2 = "var availableCourses = ["; query = "SELECT IdCourse, Name FROM Courses WHERE IsDeleted=0"; table = DbMess.GetTable(query); for (int i = 0; i < table.Rows.Count; i++) { JSCode2 += " {label:\"" + table.Rows[i][1].ToString() + "\", idwka:\"" + table.Rows[i][0].ToString() + "\", value:\"" + table.Rows[i][1].ToString() + "\"}"; if (i != table.Rows.Count - 1) { JSCode2 += ","; } } JSCode2 += "];"; }