public IActionResult DeleteElement(int elementId) { try { var deleteElement = _context.Items.Find(elementId); if (deleteElement == null) { throw new Exception("You try to delete not existing element."); } _context.Remove(deleteElement); return(Ok()); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }