public IHttpActionResult PutNhanVien(int id, NhanVien nhanVien)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != nhanVien.MaNhanVien)
            {
                return(BadRequest());
            }

            db.Entry(nhanVien).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NhanVienExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
 public bool CapNhapSanPham(SanPham_OBJ obj)
 {
     try
     {
         Base.SanPham sanPham = MapperBase(obj);
         db.Entry(sanPham).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public bool CapNhap(ThongSoKyThuat_OBJ obj)
 {
     try
     {
         MayTinhDbContext    db   = new MayTinhDbContext();
         Base.ThongSoKyThuat item = MapperBase(obj);
         db.Entry(item).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }