Пример #1
0
        public bool Insert(DanhGiaSPViewModel dgsp)
        {
            var bl = new BinhLuan();

            bl.NguoiDungID = dgsp.NguoiDungID;
            bl.MaSP        = dgsp.MaSP;
            bl.MaDL        = dgsp.MaDL;
            bl.MaTT        = dgsp.MaTT;
            bl.MaMau       = dgsp.MaMau;
            bl.NoiDung     = dgsp.NoiDung;
            bl.DanhGia     = dgsp.DanhGia;
            bl.ReplyID     = dgsp.ReplyID;
            db.BinhLuans.Add(bl);
            db.SaveChanges();
            return(true);
        }
Пример #2
0
        public ActionResult ChiTietSP(DanhGiaSPViewModel dgsp, string masp, string mamau, string matt, string madl)
        {
            ViewBag.user = Session[CommonConstant.USER_SESSION];
            var nhanVien = new UserDao().getGroupID(ViewBag.user.ID);

            if (ViewBag.user == null)
            {
                return(View("Error_ChuaLogin"));
            }
            else
            {
                var soLanMua     = new BinhLuanDao().SoLanMuaCua1KH(dgsp.NguoiDungID, masp, mamau, matt, madl);
                var soLanDanhGia = new BinhLuanDao().SoLanDanhGia(dgsp.NguoiDungID, masp, mamau, matt, madl);
                if (soLanMua.Count > 0 || nhanVien == "NVBH")
                {
                    if (soLanDanhGia.Count < soLanMua.Count || nhanVien == "NVBH")
                    {
                        var rs   = new BinhLuanDao().Insert(dgsp);
                        var ctsp = new SanPhamDao().ListAll().Where(x => x.DMSPID == dgsp.ID && x.MaSP == masp && x.MaMau == mamau && x.MaTT == matt && x.MaDL == madl).SingleOrDefault();
                        ViewBag.sptuongtu = new SanPhamDao().ListSPLienQuan(dgsp.ID, masp, mamau, matt, madl);
                        ViewBag.chonMau   = new SanPhamDao().ChonMau(dgsp.ID, masp, mamau, matt, madl);
                        ViewBag.BinhLuan  = new BinhLuanDao().ListDanhGiaSP(dgsp.ID, masp, mamau, matt, madl);
                        ViewBag.danhGia   = new BinhLuanDao().DiemDanhGia(masp, mamau, matt, madl);
                        ViewBag.replyCMT  = new BinhLuanDao().ReplyDanhGia(masp, mamau, matt, madl);
                        return(View(ctsp));
                    }
                    else
                    {
                        return(View("Error_DanhGia"));
                    }
                }
                else
                {
                    return(View("Error"));
                }
            }
        }