//get info to send request to firebase server
        private void GetInfoFromDb(int status, int carID, int orderID)
        {
            DataClasses2DataContext db = new DataClasses2DataContext();
            //get car order from Lst_DatXe
            Table <Lst_DatXe> lst_datxe = db.GetTable <Lst_DatXe>();
            var queryOrder = from o in lst_datxe where o.id_dat_xe == orderID select o;
            var order      = queryOrder.FirstOrDefault();

            //get car information from Lst_Xe
            Table <Lst_Xe> lst_xe   = db.GetTable <Lst_Xe>();
            var            queryCar = from c in lst_xe where c.id_xe == carID select c;
            var            car      = queryCar.FirstOrDefault();

            //get driver's information from Lst_LaiXe
            Table <Lst_LaiXe> lst_laixe = db.GetTable <Lst_LaiXe>();
            var queryDriver             = from d in lst_laixe where d.id_lai_xe == car.id_lai_xe_chinh select d;
            var driver = queryDriver.FirstOrDefault();

            RequestFirebaseSendNoti(status, order, car, driver);
        }
        //get cartype to send to app
        public List <string> GetCarType()
        {
            List <string> carTypeList = new List <string>();

            DataClasses2DataContext db = new DataClasses2DataContext();

            Table <Lst_LoaiXe> listLoaiXe = db.GetTable <Lst_LoaiXe>();
            var query = from cartype in listLoaiXe select cartype;

            //concate car type - number of seat
            foreach (var cartype in query)
            {
                carTypeList.Add(cartype.ten_loai_xe + " - " + cartype.so_ghe);
            }

            return(carTypeList);
        }
        //save data to db
        private string saveRequestDataToDb(DataClasses2DataContext db, Dictionary <string, string> carOrder)
        {
            string success = "Success";
            string fail    = "Fail";

            carOrder.TryGetValue("originPlace", out string originPlace);
            carOrder.TryGetValue("originLatitude", out string orignLatitude);
            carOrder.TryGetValue("originLongitude", out string originLongitude);
            carOrder.TryGetValue("destinationPlace", out string destinationPlace);
            carOrder.TryGetValue("destinationLat", out string destinationLatitude);
            carOrder.TryGetValue("destinationLong", out string destinationLongitude);
            carOrder.TryGetValue("carType", out string carType);
            carOrder.TryGetValue("orderTime", out string orderTime);
            carOrder.TryGetValue("pickupTime", out string pickupTimeString);
            carOrder.TryGetValue("phoneNumber", out string phoneNumber);
            carOrder.TryGetValue("refreshed_token", out string registrationID);

            //decode
            Lst_DatXe newOrder = new Lst_DatXe();

            newOrder.diem_bat_dau  = HttpUtility.UrlDecode(originPlace);
            newOrder.lat_bat_dau   = Convert.ToDouble(HttpUtility.UrlDecode(orignLatitude));
            newOrder.long_bat_dau  = Convert.ToDouble(HttpUtility.UrlDecode(originLongitude));
            newOrder.diem_ket_thuc = HttpUtility.UrlDecode(destinationPlace);
            newOrder.lat_ket_thuc  = Convert.ToDouble(HttpUtility.UrlDecode(destinationLatitude));
            newOrder.long_ket_thuc = Convert.ToDouble(HttpUtility.UrlDecode(destinationLongitude));

            //split: ten xe - so ghe
            string car_type = HttpUtility.UrlDecode(carType);

            string[] seatNumber = car_type.Split('-');
            int      soGhe      = Convert.ToInt32(seatNumber[1]);

            newOrder.so_ghe = soGhe;

            Table <Lst_LoaiXe> listLoaiXe = db.GetTable <Lst_LoaiXe>();

            newOrder.id_loai_xe = (from idloaixe in listLoaiXe where Convert.ToInt32(idloaixe.so_ghe) == soGhe select idloaixe.id_loai_xe).First();

            string orderTimeDecoded = HttpUtility.UrlDecode(orderTime);

            newOrder.thoi_diem_dat_xe = DateTime.ParseExact(orderTimeDecoded, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

            string pickupTimeDecoded = HttpUtility.UrlDecode(pickupTimeString);

            newOrder.thoi_diem_khoi_hanh = DateTime.ParseExact(pickupTimeDecoded, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

            newOrder.sdt_nguoi_dat  = HttpUtility.UrlDecode(phoneNumber);
            newOrder.status         = 0;
            newOrder.registrationID = HttpUtility.UrlDecode(registrationID);

            try
            {
                db.Lst_DatXes.InsertOnSubmit(newOrder);
                db.SubmitChanges();
                return(success);
            }
            catch (Exception e)
            {
                return(fail);
            }
        }