public Tblsohuu get_sohuu_id(int id) { Tblsohuu sh = new Tblsohuu(); using (sql_NCKHContext db = new sql_NCKHContext()) { sh = db.Tblsohuus.SingleOrDefault(x => x.Id == id); } return(sh); }
public bool create_sohuu([FromBody] Tblsohuu sh) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { db.Tblsohuus.Add(sh); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool delete_sohuu(int id) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblsohuu d = db.Tblsohuus.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(true); } db.Tblsohuus.Remove(d); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool edit_sohuu(int id, [FromBody] Tblsohuu hs) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblsohuu d = db.Tblsohuus.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(false); } d.Tensohuu = hs.Tensohuu; d.Dmhtkinhphi = hs.Dmhtkinhphi; d.Dm = hs.Dm; d.Ghichu = hs.Ghichu; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }