Exemplo n.º 1
0
        public bool InsertRating(DanhGia model)
        {
            try
            {
                db.DanhGias.Add(model);
                db.SaveChanges();
                UpdateRatingProduct(model.MaSP);
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
Exemplo n.º 2
0
        public bool UpdateRating(DanhGia model)
        {
            DanhGia dg = db.DanhGias.Find(model.MaSP, model.NguoiDung);
            if (dg == null)
            {
                return InsertRating(model);
            }
            try
            {
                dg.Diem = model.Diem;
                db.Entry(dg).State = EntityState.Modified;
                db.SaveChanges();
                UpdateRatingProduct(model.MaSP);
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }