// 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")); }
private void btnXoaGV_Click(object sender, EventArgs e) { string oldGV = dgvGiaoVien.SelectedRows[0].Cells["MaGV"].Value.ToString(); GiaoVien gv = _giaoVienRepository.FindByCondition(p => p.MaGV.Equals(oldGV)).Single(); int nguoiDungID = gv.NguoiDungID; _giaoVienRepository.Delete(gv); _giaoVienRepository.Update(); NguoiDung nguoiDung = _nguoiDungRepository.FindByCondition(p => p.IDNguoiDung.Equals(nguoiDungID)).Single(); _nguoiDungRepository.Delete(nguoiDung); _nguoiDungRepository.Update(); LoadGiaoVien(); }