Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 3
0
 public Student UpdateStudent(Student student)
 {
     return(StudentUtils.IsValidatedStudnetModel(student) ? _studentRepo.UpdateStudent(student) : null);
 }