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