Exemplo n.º 1
0
        public void ChatbotRep(BinhLuan bl)
        {
            SanPhamModel spmd = new SanPhamModel();
            var          sp   = spmd.FindById(bl.MaSP);

            String content = GetAnswer(sp.TenSP + " : " + bl.NoiDung);

            BinhLuan rep = new BinhLuan();

            rep.Parent   = bl.MaBL;
            rep.NoiDung  = content;
            rep.NgayDang = DateTime.Now;
            rep.MaKH     = "912a7a6d-b24d-40e7-bfed-726fb822b99d";
            rep.MaSP     = bl.MaSP;
            rep.HoTen    = "ADMIN";
            rep.Email    = "*****@*****.**";



            //
            CommentModel cm = new CommentModel();

            cm.AddComment(rep);
            cm.UpdateComment(rep);
        }
        internal void UpdateComment(BinhLuan Comment)
        {
            var cmpar = db.BinhLuans.Find(Comment.Parent);

            cmpar.DaTraLoi        = "R";
            db.Entry(cmpar).State = EntityState.Modified;
            db.SaveChanges();
            var cm = db.BinhLuans.Find(Comment.MaBL);

            cm.DaTraLoi        = "N";
            db.Entry(cm).State = EntityState.Modified;
            db.SaveChanges();
        }
 public void AddComment(BinhLuan bl)
 {
     db.BinhLuans.Add(bl);
     db.SaveChanges();
 }