Ejemplo n.º 1
0
        public IActionResult RemoveComment([FromBody] CommentReq req)
        {
            var res = new SingleRsp();

            res = _svc.RemoveComment(req);
            return(Ok(res));
        }
Ejemplo n.º 2
0
        public SingleRsp RemoveComment(CommentReq req)
        {
            Comment cmt = new Comment();

            cmt.Id             = req.Id;
            cmt.UserId         = req.UserId;
            cmt.UserName       = req.UserName;
            cmt.ProductId      = req.ProductId;
            cmt.CommentContent = req.CommentContent;
            cmt.TimeComment    = req.TimeComment;
            return(_rep.RemoveComment(cmt));
        }
Ejemplo n.º 3
0
        public SingleRsp CreateComment(CommentReq cmt)
        {
            var res    = new SingleRsp();
            var cmtNew = new Comments()
            {
                PostId    = cmt.PostId,
                AccountId = cmt.AccountId,
                Content   = cmt.Content,
                React     = cmt.React,
                Rate      = cmt.Rate
            };

            res = _rep.CreateComment(cmtNew);
            return(res);
        }
Ejemplo n.º 4
0
        public SingleRsp UpdateComment(CommentReq cmt)
        {
            var res       = new SingleRsp();
            var cmtUpdate = new Comments()
            {
                CommentId = cmt.CommentId,
                PostId    = cmt.PostId,
                AccountId = cmt.AccountId,
                Content   = cmt.Content,
                React     = cmt.React,
                Rate      = cmt.Rate
            };

            res = _rep.UpdateComment(cmtUpdate);
            return(res);
        }
Ejemplo n.º 5
0
        public ActionResult CreateComment([FromBody] CommentReq req)
        {
            if (req.Content == null || req.ProductId < 1)
            {
                return(BadRequest());
            }
            else
            {
                try
                {
                    var           identity = HttpContext.User.Identity as ClaimsIdentity;
                    IList <Claim> claims   = identity.Claims.ToList();
                    string        username = claims[0].Value;
                    string        role     = claims[2].Value;

                    Comments comment = new Comments()
                    {
                        Content   = req.Content,
                        ProductId = req.ProductId,
                    };

                    if (role == "2")
                    {
                        comment.ShopId = username;
                    }
                    else if (role == "3")
                    {
                        comment.CustomerId = username;
                    }
                    else
                    {
                        throw new Exception();
                    }

                    this._context.Comments.Add(comment);
                    this._context.SaveChanges();

                    return(Ok());
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex));
                }
            }
        }
        public IActionResult DeleteComment([FromBody] CommentReq req)
        {
            var res = _svc.DeleteComment(req.PostId);

            return(Ok(res));
        }
        public IActionResult UpdateComment([FromBody] CommentReq req)
        {
            var res = _svc.UpdateComment(req);

            return(Ok(res));
        }