Beispiel #1
0
        public static m_profile register(m_register value)
        {
            string registerUrl = Constant.WebService.Production.Api.User.register;

            using (var client = new HttpClient())
            {
                try
                {
                    client.BaseAddress = new Uri(Host);
                    client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                    string postBody = JsonConvert.SerializeObject(value);
                    var    content  = new StringContent(postBody, Encoding.UTF8, "application/json");
                    var    response = client.PostAsync(registerUrl, content).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        var responseObj = JsonConvert.DeserializeObject <m_profile>(response.Content.ReadAsStringAsync().Result);
                        return(responseObj);
                    }
                    else
                    {
                        return(null);
                    }
                }
                finally
                {
                    client.Dispose();
                }
            }
        }
Beispiel #2
0
        private void register(m_register data)
        {
            var result = User.register(data);

            if (result != null)
            {
                if (result.code == 200)
                {
                    if (Device.RuntimePlatform == Device.Android)
                    {
                        DependencyService.Get <IMessage>().longAlert("ลงทะเบียนสำเร็จ");
                    }


                    Navigation.PushAsync(new Mainpage(result.data, _deviceID, _simSerial, _version));
                    Navigation.RemovePage(this);
                }
                else
                {
                    DisplayAlert("ไม่สามารถลงทะเบียนได้", result.message, "ตกลง");
                    //if(Device.RuntimePlatform == Device.Android)
                    //DependencyService.Get<IMessage>().longAlert(result.message);
                }
            }
            else
            {
                DisplayAlert("ไม่สามารถลงทะเบียนได้", "พบข้อผิดพลาดจากเซิฟเวอร์ กรุณาลงทะเบียนใหม่ในภายหลัง", "ตกลง");
                txtPhone.Text = "";
                //if(Device.RuntimePlatform == Device.Android)
                //DependencyService.Get<IMessage>().longAlert("พบข้อผิดพลาดจากเซิฟเวอร์ ไม่สามารถลงทะเบียนได้");
            }
        }
Beispiel #3
0
        async void Handle_ClickedAsync(object sender, System.EventArgs e)
        {
            if (string.IsNullOrEmpty(txtPhone.Text))
            {
                await DisplayAlert("ไม่สามารถลงทะเบียนได้", "กรุณากรอกหมายเลขโทรศัพท์ของท่าน", "ตกลง");

                txtPhone.Focus();
                return;
            }
            var        version = double.Parse(_version);
            m_register data    = new m_register();

            //data.citizen_no = txtCitizen.Text;
            data.phone_no = txtPhone.Text;
            //data.pin = txtPin.Text;
            data.device_id   = _deviceID;
            data.app_version = version;
            if (Device.RuntimePlatform == Device.iOS)
            {
                data.serial_sim = "1111111111";
                data.platform   = "IOS";
            }
            else if (Device.RuntimePlatform == Device.Android)
            {
                data.serial_sim = "2222222222";
                data.platform   = "ANDROID";
            }
            data.brand       = DeviceInfo.Manufacturer;
            data.model       = DeviceInfo.Model;
            data.api_version = DeviceInfo.VersionString;

            var result = User.preIdentify(data.phone_no);

            if (result != null)
            {
                if (result.code == 200)
                {
                    if (result.data.Count > 1)
                    {
                        List <string> menu = new List <string>();
                        foreach (var n in result.data)
                        {
                            menu.Add("คุณ" + n.CUST_NAME + "\n" + n.CITIZEN_NO);
                        }
                        var action = await DisplayActionSheet("D-Mobile App ยินดีต้อนรับ\n(กรุณาตรวจการชำระเงินทุกวัน)\nกรูณากดเลือก", null, "ไม่พบชื่อของท่าน", menu.ToArray());

                        Debug.WriteLine($"pipe => The action is {action}");
                        if (!string.IsNullOrEmpty(action))
                        {
                            if (action != "ไม่พบชื่อของท่าน")
                            {
                                var index = menu.IndexOf(action);
                                data.cust_no = result.data[index].CUST_NO;
                                register(data);
                            }
                            else if (action == "ไม่พบชื่อของท่าน")
                            {
                                txtPhone.Focus();
                            }
                        }
                    }
                    else
                    {
                        var action = await DisplayAlert("D-Mobile App ยินดีต้อนรับคุณ\n(กรุณาตรวจการชำระเงินทุกวัน)", $"คุณ {result.data.First().CUST_NAME}", "ใช่", "ไม่ใช่");

                        Debug.WriteLine($"pipe => The action is {action}");
                        if (action)
                        {
                            data.cust_no = result.data.First().CUST_NO;
                            register(data);
                        }
                        else
                        {
                            txtPhone.Focus();
                        }
                    }
                }
                else
                {
                    await DisplayAlert("ไม่สามารถลงทะเบียนได้", result.message, "ตกลง");
                }
            }
        }
Beispiel #4
0
        private async void btnRegister_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtPhone.Text))
            {
                await DisplayAlert("ไม่สามารถลงทะเบียนได้", "กรุณากรอกหมายเลขโทรศัพท์ของท่าน", "ตกลง");

                txtPhone.Focus();
                return;
            }
            var        version = double.Parse(_version);
            m_register data    = new m_register();

            //data.citizen_no = txtCitizen.Text;
            data.phone_no = txtPhone.Text;
            //data.pin = txtPin.Text;
            data.device_id   = _deviceID;
            data.app_version = version;
            if (Device.RuntimePlatform == Device.iOS)
            {
                data.serial_sim = "1111111111";
                data.platform   = "IOS";
            }
            else if (Device.RuntimePlatform == Device.Android)
            {
                data.serial_sim = "2222222222";
                data.platform   = "ANDROID";
            }
            data.brand       = DeviceInfo.Manufacturer;
            data.model       = DeviceInfo.Model;
            data.api_version = DeviceInfo.VersionString;

            var result = User.preIdentify(data.phone_no);

            if (result != null)
            {
                if (result.code == 200)
                {
                    if (result.data.Count > 1)
                    {
                        List <string> menu = new List <string>();
                        foreach (var n in result.data)
                        {
                            menu.Add("คุณ" + n.CUST_NAME + "\n" + n.CITIZEN_NO);
                        }
                        var action = await DisplayActionSheet("D-Mobile App ยินดีต้อนรับ\n(กรุณาตรวจการชำระเงินทุกวัน)\nกรูณากดเลือก", null, "ไม่พบชื่อของท่าน", menu.ToArray());

                        Debug.WriteLine($"pipe => The action is {action}");
                        if (!string.IsNullOrEmpty(action))
                        {
                            if (action != "ไม่พบชื่อของท่าน")
                            {
                                var index = menu.IndexOf(action);
                                data.cust_no = result.data[index].CUST_NO;
                                register(data);
                            }
                            else if (action == "ไม่พบชื่อของท่าน")
                            {
                                txtPhone.Focus();
                            }
                        }
                    }
                    else
                    {
                        var action = await DisplayAlert("D-Mobile App ยินดีต้อนรับคุณ\n(กรุณาตรวจการชำระเงินทุกวัน)", $"คุณ {result.data.First().CUST_NAME}", "ใช่", "ไม่ใช่");

                        Debug.WriteLine($"pipe => The action is {action}");
                        if (action)
                        {
                            data.cust_no = result.data.First().CUST_NO;
                            register(data);
                        }
                        else
                        {
                            txtPhone.Focus();
                        }
                    }
                }
                else
                {
                    await DisplayAlert("ไม่สามารถลงทะเบียนได้", result.message, "ตกลง");
                }
            }
            //var result = Services.User.register(data);
            //if(result != null)
            //{
            //    if(result.code == 200)
            //    {
            //        if(Device.RuntimePlatform == Device.Android)
            //            DependencyService.Get<IMessage>().longAlert("ลงทะเบียนสำเร็จ");


            //        Navigation.PushAsync(new Mainpage(result.data, _deviceID, _simSerial, _version));
            //        Navigation.RemovePage(this);

            //        //if (result.data.PERMIT == "BOTH")
            //        //{
            //        //    Navigation.PushAsync(new Mainpage(result.data));
            //        //    Navigation.RemovePage(this);
            //        //}
            //        //else if(result.data.PERMIT == "SMS")
            //        //{
            //        //    Navigation.PushAsync(new ChatSms(result.data));
            //        //    Navigation.RemovePage(this);
            //        //}
            //        //else if(result.data.PERMIT == "PAYMENT")
            //        //{
            //        //    Navigation.PushAsync(new LoanPage(result.data));
            //        //    Navigation.RemovePage(this);
            //        //}
            //    }
            //    else
            //    {
            //        DisplayAlert("ไม่สามารถลงทะเบียนได้", result.message, "ตกลง");
            //        //if(Device.RuntimePlatform == Device.Android)
            //        //DependencyService.Get<IMessage>().longAlert(result.message);
            //    }
            //}
            //else
            //{
            //    DisplayAlert("ไม่สามารถลงทะเบียนได้", "พบข้อผิดพลาดจากเซิฟเวอร์ กรุณาลงทะเบียนใหม่ในภายหลัง", "ตกลง");
            //    txtPhone.Text = "";
            //    //if(Device.RuntimePlatform == Device.Android)
            //        //DependencyService.Get<IMessage>().longAlert("พบข้อผิดพลาดจากเซิฟเวอร์ ไม่สามารถลงทะเบียนได้");
            //}
        }