// GET: Admin/DeThiManagement/Delete/5 public ActionResult Delete(int id) { DeThi deThi = deThiRepository.GetById(id); deThiRepository.Delete(deThi); return(RedirectToAction("Index")); }
private void btnXoaDT_Click(object sender, EventArgs e) { string maDT = dgvDeThi.SelectedRows[0].Cells["MaDT"].Value.ToString(); DeThi dt = _deThiRepository.FindByCondition(p => p.MaDeThi.Equals(maDT)).Single(); List <DeThi_CauHoi> deThi_CauHois = _dt_chRepository.FindByCondition(p => p.MaDT.Equals(maDT)).ToList(); foreach (var item in deThi_CauHois) { _dt_chRepository.Delete(item); } _dt_chRepository.Update(); _deThiRepository.Delete(dt); _deThiRepository.Update(); ReLoad(); }