コード例 #1
0
 public bool Add(teacherviewmodel dept)
 {
     try
     {
         Teacher dd = new Teacher();
         dd.teacher_name    = dept.teacher_name;
         dd.id              = dept.id;
         dd.addres          = dept.addres;
         dd.cender          = dept.cender;
         dd.city            = dept.city;
         dd.user_name       = dept.user_name;
         dd.Email           = dept.Email;
         dd.leval_id        = dept.leval_id;
         dd.mobile          = dept.mobile;
         dd.password        = dept.password;
         dd.comfer_password = dept.comfer_password;
         var old = context.Teachers.FirstOrDefault(x => x.password == dept.comfer_password);
         if (old != null)
         {
             context.Teachers.Add(dd);
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #2
0
 public bool updatapassword(teacherviewmodel th)
 {
     try
     {
         var obj = context.Teachers.FirstOrDefault(x => x.id == th.id);
         if (obj != null)
         {
             obj.password = th.newpassword;
             if (th.newpassword == th.comfer_password)
             {
                 obj.comfer_password = th.comfer_password;
                 context.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #3
0
 public bool updata(teacherviewmodel dept)
 {
     try
     {
         var obj = context.Teachers.FirstOrDefault(x => x.id == dept.id);
         if (obj != null)
         {
             obj.Email  = dept.Email;
             obj.addres = dept.addres;
             obj.city   = dept.city;
             obj.mobile = dept.mobile;
             obj.photo  = dept.photo;
             obj.id     = dept.id;
             context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #4
0
        public JsonResult Addclass(teacherviewmodel dept)
        {
            bool x = rept.Add(dept);

            if (x)
            {
                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
        }
コード例 #5
0
        public JsonResult changepassword2(teacherviewmodel th)
        {
            bool log = rept.updatapassword(th);

            if (log)
            {
                return(Json(log, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
        }
コード例 #6
0
        public teacherviewmodel getall(int id)
        {
            var dept             = context.Teachers.FirstOrDefault(x => x.id == id);
            teacherviewmodel obj = new teacherviewmodel();

            obj.id     = dept.id;
            obj.Email  = dept.Email;
            obj.addres = dept.addres;
            obj.city   = dept.city;
            obj.mobile = dept.mobile;
            obj.photo  = dept.photo;

            return(obj);
        }
コード例 #7
0
        public JsonResult login(teacherviewmodel login)
        {
            bool log = rept.login(login);

            if (log)
            {
                Class_studentEntities context = new Class_studentEntities();
                var id = context.Teachers.Where(x => x.user_name == login.user_name && x.password == login.password).Select(x => x.id).FirstOrDefault();
                return(Json(id, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
        }
コード例 #8
0
        public bool login(teacherviewmodel adim)
        {
            Class_studentEntities dd = new Class_studentEntities();

            if (adim != null)
            {
                var old = dd.Teachers.Where(x => x.user_name == adim.user_name && x.password == adim.password).Select(x => x.id).FirstOrDefault();
                if (old != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #9
0
        public IEnumerable <teacherviewmodel> GetAll()
        {
            List <teacherviewmodel> obj = new List <teacherviewmodel>();

            foreach (var item in context.Teachers)
            {
                teacherviewmodel dd = new teacherviewmodel();
                dd.teacher_name    = item.teacher_name;
                dd.addres          = item.addres;
                dd.cender          = item.cender;
                dd.id              = item.id;
                dd.city            = item.city;
                dd.user_name       = item.user_name;
                dd.Email           = item.Email;
                dd.leval_id        = item.leval_id;
                dd.mobile          = item.mobile;
                dd.password        = item.password;
                dd.comfer_password = item.comfer_password;
                obj.Add(dd);
            }
            return(obj);
        }
コード例 #10
0
        public ActionResult updata(teacherviewmodel th)
        {
            var depts = rept.updata(th);

            return(Json(depts, JsonRequestBehavior.AllowGet));
        }
コード例 #11
0
        public ActionResult Edit(int id)
        {
            teacherviewmodel dep = rept.getall(id);

            return(Json(dep, JsonRequestBehavior.AllowGet));
        }