public Tblloaitt get_loaitintuc_id(int id)
        {
            Tblloaitt ltt = new Tblloaitt();

            using (sql_NCKHContext db = new sql_NCKHContext())
            {
                ltt = db.Tblloaitts.SingleOrDefault(x => x.Id == id);
            }
            return(ltt);
        }
 public bool create_loaitintuc([FromBody] Tblloaitt ltt)
 {
     try
     {
         using (sql_NCKHContext db = new sql_NCKHContext())
         {
             db.Tblloaitts.Add(ltt);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public bool edit_loaitintuc(int id, [FromBody] Tblloaitt ltt)
 {
     try
     {
         using (sql_NCKHContext db = new sql_NCKHContext())
         {
             Tblloaitt d = db.Tblloaitts.SingleOrDefault(x => x.Id == id);
             if (string.IsNullOrEmpty(d.ToString()))
             {
                 return(false);
             }
             d.Tenloaitt = ltt.Tenloaitt;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public bool delete_loaitintuc(int id)
 {
     try
     {
         using (sql_NCKHContext db = new sql_NCKHContext())
         {
             Tblloaitt d = db.Tblloaitts.SingleOrDefault(x => x.Id == id);
             if (string.IsNullOrEmpty(d.ToString()))
             {
                 return(true);
             }
             db.Tblloaitts.Remove(d);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }