コード例 #1
0
 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();
         }
     }
 }
コード例 #2
0
        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());
            }
        }
コード例 #3
0
 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));
     }
 }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
 public IActionResult Delete(int id)
 {
     _repository.Delete(id);
     return(RedirectToAction("Index"));
 }
コード例 #6
0
 public bool Delete(int id)
 {
     return(_dogRepository.Delete(id));
 }