public Tblphanhoi get_phanhoi_id(int id) { Tblphanhoi dv = new Tblphanhoi(); using (sql_NCKHContext db = new sql_NCKHContext()) { dv = db.Tblphanhois.SingleOrDefault(x => x.Id == id); } return(dv); }
public bool create_hoso([FromBody] Tblphanhoi dv) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { db.Tblphanhois.Add(dv); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool edit_phanhoi(int id, [FromBody] Tblphanhoi ph) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblphanhoi d = db.Tblphanhois.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(false); } db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }