Example #1
0
        public static User EditedStudentToUser(RealStudent student, UserController userController)
        {
            User editedUser = userController.GetById(student.Id);

            editedUser.email     = student.email;
            editedUser.username  = student.username;
            editedUser.full_name = student.name;
            editedUser.birth     = DateTime.Parse(student.birth);
            editedUser.contact   = student.contact;
            return(editedUser);
        }
Example #2
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);
        }
Example #3
0
 public static User NewStudentToUser(RealStudent student)
 {
     return(new User
     {
         Id = student.Id,
         email = student.email,
         username = student.username,
         role = student.role,
         password = StringUtils.StringToSha("User_123"),
         created = DateTime.Today,
         until = DateTime.Today.AddYears(4), //TODO: OBSERVATION CHANGE FOR REAL FORM
         active = true,
         full_name = student.name,
         birth = DateTime.Parse(student.birth),
         contact = student.contact
     });
 }
        // 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);
            }
        }
Example #5
0
 public static void UpdateStudent(RealStudent student)
 {
     teacherStudentsCache.Remove(student);
 }