Exemplo n.º 1
0
        // GET: BinhLuan
        public ActionResult NhapBinhLuan(BINHLUAN bl)
        {
            NGUOIDUNG nd = (NGUOIDUNG)Session["NguoiDung"];

            bl.NGAYDANG    = DateTime.Now;
            bl.MANGUOIDUNG = nd.MANGUOIDUNG;
            db.BINHLUANs.Add(bl);
            db.SaveChanges();
            return(Redirect("/TrangChu/Index"));
        }
Exemplo n.º 2
0
        public static bool ThemLoiBinh(BINHLUAN blThem)
        {
            BINHLUAN             bl = new BINHLUAN();
            QLNhaHangDataContext db = new QLNhaHangDataContext();

            db.DeferredLoadingEnabled = false;
            blThem.MaBinhLuan         = default(int);
            db.BINHLUANs.InsertOnSubmit(blThem);
            db.SubmitChanges();
            return(true);
        }
Exemplo n.º 3
0
        public ActionResult traodoi(FormCollection frmbl, BINHLUAN bl)
        {
            bl.TenKH   = frmbl["tenkh"];
            bl.TG      = DateTime.Now;
            bl.NoiDung = frmbl["binhluan"];

            db.BINHLUANs.Add(bl);
            db.SaveChanges();

            return(RedirectToAction("traodoi", "diendan"));
        }
Exemplo n.º 4
0
        public async Task <IHttpActionResult> GetBINHLUAN(int id)
        {
            BINHLUAN bINHLUAN = await db.BINHLUAN.FindAsync(id);

            if (bINHLUAN == null)
            {
                return(NotFound());
            }

            return(Ok(bINHLUAN));
        }
Exemplo n.º 5
0
            public int Delete(BINHLUAN model)
            {
                BINHLUAN dbEntry = context.BINHLUANs.Find(model.ID_BL);

                if (dbEntry == null)
                {
                    return(0);
                }
                context.BINHLUANs.Remove(dbEntry);
                context.SaveChanges();
                return(1);
            }
Exemplo n.º 6
0
        public async Task <IHttpActionResult> PostBINHLUAN(BINHLUAN bINHLUAN)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.BINHLUAN.Add(bINHLUAN);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = bINHLUAN.ID }, bINHLUAN));
        }
Exemplo n.º 7
0
            public int Insert(BINHLUAN model)
            {
                BINHLUAN dbEntry = context.BINHLUANs.Find(model.ID_BL);

                if (dbEntry != null)
                {
                    return(0);
                }
                context.BINHLUANs.Add(model);
                context.SaveChanges();
                return(1);
            }
 public ActionResult Sua(BINHLUAN bl)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         BINHLUAN binhluan = db.BINHLUANs.SingleOrDefault(n => n.IdBL == bl.IdBL);
         if (binhluan != null)
         {
             binhluan.TrangThai = bl.TrangThai;
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
 //POST: Admin/BinhLuan/Xoa
 public ActionResult Xoa(int id)
 {
     using (Web_KTCKEntities db = new Web_KTCKEntities())
     {
         BINHLUAN bl = db.BINHLUANs.SingleOrDefault(n => n.IdBL == id);
         if (bl != null)
         {
             db.BINHLUANs.Remove(bl);
             db.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
 }
Exemplo n.º 10
0
        public async Task <IHttpActionResult> DeleteBINHLUAN(int id)
        {
            BINHLUAN bINHLUAN = await db.BINHLUAN.FindAsync(id);

            if (bINHLUAN == null)
            {
                return(NotFound());
            }

            db.BINHLUAN.Remove(bINHLUAN);
            await db.SaveChangesAsync();

            return(Ok(bINHLUAN));
        }
Exemplo n.º 11
0
 public ActionResult AddComment([Bind(Include = "MABL,MAMH,NOIDUNG,NGAYGUI,TENKH")] BINHLUAN bl)
 {
     if (ModelState.IsValid)
     {
         bl.MABL    = NewCommentId();
         bl.NGAYGUI = DateTime.Now;
         db.BINHLUANs.Add(bl);
         db.SaveChanges();
     }
     ViewBag.List = db.MATHANGs.Find(bl.MAMH).BINHLUANs.OrderByDescending(m => m.NGAYGUI)
                    .ToPagedList(1, 15);
     ViewBag.MH = db.MATHANGs.Find(bl.MAMH);
     return(View(bl));
 }
Exemplo n.º 12
0
        public ActionResult AddComment(string id, int?page)
        {
            BINHLUAN bl = new BINHLUAN();

            bl.MAMH = id;
            var mm = db.MATHANGs.Find(id);

            bl.MATHANG = mm;
            int pageNumber = (page ?? 1);

            ViewBag.List = db.MATHANGs.Find(id).BINHLUANs.OrderByDescending(m => m.NGAYGUI)
                           .ToPagedList(pageNumber, 15);
            ViewBag.MH = db.MATHANGs.Find(bl.MAMH);
            return(View(bl));
        }
Exemplo n.º 13
0
            public int Update(BINHLUAN model)
            {
                BINHLUAN dbEntry = context.BINHLUANs.Find(model.ID_BL);

                if (dbEntry == null)
                {
                    return(0);
                }
                //dbEntry.ID_BL = model.ID_BL;
                dbEntry.ID_SP        = model.ID_SP;
                dbEntry.ID_TK        = model.ID_TK;
                dbEntry.ngaybinhluan = model.ngaybinhluan;
                dbEntry.noidung      = model.noidung;
                context.SaveChanges();
                return(1);
            }
Exemplo n.º 14
0
 public ActionResult ThemBinhLuan(BINHLUAN bl)
 {
     try
     {
         bl.NgayBinhLuan = DateTime.Parse(DateTime.Now.ToString());
         bl.TrangThai    = "Hiển thị";
         bl.NoiDung      = bl.NoiDung;
         bl.UrlBaiViet   = bl.UrlBaiViet;
         db.BINHLUANs.Add(bl);
         db.SaveChanges();
         return(Redirect(Request.UrlReferrer.ToString()));
     }
     catch
     {
         return(RedirectToAction("Index"));
     }
 }
Exemplo n.º 15
0
        public ActionResult AddBL(string MASP, string COMMENT)
        {
            if (Session["UserName"] != null)

            {
                string      email = Convert.ToString(Session["UserName"]);
                var         ngay  = DateTime.Now.Date;
                BINHLUANDao dao   = new BINHLUANDao();
                BINHLUAN    bl    = new BINHLUAN();
                bl.MASP    = MASP;
                bl.NGAYCM  = ngay;
                bl.EMAIL   = email;
                bl.COMMENT = COMMENT;
                if (ModelState.IsValid)
                {
                    dao.AddBL(bl);
                }
            }
            return(Redirect("detailSP?MASP=" + MASP + ""));
        }
Exemplo n.º 16
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Request.Form["star2"] == null)
     {
         Literal2.Visible = true;
     }
     else
     {
         BINHLUAN bl = new BINHLUAN();
         bl.NguoiBinhLuan = textten.Text;
         bl.DanhGia       = int.Parse(Request.Form["star2"]);
         bl.NoiDung       = textnoidung.Text;
         bl.DaXoa         = false;
         bl.MaMonAn       = req;
         bl.ThoiGian      = DateTime.Now;
         BinhLuanDAO.ThemLoiBinh(bl);
         isClick = false;
         Response.Redirect("~/ChiTietMonAn.aspx");
     }
 }
Exemplo n.º 17
0
        public async Task <IHttpActionResult> PutBINHLUAN(BINHLUAN bINHLUAN)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            db.Entry(bINHLUAN).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 18
0
 public ActionResult Comment(FormCollection fr, int id)
 {
     try
     {
         BINHLUAN model = new BINHLUAN();
         model.ID_SP   = id;
         model.noidung = fr["textbinhluan"];
         //model.ID_TK = SessionPersister.UserName.ID_TK;
         model.ngaybinhluan = DateTime.Now;
         // TODO: Add insert logic here
         var result = new BINHLUANFunction.BinhLuanFunction().Insert(model);
         if (result == 0)
         {
             return(View());
         }
         return(RedirectToAction("Details", new RouteValueDictionary(new { Controller = "SANPHAM", Action = "Details", id = id })));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Details", new RouteValueDictionary(new { Controller = "SANPHAM", Action = "Details", id = id })));
     }
 }
Exemplo n.º 19
0
            public BINHLUAN FindEntity(int ID_BL)
            {
                BINHLUAN dbEntry = context.BINHLUANs.Find(ID_BL);

                return(dbEntry);
            }
Exemplo n.º 20
0
 public void AddBL(BINHLUAN bl)
 {
     db.BINHLUANs.Add(bl);
     db.SaveChanges();
 }