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); }
public void CreateComment(int orderId, [FromBody] CommentInputFromBodyDTO commentInputDTO) { var comment = new CommentInputDTO() { OrderId = orderId, Message = commentInputDTO.Message, UserId = commentInputDTO.UserId }; userAppService.MakeComment(comment); }
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)); }