Exemplo n.º 1
0
 public IActionResult Delete(Animals model)
 {
     if (ModelState.Count > 0)
     {
         var dogToDelete = dogRepository.GetDogs().Find(x => x.Id == model.Id);
         dogRepository.DeleteDog(dogToDelete);
     }
     return(View(model));
 }
Exemplo n.º 2
0
        public Dog DeleteDog(int DogId)
        {
            string dogJson = GetDogById(DogId);
            Dog    dog     = JsonConvert.DeserializeObject <Dog>(dogJson);

            _dogRepository.DeleteDog(DogId);

            return(dog);
        }
Exemplo n.º 3
0
 public ActionResult Delete(int id, Dog dog)
 {
     try
     {
         _dogRepo.DeleteDog(id);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View(dog));
     }
 }
Exemplo n.º 4
0
        public ActionResult Delete(int id, Dog dog)
        {
            int OwnerId = GetCurrentUserId();

            dog.OwnerId = OwnerId;
            if (dog.OwnerId == OwnerId)
            {
                _dogRepo.DeleteDog(id);
                return(RedirectToAction(nameof(Index)));
            }

            return(View(dog));
        }
Exemplo n.º 5
0
        public ActionResult Delete(int id, Dog dog)
        {
            try
            {
                _dogRepo.DeleteDog(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                // If something goes wrong, just keep the user on the same page so they can try again
                return(View(dog));
            }
        }
Exemplo n.º 6
0
 public ActionResult Delete(int id, Dog dog)
 {
     if (dog.OwnerId == GetCurrentUserId())
     {
         try
         {
             _dogRepo.DeleteDog(dog.Id);
             return(RedirectToAction("Index"));
         }
         catch
         {
             return(View(dog));
         }
     }
     else
     {
         return(NotFound());
     }
 }
Exemplo n.º 7
0
        public ActionResult Delete(int id, Dog dog)
        {
            dog = _dogRepo.GetDogById(id);

            try
            {
                if (dog.OwnerId == GetCurrentUserId())
                {
                    _dogRepo.DeleteDog(id);

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception ex)
            {
                return(View(dog));
            }
        }