public IActionResult Delete(string id)
        {
            var toaster = _toasterService.Get(id);

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

            _toasterService.Remove(toaster.Id);

            return(NoContent());
        }
Esempio n. 2
0
        // Attribute specifying to routing layer that DELETE is intended (http verb)
        // {id:------} is a route template passed to the attribute as a parameter
        public IActionResult Delete(string id)
        // IAction Result is preferable here to ActionResult since the update
        // could result in multiple ActionResult return types. "ActionResult
        // types represent various HTTP status codes".
        {
            var toaster = _toasterService.Get(id);

            // initiates variable equal to get method from toasterService

            if (toaster == null)
            {
                return(NotFound());
                // sends 404 if no toaster found
            }

            _toasterService.Remove(toaster.Id);
            // if toaster is found, calls Remove method from service

            return(NoContent());
            // sends an empty 204 response
        }