Beispiel #1
0
        public async Task <IActionResult> AddComment(Guid adId, [FromBody] AdCommentRequest adCommentRequest)
        {
            try
            {
                var newComment = await adManager.AddComment(adId, GetCurrentUserId(), adCommentRequest);

                return(Ok(mapper.Map <CommentView>(newComment)));
            }
            catch (InvalidOperationException ioe)
            {
                logger.LogDebug(ioe.Message + "\n" + ioe.StackTrace);
                return(NotFound("Can't find ad or user"));
            }
            catch (ArgumentNullException ane)
            {
                logger.LogDebug(ane.Message + "\n" + ane.StackTrace);
                return(NotFound("Can't find ad ot user"));
            }
            catch (Exception ex)
            {
                logger.LogDebug(ex.Message + "\n" + ex.StackTrace);
                return(StatusCode(500));
            }
        }