private void DeleteAward() { if (listOfAwards != null && listOfAwards.GetList().Count() > 0) { int id = (int)ctrGridAward.Rows[ctrGridAward.SelectedCells[0].RowIndex].Cells[2].Value; Award deletedAward = new Award(); foreach (Award aw in listOfAwards.GetList()) { if (aw.AwardId == id) { deletedAward = aw; } } var form = new ConfirmForm(deletedAward); if (form.ShowDialog() == DialogResult.OK) { foreach (User user in listOfUsers.GetList()) { user.Awards.Remove(deletedAward); } listOfAwards.Remove(deletedAward); DisplayAwards(); DisplayUsers(); } } }
public ActionResult Delete(int id, FormCollection collection) { try { listOfAwards.Remove(id); return(RedirectToAction("Index")); } catch { return(View()); } }
private void DeleteAward() { if (listOfAwards != null & listOfAwards.GetList().Count() > 0) { var form = new ConfirmForm((Award)ctrGridAward.SelectedCells[0].OwningRow.DataBoundItem); if (form.ShowDialog() == DialogResult.OK) { var deletedAward = (Award)ctrGridAward.SelectedCells[0].OwningRow.DataBoundItem; foreach (User user in listOfUsers.GetList()) { user.Awards.Remove(deletedAward); } listOfAwards.Remove(deletedAward); DisplayAwards(); DisplayUsers(); } } }