public IActionResult DeleteConfirmed(int id)
        {
            var bike = _bikeRepository.GetBikeById(id);

            _bikeRepository.DeleteBike(bike);
            _db.Likes.RemoveRange(bike.Likes);
            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 2
0
        public async Task <ActionResult> Delete(int id)
        {
            TempData["message"] = string.Empty;
            bool succeeded = await repository.DeleteBike(id);

            TempData["message"] = $"Bike not deleted";
            if (succeeded)
            {
                TempData["message"] = $"Bike deleted";
            }
            //returning to view
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        public ActionResult RemoveBike(int id)
        {
            var bike = _bikeRepo.GetBikeById(id);

            if (bike is null)
            {
                return(NotFound());
            }

            _bikeRepo.DeleteBike(bike);
            _bikeRepo.SaveChanges();

            return(NoContent());
        }
Esempio n. 4
0
        public ActionResult <Bike> DeleteBike(Guid id)
        {
            var bike = _repository.GetBikeById(id);

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

            _repository.DeleteBike(id);
            _repository.Save();

            return(bike);
        }
        public async Task <IActionResult> DeleteConfirmed(Guid?BikeId)
        {
            if (ModelState.IsValid)
            {
                var response = await _bikeRepo.DeleteBike(BikeId);

                if (response)
                {
                    return(RedirectToAction("Index"));
                }
            }

            return(NoContent());
        }
Esempio n. 6
0
        public async Task <IActionResult> DeleteBike(int?bikeId)
        {
            int result = 0;

            if (bikeId == null)
            {
                return(BadRequest());
            }
            try
            {
                result = await _BikeRepository.DeleteBike(bikeId);

                if (result == 0)
                {
                    return(NotFound());
                }
                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }