Exemple #1
0
        public async Task <ActionResult> CreateComment([FromBody] CompositionCommentsViewModel comment)
        {
            try
            {
                if (comment == null)
                {
                    logger.LogError($"Comment object sent from client is null");
                    return(BadRequest("Comment object is null"));
                }

                await commentsAdapter.AddComent(comment).ConfigureAwait(false);

                logger.LogInformation($"{comment.UserName} commentary is successfully added");
                return(Ok());
            }
            catch (Exception ex)
            {
                logger.LogError($"Something went wrong inside CreateComment action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
        }
 public async Task AddComent(CompositionCommentsViewModel comment)
 {
     await commentsService.CreateAsync(mapper.Map <CompositionComments>(comment)).ConfigureAwait(false);
 }