Ejemplo n.º 1
0
        public static bool RegisterTeacher(TeacherDTO teacher)
        {
            try
            {
                var teacherDal = TeacherDTO.TeacherConvertDAL(teacher);
                using (DAL.SchoolEntities DB = new DAL.SchoolEntities())
                {
                    //TeacherDTO myteacher = new TeacherDTO();
                    //myteacher.TeacherId = teacher.TeacherId;
                    //myteacher.TeacherName = teacher.TeacherName;
                    //myteacher.TeacherEmail = teacher.TeacherEmail;
                    //myteacher.TeacherPhone = teacher.TeacherPhone;
                    //myteacher.TeacherAge = teacher.TeacherAge;
                    //myteacher.Describe = teacher.Describe;
                    //myteacher.Password = teacher.Password;
                    //myteacher.UserNmae = teacher.UserNmae;

                    DB.Teachers.Add(teacherDal);
                    DB.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static TeacherDTO LoginTeacher(string username, string password)
        {
            using (DAL.SchoolEntities DB = new DAL.SchoolEntities())
            {
                UserDTO newteacher = new UserDTO();

                // var a = DB.Teachers.FirstOrDefault(t => t.UserNmae == username && t.Password == password);

                var teacher = DB.Teachers.FirstOrDefault(p => p.Password == password && p.UserNmae == username);
                return(TeacherDTO.TeacherConvertDTO(teacher));
            }
        }
Ejemplo n.º 3
0
        public static void RegisterUser(UserDTO user)
        {
            var userDal = UserDTO.UserConvertDAL(user);

            using (DAL.SchoolEntities DB = new DAL.SchoolEntities())
            {
                //var y = DB.Users.Where(t => t.UserPassword == user.UserPassword).ToList();
                //if(y!=null)
                //    DB.Users.Add(userDal);
                DB.Users.Add(userDal);
            }
        }
Ejemplo n.º 4
0
        public static List <TeacherDTO> GetAllTeacher()
        {
            using (DAL.SchoolEntities DB = new DAL.SchoolEntities())
            {
                List <TeacherDTO> t = new List <TeacherDTO>();

                foreach (var item in DB.Teachers)
                {
                    t.Add(TeacherDTO.TeacherConvertDTO(item));
                }
                return(t);
            }
        }
Ejemplo n.º 5
0
 public static List <User> GetAllUsers(int teacherid)
 {
     using (DAL.SchoolEntities DB = new DAL.SchoolEntities())
     {
         List <UserDTO> listUsers = new List <UserDTO>();
         //עוברים על טבלת קורסים ושולפים את הקורסים של המורה הנוחכי
         var e = DB.Courses.Where(t => t.IdTeacher == teacherid).ToList();
         //רצינו לשלוף את הקבוצות של אותו הקורס והכל בשביל שנוכל להגיע לתלמיד שנמצא ב groupforuser
         DB.Groups.Where(y => y.CodeCourse = e.CourseId);
         //איך אנחנו ניגשות לתלמידים של אותו מורה בדרך ישרה יותר
         //תודה אין מילים נשמהההה!
     }
 }
Ejemplo n.º 6
0
 public static bool LoginUser(string username, string password)
 {
     using (DAL.SchoolEntities DB = new DAL.SchoolEntities())
     {
         UserDTO newuser = new UserDTO();
         foreach (var item in DB.Users)
         {
             if (item.UserName == username && item.UserPassword == password)
             {
                 return(true);
             }
         }
         newuser.UserName     = username;
         newuser.UserPassword = password;
         DB.Users.Add(UserDTO.UserConvertDAL(newuser));
         return(false);
     }
 }