コード例 #1
0
        public async Task SaveComment(CommentDto comment)
        {
            if (!comment.ProductId.HasValue)
            {
                throw new ArgumentNullException(nameof(comment.ProductId), "SaveComment service exeption");
            }
            if (string.IsNullOrWhiteSpace(comment.PosterName))
            {
                throw new ArgumentNullException(nameof(comment.PosterName), "SaveComment service exeption");
            }
            if (string.IsNullOrWhiteSpace(comment.Description))
            {
                throw new ArgumentNullException(nameof(comment.Description), "SaveComment service exeption");
            }

            try
            {
                await _repository.SaveComment(comment).ConfigureAwait(false);
            }
            catch (Exception ex) {
                Msmq.Save(MsmqConst.NotSavedComments, comment);
                throw new Exception(ex.Message, ex);
            }
        }