public ActionResult Delete(int id, FormCollection collection) { try { _gearRep.Delete(id); _gearRep.Save(); return(RedirectToAction("Index")); } catch { return(View()); } }
public IActionResult Delete(int id) { // Id 1 is the permanent 'dummy' gear to keep old reservations in the database if (id == 1) { return(BadRequest()); } var reservations = _reservationRepository.GetByGear(id); foreach (Reservation reservation in reservations) { // Set to reserved, "unavailable" gear reservation.GearId = 1; _reservationRepository.Update(reservation); } _gearRepository.Delete(id); return(NoContent()); }