public static bool AddCourseCode(int id, CourseCode c) { bool result; using (var connection = DbConn.GetConnection()) { connection.Open(); SqlCommand insertCommand = new SqlCommand("mcftacademics.dbo.AddCourseCode", connection); insertCommand.CommandType = System.Data.CommandType.StoredProcedure; insertCommand.Parameters.AddWithValue("@id", id); insertCommand.Parameters.AddWithValue("@code", c.Code); insertCommand.Parameters.AddWithValue("@startDate", c.From); insertCommand.Parameters.AddWithValue("@endDate", c.To); insertCommand.Parameters.AddWithValue("@semester", c.Semester); int rows = insertCommand.ExecuteNonQuery(); if (rows > 0) { result = true; } else { result = false; } } return(result); }
public IActionResult OnPost() { try { List <CourseCode> coursecodes = new List <CourseCode>(); for (int i = 0; i < Convert.ToInt32(Request.Form["count"]); i++) { //Still not sure if the semester changes per course code or if thats a course dependent thing CourseCode coursecode = new CourseCode(Request.Form["txtCode+" + i], Convert.ToDateTime(Request.Form["txtStartDate+" + i]), Convert.ToDateTime(Request.Form["txtEndDate+" + i]), Convert.ToInt32(Request.Form["semester+" + i])); coursecodes.Add(coursecode); } bool result = CourseCode.UpdateCourseCodes(coursecodes, Convert.ToInt32(Request.Form["courseId"])); if (result) { return(RedirectToPage("CourseCodeEditor", new { id = Convert.ToInt32(Request.Form["courseId"]), alertMessage = "Course Codes have been updated" })); } else { throw new Exception(); } } catch (Exception ex) { return(RedirectToPage("CourseCodeEditor", new { id = Convert.ToInt32(Request.Form["courseId"]), alertMessage = "Error: You have entered invalid data" })); } }
/// <summary> /// Update Course Code of the Course /// </summary> /// <param name="courseID">CourseId</param> private void updateCourseCode(long courseID) { CourseCodeDataAccess codeDAL = new CourseCodeDataAccess(); codeDAL.DeleteCourseCodeByCourseID(courseID); // Delete course codes of the Course string[] descList = splitString(courseDesc); string[] typeList = splitString(courseType); //string[] typeList = courseType.Split('|'); if (!courseType.Equals(string.Empty)) { for (int i = 0; i < typeList.Length; i++) { CourseCode code = new CourseCode(); code.Description = descList[i]; code.CodeID = Convert.ToInt32(typeList[i]); code.CourseID = courseID; try { codeDAL.AddCourseCode(code); // Add course Code } catch (Exception ex) { Session["AdminCourseCodeFailed"] = "yes"; } } } populateCourseCodeInfo(courseID); // on Load script for populating the Course code after page refresh. }
//database - check duplicates moved to super // public static void CheckDuplicatesInGrid(DataGridView dataGridView, int rowIndex, string revertName) // { // if (rowIndex < 0) return; // string courseNameAfterUpdate = dataGridView[0, rowIndex].CellValue(); // for (int i = 0; i < dataGridView.RowCount; i++) // { // if (dataGridView[0, i].CellValue() == courseNameAfterUpdate && i != rowIndex) // { // EditorUtilities.ShowWarning( // "Warning: Duplicate course names not allowed, reverting back to previous name"); // dataGridView[0, rowIndex].Value = revertName; // } // } // } //***************************************** // PARSER //***************************************** public override void ParseCtt(string line) { var words = GetStringData(line); var i = 0; CourseCode = words[i++]; HoursPerDay = CourseCode.EndsWith("_WK") ? 3 : 2; TeacherGroup = new TeacherGroup(words[i++]); if (EntityDataBase.TeacherGroups.IndexOf(TeacherGroup) == -1) { EntityDataBase.TeacherGroups.Add(TeacherGroup); } LectureSize = int.Parse(words[i++]); MinimumWorkingDays = int.Parse(words[i++]); StudentSize = int.Parse(words[i++]); MinimumDate = ParseDate(words[i++], DateType.Minium); DeadlineDate = ParseDate(words[i++], DateType.Maximum); MaximumWorkingDays = ParseMaximumValue(words[i++]); if (words.Length >= 9) { IsPcNeeded = bool.Parse(words[i++]); } if (words.Length >= 10) { HoursPerDay = int.Parse(words[i++]); } }
public override string ToString() { StringBuilder result = new StringBuilder(); result.Append(Id.ToString()); result.Append("|"); result.Append(CourseCode.ToString()); result.Append("|"); result.Append(CourseName.ToString()); result.Append("|"); result.Append(Ects.ToString()); result.Append("|"); result.Append(CourseType.ToString()); result.Append("|"); result.Append(Zzu.ToString()); result.Append("|"); result.Append(SemesterNumber.ToString()); result.Append("|"); result.Append(StudyPlanID.ToString()); result.Append("|"); result.Append(CoursesGroupID.ToString()); result.Append("|"); result.Append(IsCoursesGroup.ToString()); return(result.ToString()); }
public override int GetHashCode() { unchecked { const int randomPrime = 397; int hashCode = Id.GetHashCode(); hashCode = (hashCode * randomPrime) ^ (FullDocumentFileName != null ? FullDocumentFileName.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (FreeSnippetFileName != null ? FreeSnippetFileName.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (OriginalFileName != null ? OriginalFileName.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (Title != null ? Title.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (Description != null ? Description.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (Degree != null ? Degree.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (CourseName != null ? CourseName.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (CourseCode != null ? CourseCode.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (Year != null ? Year.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ UniversityId.GetHashCode(); hashCode = (hashCode * randomPrime) ^ UploadedBy.GetHashCode(); hashCode = (hashCode * randomPrime) ^ UploadedAt.GetHashCode(); hashCode = (hashCode * randomPrime) ^ (DeletedAt != null ? DeletedAt.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ IsFree.GetHashCode(); hashCode = (hashCode * randomPrime) ^ (IsApproved != null ? IsApproved.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (Hash != null ? Hash.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ (MinHashSignature != null ? MinHashSignature.GetHashCode() : 0); hashCode = (hashCode * randomPrime) ^ CategoryId.GetHashCode(); return(hashCode); } }
public ActionResult OnGetAjax(string code) { if (code != null) { List <string> prereqCodes = CourseCode.SearchCourseCodes(code); JsonResult result = new JsonResult(prereqCodes); return(result); } return(new JsonResult("")); }
public override int GetHashCode() { unchecked { var hashCode = Id; hashCode = (hashCode * 397) ^ (CourseCode != null ? CourseCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); return(hashCode); } }
public ActionResult Create(CourseCode courseCode) { try { courseCodeService.Add(courseCode); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, CourseCode courseCode) { try { courseCodeService.Update(courseCode); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult OnGetCheckPrereqCode(string code) { if (code != null) { if (CourseCode.GetIdByCourseCode(code) == 0) { return(new JsonResult(false)); } else { return(new JsonResult(true)); } } return(new JsonResult(false)); }
//Warning confusing code ahead public void CheckArray() { try { conn = new SqlConnection(@"Data Source=MIRAZ-PC\SQLEXPRESS;Initial Catalog=ClassRoutine;Integrated Security=True"); conn.Open(); query = "Select CourseCredit from RoutineInfo where TeacherInitials = 'SY'"; tempCourseCredit = new SqlCommand(query, conn).ExecuteScalar().ToString(); CourseCredit = Double.Parse(tempCourseCredit); CourseCredit = Double.Parse(tempCourseCredit); YearDeterminingCourseCodeDigit = Convert.ToInt32(CourseCode.Substring(4, 1)); if (YearDeterminingCourseCodeDigit == 1) { row = 1; } else if (YearDeterminingCourseCodeDigit == 2) { row = 7; } else if (YearDeterminingCourseCodeDigit == 3) { row = 13; } else { row = 19; } SemesterDeterminingCourseCodeDigit = Convert.ToInt32(CourseCode.Substring(5, 1)); if (CourseCredit == 1.5 || CourseCredit == 0.75) { DoubleTimeSlotAssign(); } else { SingleTimeSlotAssign(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Check Array", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { conn.Close(); } }
public Lesson(List <LessonInfo> infos, DateTime start, int duration, int priority, CourseCode code, bool isStandard, bool isEvent, int id, int lessonId, int lessonNumber, LessonCode lessonCode, CellState cellState, string lessonText, string periodText) { Infos = infos; Start = start; Duration = duration; Priority = priority; Code = code; IsStandard = isStandard; IsEvent = isEvent; Id = id; LessonId = lessonId; LessonNumber = lessonNumber; LessonCode = lessonCode; CellState = cellState; LessonText = lessonText; PeriodText = periodText; }
public void CheckCourseCode() { if (this.Visa == "Student") { CoEDateChecker = 0; bool aaa = true; if (this.CourseCode.Contains("GE") || this.CourseCode.Contains("GRD") || this.CourseCode.Contains("GRN") || this.CourseCode.Contains("GRND")) { this.CourseCode = "GE"; } if (this.CourseCode.Contains("IELTS")) { this.CourseCode = "IELTS"; } if (CoEDescription == null || !CourseCode.Contains(CoEDescription)) { aaa = false; CoEDateChecker += 4; } if (this.StartDate != this.CoEStartDate) { aaa = false; CoEDateChecker += 1; } if (this.EndDate != this.CoEEndDate) { CoEDateChecker += 2; aaa = false; } if (aaa) { this.CoEStatus = "Okay"; } else { this.CoEStatus = "!!!"; } } }
public static CourseCode GetNewestCourseCodeById(int id) { CourseCode courseCode = null; using (var connection = DbConn.GetConnection()) { connection.Open(); SqlCommand selectCommand = new SqlCommand("mcftacademics.dbo.SelectNewestCourseCodeById", connection); selectCommand.CommandType = System.Data.CommandType.StoredProcedure; selectCommand.Parameters.AddWithValue("@id", id); //execute the sql statement SqlDataReader reader = selectCommand.ExecuteReader(); //loop through the resultset if (reader.Read()) { courseCode = CourseCodeFromRow(reader); } } return(courseCode);//return the coursecode }
private void FilterClasses(List <Course> Fall, List <Course> Winter, List <Course> Both) { foreach (string CourseCode in CoursesToTake) { string code = CourseCode.Split('_')[0]; Course course = CourseByCode(code); if (HasSemester(code, Semester.Fall) && HasSemester(code, Semester.Winter)) { Both.Add(course); } else if (HasSemester(code, Semester.Fall)) { Fall.Add(course); } else if (HasSemester(code, Semester.Winter)) { Winter.Add(course); } } }
public static List <CourseCode> GetAllCourseCodesById(int id) { List <CourseCode> courseCodes = new List <CourseCode>(); using (var connection = DbConn.GetConnection()) { connection.Open(); SqlCommand selectCommand = new SqlCommand("mcftacademics.dbo.SelectCourseCodesById", connection); selectCommand.CommandType = System.Data.CommandType.StoredProcedure; selectCommand.Parameters.AddWithValue("@courseId", id); //execute the sql statement SqlDataReader reader = selectCommand.ExecuteReader(); //loop through the resultset while (reader.Read()) { CourseCode c = CourseCodeFromRow(reader); courseCodes.Add(c); } } return(courseCodes);//return the list of coursecodes }
public override bool FillDataFromGridline(DataGridView dataGridView, int rowIndex) { var i = 0; CourseCode = dataGridView[i++, rowIndex].CellValue(); HoursPerDay = CourseCode.EndsWith("_WK") ? 3 : 2; TeacherGroup = new TeacherGroup(dataGridView[i++, rowIndex].CellValue()); if (EntityDataBase.TeacherGroups.IndexOf(TeacherGroup) == -1) { EntityDataBase.TeacherGroups.Add(TeacherGroup); } LectureSize = int.Parse(dataGridView[i++, rowIndex].CellValue()); MinimumWorkingDays = int.Parse(dataGridView[i++, rowIndex].CellValue()); StudentSize = int.Parse(dataGridView[i++, rowIndex].CellValue()); MinimumDate = ParseDate(dataGridView[i++, rowIndex].CellValue(), DateType.Minium); DeadlineDate = ParseDate(dataGridView[i++, rowIndex].CellValue(), DateType.Maximum); MaximumWorkingDays = ParseMaximumValue(dataGridView[i++, rowIndex].CellValue()); if (dataGridView[i, rowIndex].CellValue() == null) { IsPcNeeded = false; i++; } else { IsPcNeeded = bool.Parse(dataGridView[i++, rowIndex].CellValue()); } if (dataGridView[i, rowIndex].CellValue() != null) { HoursPerDay = int.Parse(dataGridView[i++, rowIndex].CellValue()); } return(true); }
private bool UploadExcelFile() { try { //get the course id from query string List <Course> courseList = new List <Course>(); //create the file loacton FileStream oFileStream = File.Create(fileLocation); foreach (byte b in FileUpload1.FileBytes) { oFileStream.WriteByte(b); } oFileStream.Close(); Course oCourse = null; DataTable oDataTable = LACESUtilities.ReadXLFile(fileLocation, "Courses"); bool useNext = false; ApprovedProvider provider = (ApprovedProvider)Session[LACESConstant.SessionKeys.LOGEDIN_APPROVED_PROVIDER]; // get approved provider information from Session System.Text.StringBuilder sbResult = new System.Text.StringBuilder(); foreach (DataRow dr in oDataTable.Rows) { oCourse = new Course(); string strCol1 = dr[0].ToString().Trim(); if (useNext) { bool isAllRequiredFilled = true; string strCourseTitle = dr[0].ToString().Trim(); oCourse.Title = strCourseTitle; string strCourseRegUrl = dr[1].ToString().Trim(); oCourse.Hyperlink = strCourseRegUrl; string strRegEligibility = dr[2].ToString().Trim(); oCourse.RegistrationEligibility = strRegEligibility; string strStartDate = dr[3].ToString().Trim(); DateTime dtStart; if (DateTime.TryParse(strStartDate, out dtStart)) { oCourse.StartDate = dtStart; } else { oCourse.StartDate = (DateTime)SqlDateTime.MinValue; } string strEndDate = dr[4].ToString().Trim(); DateTime dtEndDate; if (DateTime.TryParse(strEndDate, out dtEndDate)) { oCourse.EndDate = dtStart; } else { oCourse.EndDate = (DateTime)SqlDateTime.MinValue; } string strDescription = dr[5].ToString().Trim(); oCourse.Description = strDescription; string strCity = dr[6].ToString().Trim(); oCourse.City = strCity; string strState = dr[7].ToString().Trim(); oCourse.StateProvince = strStartDate; string strDistanceEd = dr[8].ToString(); if (strDistanceEd.Length == 0) { oCourse.DistanceEducation = " "; } else { oCourse.DistanceEducation = strDistanceEd; } string strCourseEquivalency = dr[9].ToString(); if (strCourseEquivalency.Length == 0) { oCourse.CourseEquivalency = " "; } else { oCourse.CourseEquivalency = strCourseEquivalency; } string strSubjects = dr[10].ToString().Trim(); oCourse.Subjects = strSubjects; string strHealthSafety = dr[11].ToString().Trim(); oCourse.Healths = strHealthSafety; string strPersonalDevelopmentHours = dr[12].ToString().Trim(); oCourse.Hours = strPersonalDevelopmentHours; string strLearningOutcomes = dr[13].ToString().Trim(); oCourse.LearningOutcomes = strLearningOutcomes; string strInstructors = dr[14].ToString().Trim(); oCourse.Instructors = strInstructors; string strNoProprietary = dr[15].ToString().Trim(); string strCourseCode = dr[16].ToString().Trim(); oCourse.ProviderID = provider.ID; string strCourseErrors = LACESUtilities.CheckCourseValid(oCourse); //oCourse.OrgStateCourseIDNumber = strCourseCode; if (strCourseErrors.Length == 0) { oCourse.Status = "NP"; } else { oCourse.Status = "IC"; } CourseDataAccess cd = new CourseDataAccess(); long lngCourseID; if (long.TryParse(cd.AddCourseDetails(oCourse).ToString(), out lngCourseID)) { if (strCourseCode.Trim().Length > 0) { CourseCodeDataAccess codeDAL = new CourseCodeDataAccess(); CourseCode code = new CourseCode(); //code.Description = descList[i]; code.CodeID = Convert.ToInt32(strCourseCode); code.CourseID = lngCourseID; try { codeDAL.AddCourseCode(code); // Add course Code } catch (Exception ex) { uiLblResults.Text = ex.Message; Response.End(); } } } if (strCourseErrors.Length == 0) { sbResult.Append("SUCCESS" + lngCourseID.ToString() + " - " + oCourse.Title); } else { sbResult.Append(lngCourseID.ToString() + " - " + oCourse.Title + "<br />" + strCourseErrors); } } if (strCol1 == "*Course Title") { useNext = true; } //long newCourse = cd.AddCourseDetails(oCourse); } uiLblResults.Text = sbResult.ToString(); } catch (Exception ex) { Response.Write(ex.Message); Response.End(); } return(false); }
public override int GetHashCode() { return(CourseCode.GetHashCode()); }
public HttpResponseMessage GetSearchResult(object data) { var db = DbUtils.GetDBConnection(); db.Connection.Open(); IEnumerable <IDictionary <string, object> > response = null; var jsonData = JsonConvert.SerializeObject(data); var dictJson = JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonData); object actionObject; dictJson.TryGetValue("actionName", out actionObject); string Action = actionObject.ToString(); string input_queryapi = ""; object userName; dictJson.TryGetValue("queried_by_username", out userName); if (Action.Equals("GetTableSchema")) { object tableName; dictJson.TryGetValue("TableName", out tableName); input_queryapi = tableName.ToString(); response = db.Query("INFORMATION_SCHEMA.COLUMNS").Select("COLUMN_NAME").WhereRaw("TABLE_NAME = ?", tableName).Get().Cast <IDictionary <string, object> >(); return(Request.CreateResponse(HttpStatusCode.OK, response)); } if (Action.Equals("GetInstructorByName")) { object empName; dictJson.TryGetValue("EmpName", out empName); input_queryapi = empName.ToString(); response = db.Query("Employee").WhereRaw("lower(EmpName) = ?", empName).Get().Cast <IDictionary <string, object> >(); //response = db.Query("Employee").WhereRaw("lower(EmpName) = ?", "dr. abdul aziz").Get().Cast<IDictionary<string, object>>(); } else if (Action.Equals("GetInstructorByEmail")) { object email; dictJson.TryGetValue("Email", out email); input_queryapi = email.ToString(); response = db.Query("Employee").WhereRaw("lower(Email) = ?", email).Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetInstructorByRank")) { object designationTitle; dictJson.TryGetValue("DesignationTitle", out designationTitle); input_queryapi = designationTitle.ToString(); response = db.Query("Employee").Join("Designation", "Employee.DesignationID", "Designation.DesignationID").Where("DesignationTitle", designationTitle).Get().Cast <IDictionary <string, object> >(); //get product by id=1 } else if (Action.Equals("GetInstructorByDepartment")) { object departmentID; dictJson.TryGetValue("DepartmentID", out departmentID); input_queryapi = departmentID.ToString(); response = db.Query("Employee").Join("Department", "Employee.DepartmentID", "Department.DepartmentID").Where("Department.DepartmentID", departmentID).Get().Cast <IDictionary <string, object> >(); //get product by id=1 } else if (Action.Equals("GetInstructorByNameStartsWith")) { object startNamePrefix; dictJson.TryGetValue("EmpName", out startNamePrefix); string prefixString = startNamePrefix.ToString() + "%"; input_queryapi = startNamePrefix.ToString(); response = db.Query("Employee").WhereLike("EmpName", prefixString).Get().Cast <IDictionary <string, object> >(); //get product by id=1 } else if (Action.Equals("GetInstructorByNameContains")) { object startNamePrefix; dictJson.TryGetValue("EmpName", out startNamePrefix); string prefixString = "%" + startNamePrefix.ToString() + "%"; input_queryapi = startNamePrefix.ToString(); response = db.Query("Employee").WhereLike("EmpName", prefixString).Get().Cast <IDictionary <string, object> >(); //get product by id=1 } else if (Action.Equals("GetInstructorByCourseName")) { object courseName; dictJson.TryGetValue("CourseName", out courseName); input_queryapi = courseName.ToString(); response = db.Query("Employee").Join("CourseFaculty", "Employee.EmpID", "CourseFaculty.EmpID").Join("CourseOffered", "CourseOffered.CourseOfferedID", "CourseFaculty.CourseOfferedID").Join("Course", "CourseOffered.CourseID", "Course.CourseID").Where("CourseName", courseName).Get().Cast <IDictionary <string, object> >(); //get product by id=1 } else if (Action.Equals("GetInstructorByCourseCode")) { object courseCode; dictJson.TryGetValue("CourseCode", out courseCode); input_queryapi = courseCode.ToString(); response = db.Query("Employee").Join("CourseFaculty", "Employee.EmpID", "CourseFaculty.EmpID").Join("CourseOffered", "CourseOffered.CourseOfferedID", "CourseFaculty.CourseOfferedID").Join("Course", "CourseOffered.CourseID", "Course.CourseID").Where("CourseCode", courseCode).Get().Cast <IDictionary <string, object> >(); //get product by id=1 } else if (Action.Equals("GetCoursesTaughtByASpecificInstructor")) { object EmpName; dictJson.TryGetValue("EmpName", out EmpName); input_queryapi = EmpName.ToString(); response = db.Query("Semester").Select("CourseName").Join("CourseOffered", "Semester.SemesterID", "CourseOffered.SemesterID").Join("Course", "Course.CourseID", "CourseOffered.CourseID") .Join("CourseFaculty", "CourseFaculty.CourseOfferedID", "CourseOffered.CourseOfferedID") .Join("Employee", "Employee.EmpID", "CourseFaculty.EmpID") .Where("EmpName", EmpName).Get().Cast <IDictionary <string, object> >(); //get product by id=1 } else if (Action.Equals("GetCoursesTaughtByAInstructorInAParticularSemester")) { object semesterName; object empName; dictJson.TryGetValue("EmpName", out empName); dictJson.TryGetValue("SemesterName", out semesterName); input_queryapi = empName.ToString() + " " + semesterName.ToString(); response = db.Query("Semester").Join("CourseOffered", "Semester.SemesterID", "CourseOffered.SemesterID").Join("Course", "Course.CourseID", "CourseOffered.CourseID") .Join("CourseFaculty", "CourseFaculty.CourseOfferedID", "CourseOffered.CourseOfferedID") .Join("Employee", "Employee.EmpID", "CourseFaculty.EmpID") .Where("SemesterName", semesterName) .Where("EmpName", empName).Get().Cast <IDictionary <string, object> >(); //get product by id=1 } // STUDENT QUERIES else if (Action.Equals("GetStudentByName")) { object SName; dictJson.TryGetValue("SName", out SName); input_queryapi = SName.ToString(); response = db.Query("Student").WhereRaw("lower(SName) = ?", SName).Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetStudentByStudentID")) { object RollNumber; dictJson.TryGetValue("RollNumber", out RollNumber); input_queryapi = RollNumber.ToString(); response = db.Query("Student").WhereRaw("lower(RollNumber) = ?", RollNumber).Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetStudentByBatchID")) { object BatchID; dictJson.TryGetValue("BatchID", out BatchID); input_queryapi = BatchID.ToString(); response = db.Query("Student").WhereRaw("BatchID = ?", BatchID).Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetStudentsByDepartment")) { object DepartmentName; dictJson.TryGetValue("DepartmentName", out DepartmentName); input_queryapi = DepartmentName.ToString(); response = db.Query("Student").Join("Programme", "Programme.ProgrammeID", "Student.ProgrammeID").Join("Department", "Department.DepartmentID", "Programme.DepartmentID") .Where("DepartmentName", DepartmentName).Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetStudentsBySection")) { object SectionName; dictJson.TryGetValue("SectionName", out SectionName); input_queryapi = SectionName.ToString(); response = db.Query("Student").Join("Section", "Section.BatchID", "Student.BatchID") .Where("SectionName", SectionName).Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetStudentByNUEmail")) { object Email; dictJson.TryGetValue("Email", out Email); input_queryapi = Email.ToString(); response = db.Query("Student").Join("CandidateStudent", "CandidateStudent.CandidateID", "Student.CandidateID") .Where("Student.Email", Email).Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetStudentByPrimaryEmail")) { object Email; dictJson.TryGetValue("Email", out Email); input_queryapi = Email.ToString(); response = db.Query("Student").Join("CandidateStudent", "CandidateStudent.CandidateID", "Student.CandidateID") .Where("CandidateStudent.Email", Email).Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetStudentsByNameStartsWith")) { object startNamePrefix; dictJson.TryGetValue("Sname", out startNamePrefix); input_queryapi = startNamePrefix.ToString(); string prefixString = startNamePrefix.ToString() + "%"; response = db.Query("Student").WhereLike("Sname", prefixString).Get().Cast <IDictionary <string, object> >(); //get product by id=1 } else if (Action.Equals("GetStudentsByNameContains")) { object startNamePrefix; dictJson.TryGetValue("EmpName", out startNamePrefix); input_queryapi = startNamePrefix.ToString(); string prefixString = "%" + startNamePrefix.ToString() + "%"; response = db.Query("Student").WhereLike("Sname", prefixString).Get().Cast <IDictionary <string, object> >(); //get product by id=1 } else if (Action.Equals("GetStudentsByCourseName")) { object CourseName; dictJson.TryGetValue("CourseName", out CourseName); input_queryapi = CourseName.ToString(); response = db.Query("Student").Join("CourseEnrollment", "CourseEnrollment.StudentID", "Student.StudentID").Join("Course", "Course.CourseID", "CourseEnrollment.CourseID") .Where("CourseName", CourseName).Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetStudentsByCourseCode")) { object CourseCode; dictJson.TryGetValue("CourseCode", out CourseCode); input_queryapi = CourseCode.ToString(); response = db.Query("Student").Join("CourseEnrollment", "CourseEnrollment.StudentID", "Student.StudentID").Join("Course", "Course.CourseID", "CourseEnrollment.CourseID") .Where("CourseCode", CourseCode).Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetStudentsBySkill")) { response = db.Query("StudentSkills").Join("Skill", "Skill.SkillID", "StudentSkills.SkillID").Join("Student", "StudentSkills.StudentID", "Student.StudentID") .Get().Cast <IDictionary <string, object> >(); } else if (Action.Equals("GetStudentsByDomain")) { response = db.Query("Domain").Join("Skill", "Skill.DomainID", "Domain.DomainID").Join("StudentSkills", "StudentSkills.SkillID", "Skill.SkillID").Join("Student", "Student.StudentID", "StudentSkills.StudentID") .Get().Cast <IDictionary <string, object> >(); } //var db1 = DbUtils.GetDBConnection(); //db1.Connection.Open(); SqlConnection dbConnection = new SqlConnection(ConfigurationManager.AppSettings["SqlDBConn"].ToString()); try { /** * db1.Query("dbo.SearchLog").AsInsert(new * { * input_query = input_queryapi, * actionName = Action, * queried_by_username = userName.ToString() * }); **/ string query = "INSERT INTO dbo.SearchLog(input_query, actionName, queried_by_username) VALUES(@input_query,@actionName,@queried_by_username)"; using (SqlCommand command = new SqlCommand(query, dbConnection)) { command.Parameters.AddWithValue("@input_query", input_queryapi); command.Parameters.AddWithValue("@actionName", Action); command.Parameters.AddWithValue("@queried_by_username", userName.ToString()); dbConnection.Open(); int result = command.ExecuteNonQuery(); // Check Error if (result < 0) { Console.WriteLine("Error inserting data into Database!"); } } } catch (Exception e) { } return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public void Add(MountedCourse type) { lock (type) { if (Count == MountedCoureId.Length) { var newLength = MountedCoureId.Length + 1000; var _MountedCoureId = new string[newLength]; MountedCoureId.CopyTo(_MountedCoureId); MountedCoureId = _MountedCoureId; var _EnrollmentOption = new string[newLength]; EnrollmentOption.CopyTo(_EnrollmentOption); EnrollmentOption = _EnrollmentOption; var _Level = new string[newLength]; Level.CopyTo(_Level); Level = _Level; var _MaxLimit = new int[newLength]; MaxLimit.CopyTo(_MaxLimit); MaxLimit = _MaxLimit; var _MinLimit = new int[newLength]; MinLimit.CopyTo(_MinLimit); MinLimit = _MinLimit; var _Semester = new string[newLength]; Semester.CopyTo(_Semester); Semester = _Semester; var _AcademicYear = new string[newLength]; AcademicYear.CopyTo(_AcademicYear); AcademicYear = _AcademicYear; var _ProgramId = new string[newLength]; ProgramId.CopyTo(_ProgramId); ProgramId = _ProgramId; var _AssignedBy = new string[newLength]; AssignedBy.CopyTo(_AssignedBy); AssignedBy = _AssignedBy; var _Date = new System.DateTime[newLength]; Date.CopyTo(_Date); Date = _Date; var _CourseName = new string[newLength]; CourseName.CopyTo(_CourseName); CourseName = _CourseName; var _CourseCode = new string[newLength]; CourseCode.CopyTo(_CourseCode); CourseCode = _CourseCode; var _AssignedTo = new string[newLength]; AssignedTo.CopyTo(_AssignedTo); AssignedTo = _AssignedTo; var _Specialization = new string[newLength]; Specialization.CopyTo(_Specialization); Specialization = _Specialization; var _Category = new string[newLength]; Category.CopyTo(_Category); Category = _Category; var _Scoring = new bool[newLength]; Scoring.CopyTo(_Scoring); Scoring = _Scoring; var _Credit = new int[newLength]; Credit.CopyTo(_Credit); Credit = _Credit; } MountedCoureId.Span[Count] = type.MountedCoureId; EnrollmentOption.Span[Count] = type.EnrollmentOption; Level.Span[Count] = type.Level; MaxLimit.Span[Count] = type.MaxLimit; MinLimit.Span[Count] = type.MinLimit; Semester.Span[Count] = type.Semester; AcademicYear.Span[Count] = type.AcademicYear; ProgramId.Span[Count] = type.ProgramId; AssignedBy.Span[Count] = type.AssignedBy; Date.Span[Count] = type.Date; CourseName.Span[Count] = type.CourseName; CourseCode.Span[Count] = type.CourseCode; AssignedTo.Span[Count] = type.AssignedTo; Specialization.Span[Count] = type.Specialization; Category.Span[Count] = type.Category; Scoring.Span[Count] = type.Scoring; Credit.Span[Count] = type.Credit; Count++; } }
public IActionResult OnPost() { try { // in case we have to be on the same page again? Init(); RefreshShownCourses(); if (!ModelState.IsValid) { return(Page()); } if (!int.TryParse(Request.Form["courseId"], out int id)) { return(FailWithMessage("The ID is invalid.")); } // we have enough information for access control if (!AllowedToModify(id)) { return(FailWithMessage("You aren't allowed to change this course.")); } string name = Request.Form["courseTitle"]; string courseCode = Request.Form["courseCode"]; string description = Request.Form["description"]; if (!int.TryParse(Request.Form["credit"], out int credit) || credit < 0) { return(FailWithMessage("The credit is invalid.")); } if (!int.TryParse(Request.Form["lectureHours"], out int lectureHours) || lectureHours < 0) { return(FailWithMessage("The lecture hours are invalid.")); } if (!int.TryParse(Request.Form["labHours"], out int labHours) || labHours < 0) { return(FailWithMessage("The lab hours are invalid.")); } if (!int.TryParse(Request.Form["totalHours"], out int totalHours) || totalHours < 0) { return(FailWithMessage("The total hours are invalid.")); } if (!int.TryParse(Request.Form["examHours"], out int examHours) || examHours < 0) { return(FailWithMessage("The exam hours are invalid.")); } if (!decimal.TryParse(Request.Form["revisionNumber"], out decimal revisionNumber)) { return(FailWithMessage("The revision number is invalid.")); } string program = Request.Form["program"]; if (!bool.TryParse(Request.Form["accreditation"], out bool accreditation)) { return(FailWithMessage("The accreditation is invalid.")); } if (!int.TryParse(Request.Form["semester"], out int semester) || semester < 0) { return(FailWithMessage("The semester is invalid.")); } if (!DateTime.TryParse(Request.Form["startDate"], out DateTime startDate)) { return(FailWithMessage("The start date is invalid.")); } if (!DateTime.TryParse(Request.Form["endDate"], out DateTime endDate)) { return(FailWithMessage("The end date is invalid.")); } if (startDate > endDate) { return(FailWithMessage("The end of the course is before when it starts.")); } if (!int.TryParse(Request.Form["leadStaff"], out int leadStaffId) || leadStaffId < 0) { return(FailWithMessage("The lead staff ID is invalid.")); } Staff leadStaff = new Staff(leadStaffId, "", "lead"); Staff supportStaff = null; //Leave support staff as null unless there was a choice selected (its optional) if (!string.IsNullOrWhiteSpace(Request.Form["supportStaff"])) { if (!int.TryParse(Request.Form["supportStaff"], out int supportStaffId) || supportStaffId < 0) { return(FailWithMessage("The support staff ID is invalid.")); } supportStaff = new Staff(supportStaffId, "", "support"); } List <Prerequisite> prereqs = new List <Prerequisite>(); for (int i = 0; i < Convert.ToInt32(Request.Form["count"]); i++) { Prerequisite prereq = null; //Validation to see if the entered prereq coursecode is valid //If it isn't, the method will return 0 and then it will refresh with a message (should be no courseid of 0) int prereqId = CourseCode.GetIdByCourseCode(Request.Form["prereqCode+" + i]); if (prereqId == 0) { return(FailWithMessage("You entered a invalid Course Code for a Prerequisite")); } //If it returned a valid id, now check if its a coreq or a prereq if (Request.Form["reqRadio+" + i].Equals("prereq")) { prereq = new Prerequisite(id, prereqId, true, false); } else if (Request.Form["reqRadio+" + i].Equals("coreq")) { prereq = new Prerequisite(id, prereqId, false, true); } prereqs.Add(prereq); } if (Add == false) { Course c = new Course(id, name, credit, description, lectureHours, labHours, examHours, totalHours, revisionNumber, program, accreditation); c.UpdateCourse(leadStaff, supportStaff, prereqs); } else if (Add == true) { id = Course.AddCourse(new Course(id, name, credit, description, lectureHours, labHours, examHours, totalHours, revisionNumber, program, accreditation), leadStaff, supportStaff, prereqs); } // XXX: really flawed and prob won't be performant, we need proper course code management var oldCourseCode = !(Add ?? false) ? Course.GetCourseById(id)?.GetCourseCode()?.Code : null; if (courseCode != oldCourseCode) { CourseCode.AddCourseCode(id, new CourseCode(courseCode, startDate, endDate, semester)); } return(ShowAllCourses ? RedirectToPage("ManageCourses", "all") : RedirectToPage("ManageCourses")); } catch (Exception ex) { return(FailWithMessage("There was an exception from the system updating the course;" + "report this to an administrator: " + ex.Message)); } }