public bool create_hoatdongnckh([FromBody] Tblhoatdongnckh nc) { using (sql_NCKHContext db = new sql_NCKHContext()) { try { db.Tblhoatdongnckhs.Add(nc); db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public bool delete_hoatdongnckh(int id, [FromBody] Tblhoatdongnckh nc) { using (sql_NCKHContext db = new sql_NCKHContext()) { try { Tblhoatdongnckh kh = db.Tblhoatdongnckhs.SingleOrDefault(x => x.Id == id); if (kh == null) { return(false); } db.Tblhoatdongnckhs.Remove(kh); db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public bool edit_hoatdongnckh(int id, [FromBody] Tblhoatdongnckh nc) { using (sql_NCKHContext db = new sql_NCKHContext()) { try { Tblhoatdongnckh kh = db.Tblhoatdongnckhs.SingleOrDefault(x => x.Id == id); if (kh == null) { return(false); } kh.Tenhdnckh = nc.Tenhdnckh; kh.Dinhmuc = nc.Dinhmuc; kh.Dmhtkinhphi = nc.Dmhtkinhphi; kh.Ghichu = nc.Ghichu; kh.Idloaihd = nc.Idloaihd; return(true); } catch (Exception) { return(false); } } }