Ejemplo n.º 1
0
        public ActionResult Create(GiaoVien_TaiKhoan_Model viewModel)
        {
            if (ModelState.IsValid)
            {
                TaiKhoan taiKhoan = new TaiKhoan();
                taiKhoan.UserName = viewModel.UserName;
                taiKhoan.Password = viewModel.Password;
                taiKhoan.Role     = viewModel.Role;
                taiKhoanRepository.Add(taiKhoan);

                GiaoVien giaoVien = new GiaoVien();
                giaoVien.TaiKhoanID = taiKhoanRepository.GetByUsername(taiKhoan.UserName).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.Add(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(View());
        }
Ejemplo n.º 2
0
        public ActionResult Register(HocSinh_TaiKhoan_Model viewModel)
        {
            if (ModelState.IsValid)
            {
                TaiKhoan taiKhoan = new TaiKhoan();
                taiKhoan.UserName = viewModel.UserName;
                taiKhoan.Password = viewModel.Password;
                taiKhoan.Role     = "student";
                taiKhoanRepository.Add(taiKhoan);

                HocSinh hocSinh = new HocSinh();
                hocSinh.TaiKhoanID = taiKhoanRepository.GetByUsername(viewModel.UserName).TaiKhoanID;
                hocSinh.TenHS      = viewModel.TenHS;
                hocSinh.NgaySinh   = viewModel.NgaySinh;
                hocSinh.GioiTinh   = viewModel.GioiTinh;
                hocSinh.Email      = viewModel.Email;
                hocSinhRepository.Add(hocSinh);
                return(RedirectToAction("Login"));
            }
            return(View(viewModel));
        }
        public ActionResult Create(HocSinh_TaiKhoan_Model viewModel)
        {
            if (ModelState.IsValid)
            {
                TaiKhoan taiKhoan = new TaiKhoan();
                taiKhoan.UserName = viewModel.UserName;
                taiKhoan.Password = viewModel.Password;
                taiKhoan.Role     = viewModel.Role;
                taiKhoanRepository.Add(taiKhoan);

                HocSinh hocSinh = new HocSinh();
                hocSinh.TaiKhoanID = taiKhoanRepository.GetByUsername(viewModel.UserName).TaiKhoanID;
                hocSinh.TenHS      = viewModel.TenHS;
                hocSinh.NgaySinh   = viewModel.NgaySinh;
                hocSinh.GioiTinh   = viewModel.GioiTinh;
                hocSinh.Email      = viewModel.Email;
                hocSinhRepository.Add(hocSinh);
                return(RedirectToAction("Index"));
            }

            //ViewBag.TaiKhoanID = new SelectList(db.TaiKhoans, "TaiKhoanID", "UserName", hocSinh.TaiKhoanID);
            return(View(viewModel));
        }