// cap nhat thong tin san pham public bool CapNhat(SANPHAM pr) { try { var sp = db.SANPHAMs.Find(pr.ID); sp.TenSP = pr.TenSP; sp.Gia = pr.Gia; sp.GiaKhuyenMai = pr.GiaKhuyenMai; sp.NgaySuaDoi = DateTime.Now; sp.MoTaSP = pr.MoTaSP; sp.Code = pr.Code; sp.IDDanhMuc = pr.IDDanhMuc; sp.AnhDaiDien = pr.AnhDaiDien; sp.ChiTietSP = pr.ChiTietSP; sp.BaoHanh = pr.BaoHanh; sp.IDHang = pr.IDHang; sp.MauGiay = pr.MauGiay; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public ActionResult YeuThich(long id) { var taikhoan = GetUser(); if (taikhoan == null) { return(Json(new RatingViewModel() { IsSuccess = false, Message = "Bạn chưa đăng nhập!" }, JsonRequestBehavior.AllowGet)); } else if (db.YeuThiches.FirstOrDefault(t => t.NguoiDungId == taikhoan.ID && t.SanPhamId == id) != null) { var removeItem = db.YeuThiches.FirstOrDefault(t => t.NguoiDungId == taikhoan.ID && t.SanPhamId == id); db.YeuThiches.Remove(removeItem); } else { db.YeuThiches.Add(new Model.EF.YeuThich() { SanPhamId = id, NguoiDungId = taikhoan.ID, NgayThem = DateTime.Now }); } db.SaveChanges(); return(Json(new RatingViewModel() { IsSuccess = true, Message = "/SanPham/ChiTiet/" + id }, JsonRequestBehavior.AllowGet)); }
public long addAccount(TAIKHOAN tk) { db.TAIKHOANs.Add(tk); db.SaveChanges(); return(tk.ID); }
public long ThemLienHe(LIENHE cs) { db.LIENHEs.Add(cs); db.SaveChanges(); return(cs.ID); }
public long Insert(DONHANG xx) { db.DONHANGs.Add(xx); db.SaveChanges(); return(xx.ID); }
public long ThemCo(COGIAY cs) { db.COGIAYs.Add(cs); db.SaveChanges(); return(cs.ID); }
public void ThemDanhMuc(DANHMUCSANPHAM ds) { db.DANHMUCSANPHAMs.Add(ds); db.SaveChanges(); }
public void Add(CHITIETDONHANG od) { db.CHITIETDONHANGs.Add(od); db.SaveChanges(); }
public long AddSlide(SLIDE sl) { db.SLIDEs.Add(sl); db.SaveChanges(); return(sl.ID); }