Beispiel #1
0
        public HttpResponseMessage Delete(string id)
        {
            var traveler = travelers.FindBy(t => t.TravelerUserIdentity == id).FirstOrDefault();

            // returning 404 if the entity doesn't exist
            if (traveler == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            travelers.Delete(traveler);
            travelers.Save();
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        public async Task <IActionResult> Delete(int commentId)
        {
            try
            {
                var oldComment = await _eventRepository.GetComment(commentId);

                if (oldComment == null)
                {
                    return(NotFound($"Could not find Comment with id {commentId}"));
                }

                _eventRepository.Delete(oldComment);
                if (await _eventRepository.Save())
                {
                    return(NoContent());
                }
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure"));
            }

            return(BadRequest());
        }