/// <summary> /// this is data transfer object for student. /// Converting from presentation layer student object to business layer student object /// </summary> /// <param name="student"></param> /// <returns></returns> private static SLStudent.Student DTO_to_SL(PLStudent student) { SLStudent.Student slStudent = new SLStudent.Student(); slStudent.id = student.ID; slStudent.ssn = student.SSN; slStudent.first_name = student.FirstName; slStudent.last_name = student.LastName; slStudent.email = student.EmailAddress; slStudent.password = student.Password; slStudent.shoe_size = student.ShoeSize; slStudent.weight = student.Weight; slStudent.level = student.StudentLevel; slStudent.status = student.Status; slStudent.major = student.Major; slStudent.enrolled = null; //slStudent.enrolled = //DTO_to_SL(student.Enrollments); /*if (student.Enrollments != null) * { * slStudent.enrolled = new List<SLStudent.ScheduledCourse>();// SLSchedule.ScheduledCourse; * string sCourse= null; * for (int i = 0; i < student.Enrollments.Count(); i++) * { * sCourse = student.Enrollments[i]; * slStudent.enrolled[i] = student.Enrollments[i]; * } * }*/ return(slStudent); }
/// <summary> /// This is the data transfer object for student. /// Converting business layer student object to presentation layer student object /// </summary> /// <param name="student"></param> /// <returns> a presentation layer student object</returns> private static PLStudent DTO_to_PL(SLStudent.Student student) { PLStudent PLStudent = new PLStudent(); PLStudent.ID = student.id; PLStudent.FirstName = student.first_name; PLStudent.LastName = student.last_name; PLStudent.SSN = student.ssn; PLStudent.EmailAddress = student.email; PLStudent.Password = student.password; PLStudent.ShoeSize = student.shoe_size; PLStudent.Weight = student.weight; PLStudent.StudentLevel = student.level; PLStudent.Status = student.status; PLStudent.Major = student.major; if (student.enrolled != null) { PLStudent.Enrollments = new List <PLScheduledCourse>(); foreach (SLStudent.ScheduledCourse course in student.enrolled) { PLScheduledCourse s = DTO_to_PL(course); // method overloading PLStudent.Enrollments.Add(s); } } return(PLStudent); }
/// <summary> /// update existing student info /// </summary> /// <param name="s"></param> public static void UpdateStudent(PLStudent s) { SLStudent.Student newStudent = DTO_to_SL(s); SLStudent.ISLStudent SLStudent = new SLStudent.SLStudentClient(); string[] errors = new string[0]; SLStudent.UpdateStudentRequest request = new SLStudent.UpdateStudentRequest(newStudent, errors); SLStudent.UpdateStudent(request); }
/// <summary> /// Get student detail /// </summary> /// <param name="id"></param> /// <returns></returns> public static PLStudent GetStudentDetail(string id) { SLStudent.ISLStudent SLStudent = new SLStudent.SLStudentClient(); string[] errors = new string[0]; SLStudent.GetStudentRequest request = new SLStudent.GetStudentRequest(id, errors); SLStudent.GetStudentResponse response = SLStudent.GetStudent(request); SLStudent.Student newStudent = response.GetStudentResult; // this is the data transfer object code... if (newStudent == null) { System.Diagnostics.Debug.WriteLine("DALStudent getStudentDetail is f****d up!"); } return(DTO_to_PL(newStudent)); }