Пример #1
0
 public bool create_boiduong([FromBody] Tblboiduong bd)
 {
     try
     {
         using (sql_NCKHContext db = new sql_NCKHContext())
         {
             db.Tblboiduongs.Add(bd);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #2
0
 public bool delete_boiduong(int id)
 {
     try
     {
         using (sql_NCKHContext db = new sql_NCKHContext())
         {
             Tblboiduong d = db.Tblboiduongs.SingleOrDefault(x => x.Id == id);
             if (string.IsNullOrEmpty(d.ToString()))
             {
                 return(true);
             }
             db.Tblboiduongs.Remove(d);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #3
0
 public bool edit_boiduong(int id, [FromBody] Tblboiduong bd)
 {
     try
     {
         using (sql_NCKHContext db = new sql_NCKHContext())
         {
             Tblboiduong d = db.Tblboiduongs.SingleOrDefault(x => x.Id == id);
             if (string.IsNullOrEmpty(d.ToString()))
             {
                 return(false);
             }
             d.Noibd   = bd.Noibd;
             d.Ngaybd  = bd.Ngaybd;
             d.Ngaykt  = bd.Ngaykt;
             d.Noidung = bd.Noidung;
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }