コード例 #1
0
 public ActionResult DeleteApartment(int AptID = 0)
 {
     if (AptID == 0)
     {
         return(RedirectToAction("Error", "Home"));
     }
     if (!_aptRepo.DeleteApartment(AptID))
     {
         return(RedirectToAction("Error", "Home"));
     }
     return(RedirectToAction("Index"));
 }
コード例 #2
0
        public ActionResult DeleteApartment(int id)
        {
            var modelFromRepo = _repo.GetApartmentByID(id);

            if (modelFromRepo == null)
            {
                return(NotFound());
            }

            _repo.DeleteApartment(modelFromRepo);
            _repo.SaveChanges();
            return(NoContent());
        }