public int Edit(Noiphathanh nph) { Noiphathanh nphs = tb.Noiphathanh.Find(nph.Idph); nphs.Tenph = nph.Tenph; try { tb.Entry(nphs).State = EntityState.Modified; tb.SaveChanges(); return(1); } catch { throw; } }
public int Create([FromBody] Noiphathanh nph) { nph.Idph = Auto_id(); tb.Noiphathanh.Add(nph); try { if (ModelState.IsValid) { tb.SaveChanges(); } return(1); } catch (DbUpdateException) { throw; } }
public int Delete(string id) { try { Noiphathanh nph = tb.Noiphathanh.Find(id); if (nph != null) { tb.Noiphathanh.Remove(nph); tb.SaveChanges(); return(1); } else { return(0); } } catch { throw; } }