Пример #1
0
        public bool Remove(int id)
        {
            City removeCity = _cityRepo.Read(id);

            if (removeCity != null)
            {
                return(_cityRepo.Delete(removeCity));
            }
            return(false);
        }
Пример #2
0
        public bool Remove(int id)
        {
            City city = _cityRepo.Read(id);

            if (city == null)
            {
                return(false);
            }
            else
            {
                return(_cityRepo.Delete(city));
            }
        }
Пример #3
0
        public async Task <ActionResult> DeleteCityByID(int id)
        {
            try
            {
                var oldCity = await _cityRepo.GetCityById(id);

                if (oldCity == null)
                {
                    return(NotFound($"Couldn't find any city with id: {id}"));
                }

                _cityRepo.Delete(oldCity);

                if (await _cityRepo.Save())
                {
                    return(NoContent());
                }
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}"));
            }
            return(BadRequest());
        }
Пример #4
0
 public bool Remove(int id)
 {
     return(_cityRepo.Delete(id));
 }
Пример #5
0
 public void DeleteCity(int id)
 {
     cityRepo.Delete(id);
 }
Пример #6
0
 public async Task <bool> DeleteCityAsync(City city)
 {
     _cityRepo.Delete(city);
     return(await SaveChangesAsync());
 }