public bool DeleteDog(int DogId) { try { var mainMessages = mainDashboardRepo.GetMainMessageByDogID(DogId); if (mainMessages != null) { foreach (var item in mainMessages) { mainDashboardRepo.Delete(item); } } dogRepo.Delete(DogId); unitOfWork.Commit(); return(true); } catch (EntityException ex) { Debug.WriteLine(ex.Message); return(false); } finally { if (unitOfWork != null) { unitOfWork.Dispose(); } } }
public ActionResult Delete(Dog deleteDog, IFormCollection collection) { try { _dogRepo.Delete(deleteDog); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { _logger.LogError("Error on Delete: " + ex.Message); return(View()); } }
public IActionResult Delete(Dog dogToDelete, IFormCollection collection) { try { // TODO: Add delete logic here if (ModelState.IsValid) { _dogRepo.Delete(dogToDelete); return(RedirectToAction(nameof(Index))); } return(View(dogToDelete)); } catch { return(View(dogToDelete)); } }
public IActionResult Delete(int id, Dog dogToDelete) { try { if (ModelState.IsValid) { _dogRepo.Delete(dogToDelete); return(RedirectToAction(nameof(Index))); } return(View(dogToDelete)); } catch { return(View(dogToDelete)); } }
public IActionResult Delete(int id) { _repository.Delete(id); return(RedirectToAction("Index")); }
public bool Delete(int id) { return(_dogRepository.Delete(id)); }