public bool delete_boiduong(int id) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblboiduong d = db.Tblboiduongs.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(true); } db.Tblboiduongs.Remove(d); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool edit_boiduong(int id, [FromBody] Tblboiduong bd) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblboiduong d = db.Tblboiduongs.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(false); } d.Noibd = bd.Noibd; d.Ngaybd = bd.Ngaybd; d.Ngaykt = bd.Ngaykt; d.Noidung = bd.Noidung; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }