public bool delete_chucvu(int id) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblchucvu d = db.Tblchucvus.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(true); } db.Tblchucvus.Remove(d); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool edit_chucvu(int id, [FromBody] Tblchucvu cv) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblchucvu d = db.Tblchucvus.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(false); } d.Tenchucvu = cv.Tenchucvu; d.Dinhmuc = cv.Dinhmuc; d.Dieukien = cv.Dieukien; d.Ghichu = cv.Ghichu; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }