public static string EnrollCourse(string[] cid, int credithours) { string result = ""; DBFunctions db = new DBFunctions(); for (int i = 0; i < cid.Length;i++) { Enroll_Course enroll = new Enroll_Course { CourseID = Convert.ToInt16(cid[i]), Uid = uid, Status = 0 }; db.Enrollcourse(enroll); } StudentSelectedCredit obj = db.getStudentCredits(uid).FirstOrDefault(); if (obj == null) { StudentSelectedCredit temp = new StudentSelectedCredit(); temp.UserID = uid; temp.SelectedCourseCount = credithours; int check = -1; check = db.AddCreditHours(temp); if (check != 1) { result = "Success"; } } else { StudentSelectedCredit temp = new StudentSelectedCredit(); temp.UserID = uid; temp.SelectedCourseCount = credithours; temp.ID = obj.ID; db.UpdateCreditHours(temp); } return result; }
public static string EnrollCourse(string[] cid, int credithours) { string result = ""; DBFunctions db = new DBFunctions(); for (int i = 0; i < cid.Length; i++) { Enroll_Course enroll = new Enroll_Course { CourseID = Convert.ToInt16(cid[i]), Uid = uid, Status = 0 }; db.Enrollcourse(enroll); } StudentSelectedCredit obj = db.getStudentCredits(uid).FirstOrDefault(); if (obj == null) { StudentSelectedCredit temp = new StudentSelectedCredit(); temp.UserID = uid; temp.SelectedCourseCount = credithours; int check = -1; check = db.AddCreditHours(temp); if (check != 1) { result = "Success"; } } else { StudentSelectedCredit temp = new StudentSelectedCredit(); temp.UserID = uid; temp.SelectedCourseCount = credithours; temp.ID = obj.ID; db.UpdateCreditHours(temp); } return(result); }