public void DeleteRequest(int id) { var request = GetRequestById(id); _repo.Delete(request); _repo.SaveChanges(); }
void TestRequestsRepository() { var newrequest = new Requests() { Description = "ZZZ", Justification = "ZZZ", RejectionReason = null, DeliveryMode = "Pickup", UserId = UsersRepository.GetByPk(2).Id }; if (!RequestsRepository.Insert(newrequest)) { throw new Exception("Request insert failed!"); } DisplayAllRequests(); newrequest.Description = "YYY"; if (!RequestsRepository.Update(newrequest)) { throw new Exception("Request update failed!"); } DisplayAllRequests(); if (!RequestsRepository.Delete(newrequest)) { throw new Exception("Request delete failed!"); } DisplayAllRequests(); }
public ActionResult DeleteConfirmed(int id) { if (db.Delete(id)) { return(RedirectToAction("Index")); } else { return(RedirectToAction("Delete/" + id)); } }