public Tbllinhvuc get_linhvuc_id(int id) { Tbllinhvuc dv = new Tbllinhvuc(); using (sql_NCKHContext db = new sql_NCKHContext()) { dv = db.Tbllinhvucs.SingleOrDefault(x => x.Id == id); } return(dv); }
public bool create_linhvuc([FromBody] Tbllinhvuc lv) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { db.Tbllinhvucs.Add(lv); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool edit_linhvuc(int id, [FromBody] Tbllinhvuc lv) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tbllinhvuc d = db.Tbllinhvucs.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(false); } d.Tenlinhvuc = lv.Tenlinhvuc; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool delete_linhvuc(int id) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tbllinhvuc d = db.Tbllinhvucs.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(true); } db.Tbllinhvucs.Remove(d); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }