Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
 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);
     }
 }