コード例 #1
0
 public void Update(SoSanhGia ss)
 {
     SoSanhGia ssg = db.SoSanhGias.Where(x => x.MaSP == ss.MaSP && x.MaWebsite == ss.MaWebsite).FirstOrDefault();
     if (ssg != null)
     {
         ssg.Gia = ss.Gia;
         db.Entry(ssg).State = System.Data.EntityState.Modified;
         db.SaveChanges();
     }
     else
     {
         Insert(ss);
     }
 }
コード例 #2
0
        public void Update()
        {
            int offset = 0;
            int count = 10;
            List<SanPham> listProduct = pdata.GetProducts(offset, count);
            List<Website> listWebsite = wdata.GetListWebsite();
            while (listProduct.Count > 0)
            {
                foreach (SanPham sp in listProduct)
                {
                    foreach (Website web in listWebsite)
                    {
                        SoSanhGia ss = new SoSanhGia();
                        ss.MaSP = sp.MaSP;
                        ss.MaWebsite = web.MaSo;
                        ss.Gia = GetPrice(web, sp.TenSP.Trim());
                        prdata.Update(ss);
                    }
                }

                offset += count;
                listProduct = pdata.GetProducts(offset, count);
            }
        }
コード例 #3
0
 public void Insert(SoSanhGia ss)
 {
     db.SoSanhGias.Add(ss);
     db.SaveChanges();
 }