Esempio n. 1
0
        public ViolationVehicleFees GetViolationVehicleCharges(string accessToken, ViolationVehicleFees objfees)
        {
            ViolationVehicleFees violatinFeesDetails = new ViolationVehicleFees();

            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/InstaOperator/getViolationVehicleCharges";
                    // make the request

                    var json    = JsonConvert.SerializeObject(objfees);
                    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)
                            {
                                violatinFeesDetails = JsonConvert.DeserializeObject <ViolationVehicleFees>(Convert.ToString(apiResult.Object));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(violatinFeesDetails);
        }
        private void LoadParkingVehicleDetails(int customerParkingSlotID)
        {
            try
            {
                if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                {
                    objresult = objHome.GetSelectedParkedVehicleDetails(Convert.ToString(App.Current.Properties["apitoken"]), customerParkingSlotID);
                    if (objresult.CustomerParkingSlotID != 0)
                    {
                        labelParkingLocation.Text = objresult.LocationParkingLotID.LocationID.LocationName + "-" + objresult.LocationParkingLotID.LocationParkingLotName;
                        labelBayNumber.Text       = "Bay Number " + objresult.LocationParkingLotID.ParkingBayID.ParkingBayRange;
                        labelCheckInBy.Text       = objresult.CreatedByName + " #" + objresult.UserCode;
                        labelOverstayFrom.Text    = objresult.ExpectedStartTime == null ? null : Convert.ToDateTime(objresult.ExpectedStartTime).ToString("dd MMM yyyy, hh:mm tt");
                        labelOverstayTo.Text      = objresult.ActualEndTime == null?DateTime.Now.ToString("dd MMM yyyy, hh:mm tt") : Convert.ToDateTime(objresult.ActualEndTime).ToString("dd MMM yyyy, hh:mm tt");

                        User objloginuser = (User)App.Current.Properties["LoginUser"];
                        if (objloginuser.UserTypeID.UserTypeName.ToUpper() != "Operator".ToUpper())
                        {
                            slFOC.IsVisible = true;
                        }
                        imageVehicleImage.Source       = objresult.CustomerVehicleID.VehicleTypeID.VehicleIcon;
                        labelVehicleDetails.Text       = objresult.CustomerVehicleID.RegistrationNumber;
                        imageParkingFeeImage.Source    = "rupee_black.png";
                        labelParkingFeesDetails.Text   = (objresult.PaidAmount).ToString("N2") + "/-"; //(objresult.Amount+objresult.ExtendAmount).ToString("N2") + "/-";
                        labelPaidDueAmountDetails.Text = "( Parking Amount:" + Math.Abs(objresult.Amount - objresult.PaidDueAmount).ToString("N2") + "/-  " + "Paid Due Amount: " + objresult.PaidDueAmount.ToString("N2") + "/- )";
                        TimeSpan parkingduration = Convert.ToDateTime(objresult.ActualEndTime) - Convert.ToDateTime(objresult.ExpectedStartTime);
                        objresult.Duration = (objresult.Duration == "" || objresult.Duration == string.Empty ? "0" : objresult.Duration);
                        if (objresult.ApplicationTypeID.ApplicationTypeCode == "P")
                        {
                            labelParkingFeesDetails.Text = "Pass Check-In";
                            labelParkingPaymentType.Text = "";
                            imageParkingFeeImage.Source  = "";
                        }
                        else
                        {
                            labelParkingPaymentType.Text = "Paid for " + string.Format(((Math.Abs(parkingduration.Hours) == 0 || Math.Abs(parkingduration.Hours) == 1) ? Convert.ToInt32(objresult.Duration) : parkingduration.Hours) + "hr") + "- By " + objresult.PaymentTypeID.PaymentTypeName;
                        }
                        DateTime?actualendime = objresult.ActualEndTime == null ? DateTime.Now : Convert.ToDateTime(objresult.ActualEndTime);
                        if (actualendime != null)
                        {
                            DateTime CurrentTime = DateTime.Now;
                            TimeSpan t           = CurrentTime - Convert.ToDateTime(actualendime);
                            int      totalHours  = (t.Days > 0 ? t.Hours + (t.Days * 24) : t.Hours);

                            objInputs = new ViolationVehicleFees();
                            objInputs.CustomerParkingSlotId = objresult.CustomerParkingSlotID;
                            objInputs.LocationParkingLotID  = objresult.LocationParkingLotID.LocationParkingLotID;
                            objInputs.ParkingStartTime      = Convert.ToDateTime(actualendime);
                            objInputs.ParkingEndTime        = CurrentTime;
                            objInputs.VehicleTypeCode       = objresult.VehicleTypeID.VehicleTypeCode;
                            if (objresult.ClampFees > 0)
                            {
                                slCheckOut.IsVisible = false;
                                slCash.IsVisible     = true;
                                slEPay.IsVisible     = true;
                                objInputs            = dal_ViolationClamp.GetViolationVehicleCharges(Convert.ToString(App.Current.Properties["apitoken"]), objInputs);
                            }
                            else if ((Convert.ToInt32(t.TotalMinutes) > voilationBasicMinutes))
                            {
                                slCheckOut.IsVisible = false;
                                slCash.IsVisible     = true;
                                slEPay.IsVisible     = true;
                                objInputs            = dal_ViolationClamp.GetViolationVehicleCharges(Convert.ToString(App.Current.Properties["apitoken"]), objInputs);
                            }

                            labelOverstayTimeDetails.Text = "OVERSTAY- " + (objresult.ActualEndTime == null ? "" : Convert.ToDateTime(objresult.ActualEndTime).ToString("hh:mm tt")) + " TO " + DateTime.Now.ToString("hh:mm tt");
                            labelOverstayTime.Text        = string.Format(objInputs.TotalHours + " h : " + t.Minutes + " m");
                            objresult.ExtendAmount        = objInputs.ParkingFee;
                            objresult.Duration            = Convert.ToString(objInputs.TotalHours);
                        }

                        #region Clamp and Warning data loading

                        slVehicleWarning.IsVisible = (objresult.ViolationWarningCount >= 3) ? false : true;

                        checkBoxClampVehicle.IsChecked = objresult.IsClamp;
                        checkBoxClampVehicle.IsChecked = objresult.IsClamp;
                        checkBoxClampVehicle.IsEnabled = !objresult.IsClamp;
                        chkWarning.IsChecked           = objresult.IsWarning;
                        chkWarning.IsEnabled           = !objresult.IsWarning;
                        lblWarningCount.Text           = (objresult.ViolationWarningCount > 3) ? "" : Convert.ToString(objresult.ViolationWarningCount) + " Warning(s) Completed";
                        lblClampFees.Text   = (objresult.ClampFees > 0) ? objresult.ClampFees.ToString("N2") : "0.00";
                        lblParkingFees.Text = objInputs.ParkingFee == 0 ? "0.00" : objInputs.ParkingFee.ToString("N2");
                        lblTotal.Text       = (objresult.ClampFees + objInputs.ParkingFee).ToString("N2");
                        if (objresult.ViolationReasonID.ViolationReasonID != 0)
                        {
                            for (int x = 0; x < lstReasons.Count; x++)
                            {
                                if (lstReasons[x].Reason.ToUpper() == objresult.ViolationReasonID.Reason.ToUpper())
                                {
                                    pickerViolationReason.SelectedIndex = x;
                                    pickerViolationReason.IsEnabled     = false;
                                    checkBoxClampVehicle.IsEnabled      = false;
                                    chkWarning.IsEnabled = false;
                                }
                            }
                        }
                        slPaymentAndExpand.IsVisible = true;
                        frmClampbutton.IsVisible     = false;


                        #endregion
                    }
                    else
                    {
                        DisplayAlert("Alert", "Vehicle details unvailable,Please contact Admin", "Ok");
                    }
                }
            }
            catch (Exception ex)
            {
                ShowLoading(false);
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "OverstayVehicleInformation.xaml.cs", "", "LoadParkingVehicleDetails");
            }
        }
        public void GetViolationVehcileInformation(int customerParkingSlotID)
        {
            try
            {
                if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                {
                    objresult = dal_Home.GetSelectedParkedVehicleDetails(Convert.ToString(App.Current.Properties["apitoken"]), customerParkingSlotID);
                    if (objresult.CustomerParkingSlotID != 0)
                    {
                        User objloginuser = (User)App.Current.Properties["LoginUser"];
                        if (objloginuser.UserTypeID.UserTypeName.ToUpper() != "Operator".ToUpper())
                        {
                            slFOC.IsVisible = true;
                        }
                        if (objresult.VehicleParkingImage != null)
                        {
                            imageViolation.IsVisible = true;
                        }
                        labelParkingLocation.Text = objresult.LocationParkingLotID.LocationID.LocationName + "-" + objresult.LocationParkingLotID.LocationParkingLotName;
                        labelBayNumber.Text       = "Bay Number " + objresult.LocationParkingLotID.ParkingBayID.ParkingBayRange;
                        labelCheckInBy.Text       = objresult.CreatedByName + " #" + objresult.UserCode;
                        labelVehicleDetails.Text  = objresult.CustomerVehicleID.RegistrationNumber;
                        labelValidFrom.Text       = objresult.ExpectedStartTime == null?Convert.ToDateTime(objresult.ActualStartTime).ToString("dd MMM yyyy, hh:mm tt") : Convert.ToDateTime(objresult.ExpectedStartTime).ToString("dd MMM yyyy, hh:mm tt");

                        labelValidTo.Text = objresult.ActualEndTime == null?DateTime.Now.ToString("dd MMM yyyy, hh:mm tt") : Convert.ToDateTime(objresult.ActualEndTime).ToString("dd MMM yyyy, hh:mm tt");

                        imageVehicleImage.Source = objresult.CustomerVehicleID.VehicleTypeID.VehicleIcon;

                        DateTime starttime = objresult.ExpectedStartTime == null ? DateTime.Now : Convert.ToDateTime(objresult.ExpectedStartTime);
                        if (starttime != null)
                        {
                            DateTime CurrentTime = DateTime.Now;
                            TimeSpan t           = CurrentTime - starttime;
                            if (t != null)
                            {
                                int totalHours = (t.Days > 0 ? t.Hours + (t.Days * 24) : t.Hours);
                                labelReason.Text = objresult.ViolationReasonID.Reason;
                                ViolationVehicleFees objInputs = new ViolationVehicleFees();
                                objInputs.CustomerParkingSlotId = objresult.CustomerParkingSlotID;
                                objInputs.LocationParkingLotID  = objresult.LocationParkingLotID.LocationParkingLotID;
                                objInputs.ParkingStartTime      = starttime;
                                objInputs.ParkingEndTime        = CurrentTime;
                                objInputs.VehicleTypeCode       = objresult.VehicleTypeID.VehicleTypeCode;

                                //Get Violation Fees Details
                                objInputs               = dal_violation.GetViolationVehicleCharges(Convert.ToString(App.Current.Properties["apitoken"]), objInputs);
                                labelParkingFee.Text    = String.Format("{0:0.#}", objInputs.ParkingFee == 0 ? 0 : objInputs.ParkingFee);
                                objresult.Amount        = objInputs.ParkingFee;
                                objresult.ViolationFees = objInputs.TotalFee == 0 ? 0 : (Convert.ToDecimal(objInputs.TotalFee) - (objInputs.ClampFee));
                                lblWarningCount.Text    = (objresult.ViolationWarningCount > 3) ? "" : Convert.ToString(objresult.ViolationWarningCount) + " Warning(s)";
                                labelClampFee.Text      = String.Format("{0:0.#}", (objresult.IsWarning ? 0 : objresult.ClampFees));
                                labelDueAmount.Text     = String.Format("{0:0.#}", objresult.DueAmount);
                                labelTotalFee.Text      = String.Format("{0:0.#}", (objresult.ViolationFees + objresult.ClampFees + objresult.DueAmount));
                                objresult.Duration      = Convert.ToString(objInputs.TotalHours);
                                labelParkingHours.Text  = "Parked for " + string.Format(objInputs.TotalHours + "h:" + t.Minutes + "m");
                            }
                        }
                    }

                    else
                    {
                        DisplayAlert("Alert", "Vehicle already Checkedout", "Ok");
                    }
                }
            }
            catch (Exception ex)
            {
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "ViolationVehicleInformation.xaml.cs", "", "GetViolationVehcileInformation");
            }
        }