Beispiel #1
0
        // GET: Admin/GiaoVienManagement/Delete/5
        public ActionResult Delete(int id)
        {
            GiaoVien delete_GiaoVien = giaoVienRepository.GetById(id);
            TaiKhoan delete_TaiKhoan = taiKhoanRepository.GetById((int)delete_GiaoVien.TaiKhoanID);

            giaoVienRepository.Delete(delete_GiaoVien);
            taiKhoanRepository.Delete(delete_TaiKhoan);
            return(RedirectToAction("Index"));
        }
        // GET: Admin/HocSinhManagement/Delete/5
        public ActionResult Delete(int id)
        {
            HocSinh hocSinh = hocSinhRepository.GetById(id);

            if (hocSinh.TaiKhoanID != null)
            {
                TaiKhoan taiKhoan = taiKhoanRepository.GetById((int)hocSinh.TaiKhoanID);
                hocSinhRepository.Delete(hocSinh);
                taiKhoanRepository.Delete(taiKhoan);
            }
            else
            {
                hocSinhRepository.Delete(hocSinh);
            }
            return(RedirectToAction("Index"));
        }