public async Task <IActionResult> AddProductComponent([FromBody] AddProductCommentDTO comment) { if (!User.Identity.IsAuthenticated) { return(JsonResponseStatus.Error(new { message = "لطفا ابتدا وارد سایت شوید" })); } if (!await productService.IsExistsProductById(comment.ProductId)) { return(JsonResponseStatus.NotFound()); } var userId = User.GetUserId(); var res = await productService.AddProductComment(comment, userId); return(JsonResponseStatus.Success(res)); }
public async Task <ProductCommetDTO> AddProductComment(AddProductCommentDTO comment, long userId) { var commentData = new ProductComment { ProductId = comment.ProductId, Text = comment.Text, UserId = userId }; await _productCommentRepository.AddEntity(commentData); await _productCommentRepository.SaveChanges(); return(new ProductCommetDTO { Id = commentData.Id, CreateDate = commentData.CreateDate.ToShamsi(), Text = commentData.Text, UserId = userId, UserFullName = "" }); }