コード例 #1
0
        public IActionResult DeleteReacion([FromHeader(Name = "CommunicationKey")] string key, [FromQuery] Guid reactionID)
        {
            var reaction = reactionRepository.GetReactionByID(reactionID);

            if (reaction == null)
            {
                return(NotFound());
            }
            try
            {
                reactionRepository.DeleteReaction(reactionID);
                reactionRepository.SaveChanges();
                logger.Log(LogLevel.Information, contextAccessor.HttpContext.TraceIdentifier, "", String.Format("Successfully deleted reaction with ID {0} from database", reactionID), null);

                return(NoContent());
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Error, contextAccessor.HttpContext.TraceIdentifier, "", String.Format("Error while deleting reaction with ID {0}, message: {1}", reaction.ReactionID, ex.Message), null);
                return(StatusCode(StatusCodes.Status500InternalServerError, "Delete error"));
            }
        }