Exemple #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Boat boat = GetAllBoats().Find(b => b.Id == id);

            using (var context = new BoatContext())
            {
                var service = new BoatService(context);
                service.Remove(boat);
            }
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public IActionResult Delete(string id)
        {
            try
            {
                var boat = _boatService.Get(id);

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

                _boatService.Remove(boat.Id);

                return(NoContent());
            }
            catch (Exception e)
            {
                string message    = e.Message;
                string stackTrace = e.StackTrace;

                return(StatusCode(Microsoft.AspNetCore.Http.StatusCodes.Status500InternalServerError));
            }
        }