public JsonResult themDanhGia(string a, string b) { string trave = ""; if (save.taikhoan == null || save.taikhoan == "") { trave = "Bạn Cần đăng Nhập"; } else { try { danhgia dg = new danhgia(); dg.noidung = a; dg.idSP = idcuasanpham; dg.sosao = Convert.ToInt32(b.Trim()); dg.daxoa = false; dg.solike = 0; dg.taikhoan = save.taikhoan; db.danhgias.Add(dg); db.SaveChanges(); trave = "1"; } catch (Exception) { trave = "Có Lỗi Rồi "; } } return(Json(trave)); }
public ActionResult DeleteConfirmed(int id) { danhgia danhgia = db.danhgia.Find(id); db.danhgia.Remove(danhgia); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "madanhgia,masanpham,makhachhang,noidung")] danhgia danhgia) { if (ModelState.IsValid) { db.Entry(danhgia).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(danhgia)); }
public ActionResult Create([Bind(Include = "madanhgia,masanpham,makhachhang,noidung")] danhgia danhgia) { if (ModelState.IsValid) { db.danhgia.Add(danhgia); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(danhgia)); }
// GET: Areas/Danhgia/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } danhgia danhgia = db.danhgia.Find(id); if (danhgia == null) { return(HttpNotFound()); } return(View(danhgia)); }
public void addReviewDAO(string iduser, string idproduct, string title, int eval, string content) { DBModel dBModel = new DBModel(); danhgia neweval = new danhgia(); neweval.ID_SANPHAM = idproduct; neweval.ID_USER = iduser; neweval.TEN_USER = new UserDAO().getUserById(iduser).HO_TEN; neweval.NOIDUNG = content; neweval.SAO = eval.ToString(); neweval.TIEUDE = title; dBModel.danhgias.Add(neweval); dBModel.SaveChanges(); }
public ActionResult danhgiasanpham(int?id) { khachhang k = (khachhang)Session["nguoidung"]; danhgia i = new danhgia(); i.makhachhang = k.makhachhang; i.masanpham = id; i.noidung = Request.Form["noidung"]; db.danhgia.Add(i); db.SaveChanges(); return(RedirectToAction("Details/" + id)); }
public ActionResult NguoiMua(int?idnd, int chon, String noidung, int idndg, int idsp) { using (var daugia = new daugiaEntities()) { danhgia dg = new danhgia(); dg.id_nguoidung = idnd; dg.noidung = noidung; dg.id_nguoidanhgia = idndg; dg.mat = chon; dg.ngaytao = DateTime.Now; daugia.danhgias.Add(dg); var sp = daugia.sanphams.Where(s => s.id == idsp).FirstOrDefault(); sp.nguoimuadanhgia_ = 1; daugia.SaveChanges(); var ndd = daugia.nguoidungs.Where(nd => nd.id == idnd).FirstOrDefault(); var dgnd = daugia.danhgias.Where(dgn => dgn.id_nguoidung == idnd).ToList(); int tot = 0; int xau = 0; foreach (var d in dgnd) { if (d.mat == 1) { tot++; } else if (d.mat == 1) { xau++; } } double t = (tot / (tot - xau != 0 ? tot - xau : 1)) * 100; ndd.diem = t; daugia.SaveChanges(); int n = Login.nguoidung().id; var list = daugia.sanphams.Where(s => s.id_nguoidunghientai == n && s.tinhtrang == 2 && s.nguoimuadanhgia_ == 0).ToList(); return(View(list)); } }