public string Delete(Place entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException();
            }

            if (entity.PlaceId == null)
            {
                throw new Exception("PlaceId cannot be null!");
            }

            var place = SelectById(entity.PlaceId);

            if (place == null)
            {
                throw new Exception("Place doesn't exist!");
            }
            try
            {
                var message = repository.Delete(place);
                return(message);
            }
            catch (Exception)
            {
                throw new Exception("Error deleatin place!");
            }
        }
Пример #2
0
 public void DeletePlace()
 {
     if (SelectedPlace != null)
     {
         placesCollection.Remove(SelectedPlace);
         placeRepository.Delete(SelectedPlace.Place);
         SelectedPlace = null;
     }
 }
Пример #3
0
        public void Delete(Guid id)
        {
            var place = GetById(id);

            if (place == null)
            {
                throw new Exception("Local não encontrado");
            }

            _placeRepository.Delete(id);

            _placeRepository.UnitOfWork.Commit();
        }
Пример #4
0
        public async Task <ActionResult <Place> > Delete(
            [FromBody] Place place
            )
        {
            try
            {
                if (!User.IsAdmin(userRepository))
                {
                    throw new Exception(localizer[Controllers_PlaceController.Only_admin_is_allowed_to_manage_testing_places].Value);
                }

                if (place is null)
                {
                    throw new ArgumentNullException(nameof(place));
                }

                if (string.IsNullOrEmpty(place.Id) || await placeRepository.GetPlace(place.Id) == null)
                {
                    // new place
                    throw new Exception(localizer[Controllers_PlaceController.Place_not_found].Value);
                }
                else
                {
                    // update existing

                    await placeRepository.Delete(place);

                    logger.LogInformation($"Place {place.Name} has been deleted");
                }

                return(Ok(place));
            }
            catch (ArgumentException exc)
            {
                logger.LogError(exc.Message);
                return(BadRequest(new ProblemDetails()
                {
                    Detail = exc.Message
                }));
            }
            catch (Exception exc)
            {
                logger.LogError(exc, exc.Message);
                return(BadRequest(new ProblemDetails()
                {
                    Detail = exc.Message
                }));
            }
        }
Пример #5
0
        public IActionResult DeletePlace(int id, Place place)
        {
            var entity = _placeRepository.Get(place);

            if (entity != null)
            {
                _placeRepository.Delete(entity);
                return(RedirectToAction("List"));
            }
            else
            {
                ModelState.AddModelError("PlaceNotExist", "This Place Not Found!");
                return(View(place));
            }
        }
Пример #6
0
 public void DeletePlace(int id)
 {
     placeRepository.Delete(id);
 }
Пример #7
0
 public bool Execute()
 {
     return(placeRepository.Delete(Id));
 }
Пример #8
0
 public void Delete(Place dPlaces)
 {
     _placeRepository.Delete(dPlaces);
 }