コード例 #1
0
        public void DeleteRestaurantById(int id)
        {
            var orig = _repo.GetRestaurantById(id);

            _repo.Delete(orig);
            _repo.SaveChanges();
        }
コード例 #2
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            try
            {
                Restaurant restaurant = (Restaurant)bindingSourceRestaurant.Current;
                if (restaurant == null)
                {
                    return;
                }

                DialogResult result = MessageBox.Show(
                    InfoMessages.DeleteConfirmation,
                    GlobalConstants.DeleteConfirmationCaption,
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    repository.Delete(restaurant);
                    RefreshControls();
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(string.Format(ErrorMessages.ErrorMessageTemplate, RestaurantDisplay), ex);
            }
        }
コード例 #3
0
        public ActionResult Delete(RestaurantsDeleteViewModel model)
        {
            RestaurantRepository repository = new RestaurantRepository();

            repository.Delete(model.ID);

            return(RedirectToAction("Index"));
        }
        public void Delete_GivenRestaurant_RemovesRestaurant()
        {
            var restaurant = new Restaurant
            {
                RestaurantId       = Guid.NewGuid(),
                RestaurantPublicId = Guid.NewGuid()
            };

            _textContext.Restaurants.Add(restaurant);
            _textContext.SaveChanges();

            _restaurantRepository.Delete(restaurant);

            Assert.IsFalse(_restaurantRepository.Get().Contains(restaurant));
        }
コード例 #5
0
 public async Task <IHttpActionResult> Delete(string id)
 {
     if (id == null)
     {
         return(BadRequest("Id can not be null"));
     }
     try
     {
         var deleteRestaurant = _repository.Delete(id);
         return(Json(deleteRestaurant));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         Restaurant r = restaurantRepository.GetByID(id);
         if (r == null)
         {
             throw new ArgumentNullException("id");
         }
         restaurantRepository.Delete(r);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         log.Error($"[Restaurants Controller] [Delete] Exception thrown: {e.Message}");
         return(RedirectToAction("Index"));
     }
 }
コード例 #7
0
 public void DeleteRestaurant(int id)
 {
     restrepo.Delete(id);
 }
コード例 #8
0
 public bool Delete(Restaurant restodelete)
 {
     return(restRepo.Delete(restodelete));
 }
コード例 #9
0
 public ActionResult Delete(int id)
 {
     restaurantRepository.Delete(id);
     return(RedirectToAction("TempDataResult"));
 }
コード例 #10
0
 public bool Delete(int id)
 {
     return(restaurantRepo.Delete(id));
 }
コード例 #11
0
 public ActionResult DeleteConfirmed(int id)
 {
     rr.Delete(id);
     logger.Trace("Restuarant Deleted");
     return(RedirectToAction("Index"));
 }
コード例 #12
0
 public bool DeleteRestaurant(string id)
 {
     return(restaurants.Delete(id));
 }
コード例 #13
0
 public ActionResult Delete(int id)
 {
     RestaurantRepository.Delete(id);
     TempData["Message"] = "Deleted Succesfully";
     return(RedirectToAction("Index"));
 }