コード例 #1
0
        public ActionResult Edit(GiaoVien_TaiKhoan_Model viewModel)
        {
            if (ModelState.IsValid)
            {
                TaiKhoan taiKhoan = new TaiKhoan();
                taiKhoan.UserName   = viewModel.UserName;
                taiKhoan.Password   = viewModel.Password;
                taiKhoan.Role       = viewModel.Role;
                taiKhoan.TaiKhoanID = (int)viewModel.TaiKhoanID;
                taiKhoanRepository.Update(taiKhoan);
                var taiKhoan_updated = taiKhoanRepository.GetByUsername(viewModel.UserName);

                GiaoVien giaoVien = new GiaoVien();
                giaoVien.GiaoVienID = viewModel.GiaoVienID;
                giaoVien.TaiKhoanID = taiKhoan_updated.TaiKhoanID;
                giaoVien.TenGV      = viewModel.TenGV;
                giaoVien.NgaySinh   = viewModel.NgaySinh;
                giaoVien.GioiTinh   = viewModel.GioiTinh;
                giaoVien.Email      = viewModel.Email;
                giaoVien.MonHocID   = viewModel.MonHocID;
                giaoVien.HocViID    = viewModel.HocViID;
                giaoVienRepository.Update(giaoVien);
                return(RedirectToAction("Index"));
            }
            //ViewBag.HocViID = new SelectList(db.HocVis, "HocViID", "TenHocVi", giaoVien.HocViID);
            //ViewBag.MonHocID = new SelectList(db.MonHocs, "MonHocID", "TenMH", giaoVien.MonHocID);
            //ViewBag.TaiKhoanID = new SelectList(db.TaiKhoans, "TaiKhoanID", "UserName", giaoVien.TaiKhoanID);
            //return View(giaoVien);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult ChangePassword(ChangePassword_Model model)
        {
            var taiKhoan = taiKhoanRepository.GetById((int)Session["TaiKhoanID_session"]);

            if (taiKhoan.Password == model.OldPassword)
            {
                taiKhoan.Password = model.NewPassword;
                taiKhoanRepository.Update(taiKhoan);
                ViewBag.AlertMessage = "1";
                return(View());
            }
            else
            {
                ViewBag.AlertMessage = "0";
                return(View());
            }
        }
コード例 #3
0
        public ActionResult Edit(HocSinh_TaiKhoan_Model viewModel)
        {
            if (ModelState.IsValid)
            {
                TaiKhoan taiKhoan = new TaiKhoan();
                taiKhoan.TaiKhoanID = (int)viewModel.TaiKhoanID;
                taiKhoan.UserName   = viewModel.UserName;
                taiKhoan.Password   = viewModel.Password;
                taiKhoan.Role       = viewModel.Role;
                taiKhoanRepository.Update(taiKhoan);

                HocSinh hocSinh = new HocSinh();
                hocSinh.HocSinhID  = viewModel.HocSinhID;
                hocSinh.TaiKhoanID = taiKhoan.TaiKhoanID;
                hocSinh.TenHS      = viewModel.TenHS;
                hocSinh.NgaySinh   = viewModel.NgaySinh;
                hocSinh.GioiTinh   = viewModel.GioiTinh;
                hocSinh.Email      = viewModel.Email;
                hocSinhRepository.Update(hocSinh);
                return(RedirectToAction("Index"));
            }
            //ViewBag.TaiKhoanID = new SelectList(db.TaiKhoans, "TaiKhoanID", "UserName", viewModel.TaiKhoanID);
            return(View(viewModel));
        }