コード例 #1
0
        public void MakeComment(CommentInputDTO commentInputDTO)
        {
            var user  = userService.GetUserById(commentInputDTO.UserId);
            var order = userService.OrdersFromUser(user.Id).FirstOrDefault(o => o.Id == commentInputDTO.OrderId);

            var comment = mapper.Map <Comment>(commentInputDTO);

            comment.User  = user;
            comment.Order = order;
            userService.MakeComment(comment);
        }
コード例 #2
0
        public void CreateComment(int orderId, [FromBody] CommentInputFromBodyDTO commentInputDTO)
        {
            var comment = new CommentInputDTO()
            {
                OrderId = orderId,
                Message = commentInputDTO.Message,
                UserId  = commentInputDTO.UserId
            };

            userAppService.MakeComment(comment);
        }
コード例 #3
0
        public ActionResult <CommentOutputDTO> WriteComment(CommentInputDTO comment)
        {
            DateTime d  = DateTime.Now;
            var      IP = Request.HttpContext.Connection.RemoteIpAddress;
            Comment  c  = new Comment {
                Time = d, CommentText = comment.Comment, Name = comment.Name, IPAddr = IP.ToString()
            };
            Comment          newComment = _repository.WriteComment(c);
            CommentOutputDTO co         = new CommentOutputDTO {
                CommentText = newComment.CommentText, Name = newComment.Name
            };

            return(CreatedAtAction(nameof(GetComments), co));
        }