예제 #1
0
 public HttpResponseMessage update([FromBody] KTX0040 values)
 {
     using (DB db = new DB())
     {
         result <KTX0040> rel = new result <KTX0040>();
         var check            = db.KTX0040.SingleOrDefault(p => p.KTX0040_ID == values.KTX0040_ID);
         if (check != null)
         {
             check.ghichu    = values.ghichu;
             check.image     = values.image;
             check.noidung   = values.noidung;
             check.thutu     = values.thutu;
             check.tieude    = values.tieude;
             check.trangthai = values.trangthai;
             try {
                 db.SaveChanges();
                 rel.set("OK", check, "Thành Công");
             } catch (Exception tf)
             {
                 rel.set("ERR", values, "Thất bại: " + tf.Message);
             }
         }
         else
         {
             rel.set("NaN", values, "Không thất dữ liệu");
         }
         return(rel.ToHttpResponseMessage());
     }
 }
예제 #2
0
 public HttpResponseMessage add([FromBody] KTX0040[] values)
 {
     using (DB db = new DB())
     {
         results <KTX0040> list = new results <KTX0040>();
         foreach (var value in values)
         {
             result <KTX0040> rel = new result <KTX0040>();
             KTX0040          t   = value;
             try
             {
                 var kkk = db.KTX0040.Add(t);
                 db.SaveChanges();
                 rel.set("OK", t, "Thành công");
             }
             catch (Exception rr)
             {
                 rel.set("ERR", t, "Thất bại: " + rr.Message);
             }
             list.add(rel);
         }
         return(list.ToHttpResponseMessage());
     }
 }