public bool edit_congtac(int id, [FromBody] Tblcongtac dv) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblcongtac d = db.Tblcongtacs.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(false); } d.Noict = dv.Noict; d.Ngaybad = dv.Ngaybad; d.Ngaykt = dv.Ngaykt; d.Chucvu = dv.Chucvu; d.Chucdanh = dv.Chucdanh; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool delete_congtac(int id) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblcongtac d = db.Tblcongtacs.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(true); } db.Tblcongtacs.Remove(d); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }