public RealStudent GetStudent(int id) { RealStudent cachedStudent = teacherStudentsCache.Find(student => student.Id == id); if (cachedStudent == null) { RealStudent newStudent = StudentUtils.UserToStudent(userController.GetById(id), subAreaController, areaController); teacherStudentsCache.Add(newStudent); System.Diagnostics.Debug.WriteLine("Student fetched is:" + newStudent.name); return(newStudent); } System.Diagnostics.Debug.WriteLine("Student cached is:" + cachedStudent.name); return(cachedStudent); }
// POST: api/EditStudent public void Post(object student, bool edit) { JObject juser = student as JObject; RealStudent realStudent = juser.ToObject <RealStudent>(); DAL.User user = new DAL.User(); if (edit == false) { user = StudentUtils.NewStudentToUser(realStudent); studentController.AddStudent(user, realStudent.subareas); } else { user = StudentUtils.EditedStudentToUser(realStudent, studentController.GetUserController()); bool changedName = (realStudent.name != realStudent.full_name); studentController.EditStudent(user, realStudent.subareas, changedName); } }
public Student UpdateStudent(Student student) { return(StudentUtils.IsValidatedStudnetModel(student) ? _studentRepo.UpdateStudent(student) : null); }