public bool edit_loaitintuc(int id, [FromBody] Tblloaitt ltt) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblloaitt d = db.Tblloaitts.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(false); } d.Tenloaitt = ltt.Tenloaitt; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool delete_loaitintuc(int id) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblloaitt d = db.Tblloaitts.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(true); } db.Tblloaitts.Remove(d); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }