예제 #1
0
 public HttpResponseMessage Update([FromBody] DX0011[] values)
 {
     using (QLDX_DB db = new QLDX_DB())
     {
         results <object> list = new results <object>();
         values.ToList().ForEach(val =>
         {
             result <object> rel = new result <object>();
             var check           = db.DX0011.SingleOrDefault(p => p.DX0011_ID == val.DX0011_ID);
             if (check != null)
             {
                 check.DX0013_ID  = val.DX0013_ID;
                 check.DX0014_ID  = val.DX0014_ID;
                 check.ghiChu     = val.ghiChu;
                 check.lat        = val.lat;
                 check.lng        = val.lng;
                 check.gioDon     = val.gioDon;
                 check.maDiemDon  = val.maDiemDon;
                 check.taxi       = val.taxi;
                 check.tenDiemDon = val.tenDiemDon;
                 check.thuTu      = val.thuTu;
                 check.trangThai  = val.trangThai;
                 try
                 {
                     db.SaveChanges();
                     rel.set("UPDATE", getDX0011(check));
                 }
                 catch (Exception s)
                 {
                     rel.set("ERR", null, s.Message);
                 }
             }
             else
             {
                 db.DX0011.Add(val);
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0011(val));
                 }
                 catch (Exception s)
                 {
                     rel.set("ERR", null, s.Message);
                 }
             }
             list.add(rel);
         });
         return(list.ToHttpResponseMessage());
     }
 }
예제 #2
0
        public HttpResponseMessage add([FromBody] DX0013[] values)
        {
            using (QLDX_DB db = new QLDX_DB())
            {
                results <object> list = new results <object>();
                values.ToList().ForEach(val =>
                {
                    result <object> rel = new result <object>();
                    var check           = db.DX0013.SingleOrDefault(p => p.DX0013_ID == val.DX0013_ID);
                    if (check == null)
                    {
                        db.DX0013.Add(val);
                        try
                        {
                            db.SaveChanges();

                            rel.set("OK", getDX0013(val), "Thành công.");
                        }
                        catch (Exception f)
                        {
                            rel.set("ERR", getDX0013(val), "Thất bại: ");
                        }
                    }
                    else
                    {
                        check.ghiChu      = val.ghiChu;
                        check.lat         = val.lat;
                        check.lng         = val.lng;
                        check.maDiemTaxi  = val.maDiemTaxi;
                        check.tenDiemTaxi = val.tenDiemTaxi;
                        check.trangThai   = val.trangThai;

                        try
                        {
                            db.SaveChanges();

                            rel.set("UPDATE", getDX0013(check), "Thành công.");
                        }
                        catch (Exception f)
                        {
                            rel.set("ERR", getDX0013(val), "Thất bại: ");
                        }
                    }
                    list.add(rel);
                });
                return(list.ToHttpResponseMessage());
            }
        }
예제 #3
0
 public HttpResponseMessage delete([FromBody] DX0070[] values)
 {
     using (QLDX_DB db = new QLDX_DB())
     {
         results <object> list = new results <object>();
         values.ToList().ForEach(val => {
             result <object> rel = new result <object>();
             var check           = db.DX0070.SingleOrDefault(p => p.DX0070_ID == val.DX0070_ID);
             if (check != null)
             {
                 db.DX0070.Remove(check);
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0070(val));
                 }
                 catch (Exception d)
                 {
                     rel.set("ERR", val, d.Message);
                 }
             }
             else
             {
                 rel.set("NOT_EXIST", val);
             }
             list.add(rel);
         });
         return(list.ToHttpResponseMessage());
     }
 }
예제 #4
0
        public HttpResponseMessage Deletes([FromBody] DX0011[] values)
        {
            using (QLDX_DB db = new QLDX_DB())
            {
                results <object> list = new results <object>();
                values.ToList().ForEach(val =>
                {
                    result <object> rel = new result <object>();
                    var check           = db.DX0011.SingleOrDefault(p => p.DX0011_ID == val.DX0011_ID);
                    if (check != null)
                    {
                        db.DX0011.Remove(check);
                        try
                        {
                            db.SaveChanges();
                            rel.set("DELETE", getDX0011(check));
                        }
                        catch (Exception s)
                        {
                            rel.set("ERR", getDX0011(check), s.Message);
                        }
                    }
                    list.add(rel);
                });

                return(list.ToHttpResponseMessage());
            }
        }
 public HttpResponseMessage add([FromBody] DX0001[] values)
 {
     using (QLDX_DB db = new QLDX_DB())
     {
         results <object> list = new results <object>();
         values.ToList().ForEach(val =>
         {
             result <object> rel = new result <object>();
             var check           = db.DX0001.Where(p => p.A0028_ID == val.A0028_ID).FirstOrDefault();
             if (check == null)
             {
                 db.DX0001.Add(val);
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0001(val));
                 }
                 catch (Exception f)
                 {
                     rel.set("ERR", getDX0001(val), f.Message);
                 }
             }
             else
             {
                 rel.set("EXIST", getDX0001(check));
             }
             list.add(rel);
         });
         return(list.ToHttpResponseMessage());
     }
 }
예제 #6
0
 public HttpResponseMessage add([FromBody] DX0050[] values)
 {
     using (QLDX_DB db = new QLDX_DB())
     {
         results <object> list = new results <object>();
         values.ToList().ForEach(val => {
             result <object> rel = new result <object>();
             var check           = db.DX0050.SingleOrDefault(p => p.DX0050_ID == val.DX0050_ID);
             if (check == null)
             {
                 db.DX0050.Add(val);
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0050(val));
                 }
                 catch (Exception d)
                 {
                     rel.set("ERR", val, d.Message);
                 }
             }
             else
             {
                 check.ghiChu       = val.ghiChu;
                 check.hangTaxi     = val.hangTaxi;
                 check.trangThai    = val.trangThai;
                 check.loaiThe      = val.loaiThe;
                 check.maThe        = val.maThe;
                 check.ngayHetHan   = val.ngayHetHan;
                 check.ngayPhatHanh = val.ngayPhatHanh;
                 check.soThe        = val.soThe;
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0050(check));
                 }
                 catch (Exception d)
                 {
                     rel.set("ERR", getDX0050(check), d.Message);
                 }
             }
             list.add(rel);
         });
         return(list.ToHttpResponseMessage());
     }
 }
 public HttpResponseMessage add([FromBody] DX0010[] values)
 {
     using (QLDX_DB db = new QLDX_DB())
     {
         results <object> list = new results <object>();
         values.ToList().ForEach(val =>
         {
             result <object> rel = new result <object>();
             var check           = db.DX0010.SingleOrDefault(p => p.DX0010_ID == val.DX0010_ID);
             if (check != null)
             {
                 check.ghiChu     = val.ghiChu;
                 check.maTuyenXe  = val.maTuyenXe;
                 check.tenTuyenXe = val.tenTuyenXe;
                 check.thuTu      = val.thuTu;
                 check.trangThai  = val.trangThai;
                 check.type       = val.type;
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0010(check));
                 }
                 catch (Exception ee)
                 {
                     rel.set("ERR", getDX0010(val), ee.Message);
                 }
             }
             else
             {
                 db.DX0010.Add(val);
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0010(val));
                 }
                 catch (Exception ee)
                 {
                     rel.set("ERR", getDX0010(val), ee.Message);
                 }
             }
             list.add(rel);
         });
         return(list.ToHttpResponseMessage());
     }
 }
 public HttpResponseMessage add([FromBody] DX0012[] values)
 {
     using (QLDX_DB db = new QLDX_DB())
     {
         results <object> list = new results <object>();
         values.ToList().ForEach(val => {
             result <object> rel = new result <object>();
             var check           = db.DX0012.SingleOrDefault(p => p.DX0012_ID == val.DX0012_ID);
             if (check == null)
             {
                 db.DX0012.Add(val);
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0012(val));
                 }
                 catch (Exception d)
                 {
                     rel.set("ERR", val, d.Message);
                 }
             }
             else
             {
                 check.ghiChu     = val.ghiChu;
                 check.bienSoXe   = val.bienSoXe;
                 check.DX0010_ID  = val.DX0010_ID;
                 check.mobile     = val.mobile;
                 check.soLuongGhe = val.soLuongGhe;
                 check.tenLaiXe   = val.tenLaiXe;
                 check.trangThai  = val.trangThai;
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0012(check));
                 }
                 catch (Exception d)
                 {
                     rel.set("ERR", getDX0012(check), d.Message);
                 }
             }
             list.add(rel);
         });
         return(list.ToHttpResponseMessage());
     }
 }
 public HttpResponseMessage add([FromBody] DX0010D[] values)
 {
     using (QLDX_DB db = new QLDX_DB())
     {
         results <object> list = new results <object>();
         values.ToList().ForEach(val =>
         {
             result <object> rel = new result <object>();
             var check           = db.DX0010D.Where(p => p.DX0010_ID == val.DX0010_ID && p.DX0011_ID == val.DX0011_ID).FirstOrDefault();
             if (check == null)
             {
                 var l = new DX0010D()
                 {
                     thuTu = val.thuTu, DX0010_ID = val.DX0010_ID, DX0011_ID = val.DX0011_ID, ghiChu = val.ghiChu
                 };
                 db.DX0010D.Add(l);
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0010D(val));
                 }
                 catch (Exception f)
                 {
                     rel.set("ERR", getDX0010D(val), f.Message);
                 }
             }
             else
             {
                 check.thuTu = val.thuTu;
                 try
                 {
                     db.SaveChanges();
                     rel.set("UPDATE", getDX0010D(val));
                 }
                 catch (Exception f)
                 {
                     rel.set("ERR", getDX0010D(val), f.Message);
                 }
             }
             list.add(rel);
         });
         return(list.ToHttpResponseMessage());
     }
 }
예제 #10
0
 public HttpResponseMessage add([FromBody] DX0070[] values)
 {
     using (QLDX_DB db = new QLDX_DB())
     {
         results <object> list = new results <object>();
         values.ToList().ForEach(val => {
             result <object> rel = new result <object>();
             var check           = db.DX0070.SingleOrDefault(p => p.DX0070_ID == val.DX0070_ID);
             if (check == null)
             {
                 db.DX0070.Add(val);
                 try
                 {
                     db.SaveChanges();
                     rel.set("OK", getDX0070(val));
                 }
                 catch (Exception d)
                 {
                     rel.set("ERR", val, d.Message);
                 }
             }
             else
             {
                 check.ghiChu      = val.ghiChu;
                 check.timeMin     = val.timeMin;
                 check.timeMax     = val.timeMax;
                 check.tenKhungGio = val.tenKhungGio;
                 check.trangThai   = val.trangThai;
                 try
                 {
                     db.SaveChanges();
                     rel.set("UPDATE", getDX0070(check));
                 }
                 catch (Exception d)
                 {
                     rel.set("ERR", getDX0070(check), d.Message);
                 }
             }
             list.add(rel);
         });
         return(list.ToHttpResponseMessage());
     }
 }
예제 #11
0
        public HttpResponseMessage add([FromBody] DX0060[] values)
        {
            //return REST.GetHttpResponseMessFromObject(values);
            results <object> list = new results <object>();

            using (QLDX_DB db = new QLDX_DB())
            {
                values.ToList().ForEach(val =>
                {
                    result <object> rel = new result <object>();
                    var check           = db.DX0060.SingleOrDefault(p => p.DX0060_ID == val.DX0060_ID);
                    if (check == null)
                    {
                        val.thoiGian  = DateTime.Now;
                        val.trangThai = false;
                        db.DX0060.Add(val);
                        try
                        {
                            db.SaveChanges();
                            val.DX0061.ToList().ForEach(v => {
                                var don = db.DX0001.SingleOrDefault(b => b.DX0001_ID == v.DX0001_ID);
                                if (don != null)
                                {
                                    don.trangThai = 3;
                                }
                            });
                            db.SaveChanges();
                            rel.set("OK", getDX00600(val), "Thành công.");
                        }
                        catch (Exception)
                        {
                            rel.set("ERR", getDX00600(val), "Thất bại: ");
                        }
                    }
                    else
                    {
                    }
                    list.add(rel);
                });
                return(list.ToHttpResponseMessage());
            }
        }
        public HttpResponseMessage add([FromBody] DX0001[] values)
        {
            using (QLDX_DB db = new QLDX_DB())
            {
                results <object> list = new results <object>();
                values.ToList().ForEach(val =>
                {
                    result <object> rel = new result <object>();
                    var data            = db.Database.SqlQuery <DX0020>("select * from DX0020 where manhansu='" + val.T002C + "'").FirstOrDefault();
                    if (data == null)
                    {
                        var kl = new DX0020()
                        {
                            ban_id           = val.T098C,
                            capbac           = val.T005C,
                            dienthoai_didong = val.T004C,
                            DX0011_ID        = val.T008C,
                            DX0010_ID        = val.T009C,
                            hodem            = val.T001C,
                            manhansu         = val.T002C,
                            trangThai        = 1,
                            phong_id         = val.T098C,
                            thoiGianSuDung   = val.T010C,
                        };
                        db.DX0020.Add(kl);
                        try
                        {
                            db.SaveChanges();
                            rel.set("OK", val, "Thành công.");
                        }
                        catch (Exception g)
                        {
                            rel.set("ERR", val, "Thất bại: ");
                        }
                    }
                    else
                    {
                        rel.set("EXIST", val, "Đã tồn tại.");
                    }
                    list.add(rel);
                });

                return(list.ToHttpResponseMessage());;
            }
        }
 public HttpResponseMessage delete([FromBody] DX0010D val)
 {
     using (QLDX_DB db = new QLDX_DB())
     {
         result <object> rel   = new result <object>();
         var             check = db.DX0010D.Where(p => p.DX0010_ID == val.DX0010_ID && p.DX0011_ID == val.DX0011_ID).FirstOrDefault();
         if (check != null)
         {
             db.DX0010D.Remove(check);
             try
             {
                 db.SaveChanges();
                 rel.set("OK", getDX0010D(val));
             }
             catch (Exception f)
             {
                 rel.set("ERR", getDX0010D(val), f.Message);
             }
         }
         return(rel.ToHttpResponseMessage());
     }
 }
예제 #14
0
 public HttpResponseMessage Delete([FromBody] DX0011 val)
 {
     using (QLDX_DB db = new QLDX_DB())
     {
         result <object> rel   = new result <object>();
         var             check = db.DX0011.SingleOrDefault(p => p.DX0011_ID == val.DX0011_ID);
         if (check != null)
         {
             db.DX0011.Remove(check);
             try
             {
                 db.SaveChanges();
                 rel.set("OK", null);
             }
             catch (Exception s)
             {
                 rel.set("ERR", null, s.Message);
             }
         }
         return(rel.ToHttpResponseMessage());
     }
 }