Beispiel #1
0
        public CustomerPaymentHistoryDetails GetLotParkingDetailsByVehicleID()
        {
            CustomerPaymentHistoryDetails resultObj = new CustomerPaymentHistoryDetails();

            IsOnline = VerifyInternet();

            if (IsOnline)
            {
                if (App.Current.Properties.ContainsKey("apitoken"))
                {
                    CustomerVehicle obj_CustomerVehicle = new CustomerVehicle();
                    obj_CustomerVehicle.CustomerID        = CustomerID;
                    obj_CustomerVehicle.CustomerVehicleID = CustomerVehicleID;

                    var json    = JsonConvert.SerializeObject(obj_CustomerVehicle);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    resultObj = dal_Customer.GetLotParkingDetailsByVehicleID(Convert.ToString(App.Current.Properties["apitoken"]), obj_CustomerVehicle);
                }
            }
            else
            {
                DisplayAlert("", "Please check your network connectivity", "Ok");
            }

            return(resultObj);
        }
        public CustomerPaymentHistoryDetails GetLotParkingDetailsByVehicleID(string accessToken, CustomerVehicle objCustomerVehicle)
        {
            CustomerPaymentHistoryDetails objCPSD = new CustomerPaymentHistoryDetails();

            try
            {
                string baseUrl = Convert.ToString(App.Current.Properties["BaseURL"]);
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(baseUrl);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    // Add the Authorization header with the AccessToken.
                    client.DefaultRequestHeaders.Add("Authorization", "bearer  " + accessToken);
                    // create the URL string.
                    string url = "api/InstaConsumer/GetLotParkingDetailsByVehicleID";
                    // make the request

                    var json    = JsonConvert.SerializeObject(objCustomerVehicle);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = client.PostAsync(url, content).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        string jsonString = response.Content.ReadAsStringAsync().Result;
                        if (jsonString != null)
                        {
                            APIResponse apiResult = JsonConvert.DeserializeObject <APIResponse>(jsonString);

                            if (apiResult.Result)
                            {
                                objCPSD = JsonConvert.DeserializeObject <CustomerPaymentHistoryDetails>(Convert.ToString(apiResult.Object));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(objCPSD);
        }
Beispiel #3
0
        private async void btn_UpdateVehicleClicked(object sender, EventArgs e)
        {
            IsOnline = VerifyInternet();
            if (IsOnline)
            {
                btnUpdateVehicle.IsVisible = false;
                ShowLoading(true);

                CustomerPaymentHistoryDetails obj = GetLotParkingDetailsByVehicleID();

                if (obj.CustomerParkingSlotID != 0)
                {
                    if (obj.StatusID != 5 && obj.StatusID != 6)
                    {
                        btnUpdateVehicle.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "Unable to update Vehicle Info", "Ok");
                        return;
                    }
                    else
                    {
                        if (swtActive.IsToggled)
                        {
                            btnUpdateVehicle.IsVisible = true;
                            ShowLoading(false);
                            DisplayAlert("", "Unable to update Vehicle Info", "Ok");
                            return;
                        }
                    }

                    CustomerVehicle objCustomerVehicle = new CustomerVehicle();
                    objCustomerVehicle.CustomerVehicleMapperID = CustomerVehicleMapperID;
                    objCustomerVehicle.CustomerVehicleID       = CustomerVehicleID;
                    objCustomerVehicle.CustomerID       = CustomerID;
                    objCustomerVehicle.VehicleTypeCode  = VehicleTypeCode;
                    objCustomerVehicle.IsPrimaryVehicle = swtPrimary.IsToggled;
                    objCustomerVehicle.IsActive         = swtActive.IsToggled;
                    objCustomerVehicle.CreatedBy        = "CHECKIN";

                    if (App.Current.Properties.ContainsKey("apitoken"))
                    {
                        var json    = JsonConvert.SerializeObject(objCustomerVehicle);
                        var content = new StringContent(json, Encoding.UTF8, "application/json");
                        OCustomerVehicle resultObj = dal_Vehicle.UpdateCustomerVehicle(Convert.ToString(App.Current.Properties["apitoken"]), objCustomerVehicle);

                        if (resultObj.CustomerVehicleID != 0)
                        {
                            btnUpdateVehicle.IsVisible = true;
                            ShowLoading(false);
                            int CustomerID = 0;
                            if (App.Current.Properties.ContainsKey("CustomerID"))
                            {
                                CustomerID = Convert.ToInt32(App.Current.Properties["CustomerID"]);
                            }

                            await Navigation.PushAsync(new MyVehicles());
                        }
                    }
                    else
                    {
                        btnUpdateVehicle.IsVisible = true;
                        ShowLoading(false);
                    }
                }

                if (txtMake.Text == "" || txtMake.Text == null)
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Brand of your Vehicle", "Ok");
                    return;
                }

                var regexName = new Regex("^[a-zA-Z ]*$");
                if (!regexName.IsMatch(txtMake.Text.Trim()))
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter only alphabets for Vehicle Brand", "Ok");
                    return;
                }

                if (txtModel.Text == "" || txtModel.Text == null)
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Model of your Vehicle", "Ok");
                    return;
                }

                regexName = new Regex("^[a-zA-Z0-9 ]*$");
                if (!regexName.IsMatch(txtModel.Text.Trim()))
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please do not enter special characters for Vehicle Model", "Ok");
                    return;
                }

                if (txtColor.Text == "" || txtColor.Text == null)
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Color of your Vehicle", "Ok");
                    return;
                }

                regexName = new Regex("^[a-zA-Z ]*$");
                if (!regexName.IsMatch(txtColor.Text.Trim()))
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please do not enter special characters for Vehicle Color", "Ok");
                    return;
                }

                if (txtRegNumber.Text == "" || txtRegNumber.Text == null)
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter Registration Number of your Vehicle", "Ok");
                    return;
                }

                regexName = new Regex("^[a-zA-Z0-9]*$");
                if (!regexName.IsMatch(txtRegNumber.Text.Trim()))
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please enter only alphabets and numbers in Registration Number", "Ok");
                    return;
                }

                if (ValidRegistrationNumber(txtRegNumber.Text.Trim()))
                {
                    if (ValidateRegistrationNumber())
                    {
                        btnUpdateVehicle.IsVisible = true;
                        ShowLoading(false);
                        DisplayAlert("", "This Registration Number already exists!", "Ok");
                    }
                    else
                    {
                        CustomerVehicle objCustomerVehicle = new CustomerVehicle();
                        objCustomerVehicle.CustomerVehicleMapperID = CustomerVehicleMapperID;
                        objCustomerVehicle.CustomerVehicleID       = CustomerVehicleID;
                        objCustomerVehicle.CustomerID         = CustomerID;
                        objCustomerVehicle.VehicleTypeCode    = VehicleTypeCode;
                        objCustomerVehicle.Make               = txtMake.Text.Trim();
                        objCustomerVehicle.Model              = txtModel.Text.Trim();
                        objCustomerVehicle.Color              = txtColor.Text.Trim();
                        objCustomerVehicle.RegistrationNumber = txtRegNumber.Text.Trim();
                        objCustomerVehicle.IsPrimaryVehicle   = swtPrimary.IsToggled;
                        objCustomerVehicle.IsActive           = swtActive.IsToggled;
                        objCustomerVehicle.CreatedBy          = "NORMAL";

                        if (App.Current.Properties.ContainsKey("apitoken"))
                        {
                            var json    = JsonConvert.SerializeObject(objCustomerVehicle);
                            var content = new StringContent(json, Encoding.UTF8, "application/json");
                            OCustomerVehicle resultObj = dal_Vehicle.UpdateCustomerVehicle(Convert.ToString(App.Current.Properties["apitoken"]), objCustomerVehicle);

                            if (resultObj.CustomerVehicleID != 0)
                            {
                                App.Current.Properties["Vehicle"]            = true;
                                App.Current.Properties["VehicleTypeID"]      = resultObj.VehicleTypeID;
                                App.Current.Properties["CustomerVehicleID"]  = resultObj.CustomerVehicleID;
                                App.Current.Properties["RegistrationNumber"] = txtRegNumber.Text.Trim();
                                await Application.Current.SavePropertiesAsync();

                                btnUpdateVehicle.IsVisible = true;
                                ShowLoading(false);
                                int CustomerID = 0;
                                if (App.Current.Properties.ContainsKey("CustomerID"))
                                {
                                    CustomerID = Convert.ToInt32(App.Current.Properties["CustomerID"]);
                                }

                                await Navigation.PushAsync(new MyVehicles());
                            }
                        }
                        else
                        {
                            btnUpdateVehicle.IsVisible = true;
                            ShowLoading(false);
                        }
                    }
                }
                else
                {
                    btnUpdateVehicle.IsVisible = true;
                    ShowLoading(false);
                    DisplayAlert("", "Please provide valid vehicle Registration Number ", "Ok");
                }
            }
            else
            {
                await DisplayAlert("", "Please check your network connectivity", "Ok");

                return;
            }
        }