public bool delete_loainhiemvu(int id) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblloainhiemvu d = db.Tblloainhiemvus.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(true); } db.Tblloainhiemvus.Remove(d); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public bool edit_loainhiemvu(int id, [FromBody] Tblloainhiemvu lnv) { try { using (sql_NCKHContext db = new sql_NCKHContext()) { Tblloainhiemvu d = db.Tblloainhiemvus.SingleOrDefault(x => x.Id == id); if (string.IsNullOrEmpty(d.ToString())) { return(false); } d.Tenloainv = lnv.Tenloainv; d.Ghichu = lnv.Ghichu; d.C = lnv.C; db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }