public IActionResult DeleteDogs(int dogID) { Dog deleteDog = _dogRepository.DeleteDog(dogID); if (deleteDog != null) { TempData["message"] = $"Delete {deleteDog.Name}."; } return(RedirectToAction("DogsList")); }
public ActionResult Delete(int id, Dog dog) { try { _dogRepo.DeleteDog(id); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, Dog dog) { try { _dogRepo.DeleteDog(id); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { return(View(dog)); } }
public ActionResult Delete(int id, Dog dog) { try { dog.OwnerId = GetCurrentUserId(); _dogRepo.DeleteDog(id); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { return(View(dog)); } }
public ActionResult Delete(Dog dog) { try { int ownerId = GetCurrentUserId(); _dogRepository.DeleteDog(dog.Id, ownerId); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Delete(int id, Dog dog) { if (dog.OwnerId != GetCurrentUserId()) { return(NotFound()); } try { _dogRepo.DeleteDog(id); return(RedirectToAction("Index")); } catch (Exception ex) { return(View(dog)); } }
public ActionResult Delete(int id, Dog dog) { try { // update the dogs OwnerId to the current user's Id dog.OwnerId = GetCurrentUserId(); _dogRepo.DeleteDog(id); return(RedirectToAction("Index")); } catch (Exception) { return(View(dog)); } }
public ActionResult Delete(int id, Dog dog) { if (dog.OwnerId != GetCurrentUserId()) { return(RedirectToAction(nameof(NotFound))); } try { // TODO: Add delete logic here _dogRepo.DeleteDog(id); return(RedirectToAction(nameof(Index))); } catch { return(View(dog)); } }
public IActionResult DeleteDogForOwner(int ownerId, int dogId) { if (!_ownerRepository.OwnerExists(ownerId)) { return(NotFound()); } var dogFromRepo = _dogRepository.GetDogByOwner(ownerId, dogId); if (dogFromRepo == null) { return(NotFound()); } _dogRepository.DeleteDog(dogFromRepo); return(NoContent()); }
public ActionResult DeleteDogForClient(int clientId, int dogId) { if (!_clientRepository.ClientExists(clientId)) { return(NotFound()); } var dogForClientFromRepo = _dogRepository.GetDog(dogId, clientId); if (dogForClientFromRepo == null) { return(NotFound()); } _dogRepository.DeleteDog(dogForClientFromRepo); _dogRepository.Save(); return(NoContent()); }
public ActionResult Delete(int id, Dog dog) { int currentUserId = GetCurrentUserId(); if (dog.OwnerId == currentUserId) { try { _dogRepo.DeleteDog(id); return(RedirectToAction(nameof(Index))); } catch { return(View(dog)); } } return(NotFound()); }
public void Index_DeleteDog() { //Arrange IDogRepository sut = GetInMemoryDogRepository(); Dog dog = new Dog() { Id = 3, DogName = "Jo", Breed = "Terrier x", DOB = DateTime.Parse("2012-07-26"), Image = "jo.jpg", ApplicationUserId = "d4eb7d23-d641-4c2d-8cd3-a036e08a3c65" }; //Act Dog savedDog = sut.CreateDog(dog); Dog savedDog1 = sut.DeleteDog(dog); //Assert Assert.Empty(sut.Dogs); }
public ActionResult Delete(int id, Dog dog) { int ownerId = GetCurrentUserId(); Dog deleteDog = _dogRepo.GetDogById(id); try { if (deleteDog.OwnerId != ownerId) { return(NotFound()); } else { _dogRepo.DeleteDog(id); return(RedirectToAction("Index")); } } catch (Exception ex) { return(View(dog)); } }
public IActionResult Delete(Dog dog) { repository.DeleteDog(dog.Id); return(RedirectToAction("Index")); }