Exemplo n.º 1
0
        public async void LoadViaje()
        {
            LoginModel       = new LoginDataBase();
            viajesModel      = new ViajesDataBase();
            viajes           = new ViajesModel();
            intermedios      = new IntermediosModel();
            intermediosModel = new IntermediosDataBase();



            var usua = LoginModel.GetMembers();

            foreach (var item in usua)
            {
                this.idusuario = item.id;
            }
            var loginPOS = new GeneralModel
            {
                id = idusuario,
            };

            var url        = Application.Current.Resources["UrlAPI"].ToString();
            var prefix     = Application.Current.Resources["UrlPrefix"].ToString();
            var controller = Application.Current.Resources["UrlViajes"].ToString();
            var response   = await this.apiService.Post <GeneralModel>(url, prefix, controller, loginPOS);

            if (!response.IsSuccess)
            {
                await App.Current.MainPage.DisplayAlert("Error", "Este usuario aun no tiene viajes asignados", "Aceptar");

                return;
            }

            this.MyViajes = (List <GeneralModel>)response.Result;

            if (MyViajes != null)
            {
                viajesModel.DeleteTable();
            }

            //Agregar a la tabla de viajes

            foreach (var item in MyViajes)
            {
                viajes.id        = item.id;
                viajes.nombre    = item.nombre + " " + item.horaViaje;
                viajes.idOrigen  = item.idOrigen;
                viajes.idDestino = item.idDestino;
                viajes.origen    = item.origen;
                viajes.destino   = item.destino;
                viajes.valor     = item.valor;
                viajes.Hora      = item.horaViaje;
                viajes.Bus       = item.Bus;
                viajes.Placa     = item.Placa;

                viajesModel.AddMember(viajes);
            }

            this.Viajespick = new ObservableCollection <ViajesModel>(viajesModel.GetMembers().OrderBy(x => x.nombre));
        }
        public TicketsViewModel()
        {
            this.IsEnableAct         = true;
            this.IsEnableVal         = true;
            this.AlertaTicket        = false;
            this.IsVisible           = true;
            this.IsVisibleOrigen     = false;
            this.IsVisibleOrigenPick = true;
            this.IsVisibleAlert      = true;
            this.TickPer             = true;
            this.TickEnco            = false;
            this.NoPersonas          = 1;
            this.ValTicket           = val * NoPersonas;

            this.apiService       = new ApiService();
            this.IntermediosModel = new IntermediosDataBase();
            this.UbicacionesModel = new UbicacionesDataBase();
            this.LoadIntermedios();
            blueToothService    = DependencyService.Get <IBlueToothService>();
            this.OrigenPickSgte = null;
            this.Posicion       = 1;
            this.BindDeviceList();
        }