Пример #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));
 }
Пример #2
0
        public Dog DeleteDog(int DogId)
        {
            string dogJson = GetDogById(DogId);
            Dog    dog     = JsonConvert.DeserializeObject <Dog>(dogJson);

            _dogRepository.DeleteDog(DogId);

            return(dog);
        }
Пример #3
0
 public ActionResult Delete(int id, Dog dog)
 {
     try
     {
         _dogRepo.DeleteDog(id);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View(dog));
     }
 }
Пример #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));
        }
Пример #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));
            }
        }
Пример #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());
     }
 }
Пример #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));
            }
        }