public override async Task InitializeAsync(object navigationData)
        {
            // await listarElementos();
            if (navigationData != null)
            {
                Elemento = navigationData as ElementoModelo; //en el elemento estan todas las propiedades que se quieran desplegar en la vista

                NombreDispensador = Elemento.NombreDispensador;
                Distancia         = Elemento.Distancia;
                NombreElemento    = Elemento.NombreElemento;
                Descripcion       = Elemento.Descripcion;
                NumCasillero      = Elemento.NumCasillero;
                Id = Elemento.Id;
            }
            else
            {
                Elemento = new ElementoModelo();
            }
            var idEmpresa            = Application.Current.Properties["idEmpresa"] as string;;
            var url                  = GlobalSettings.BASE_URL + GlobalSettings.TIEMPO_MAX_RESERVA + idEmpresa;
            var empresa              = new EmpresaModelo();
            var getUbicaciones       = new GetService <EmpresaModelo>(url);
            Tuple <bool, string> ans = await getUbicaciones.SendRequest(empresa);

            if (ans.Item1)
            {
                EmpresaModelo tiempo = JsonConvert.DeserializeObject <EmpresaModelo>(ans.Item2);
                Tiempo = tiempo.TiempoMaxReserva;
            }
        }
Пример #2
0
 public void Insertar(ElementoModelo objInsertar)
 {
     try
     {
         string Json = JsonConvert.SerializeObject(objInsertar);
         objElemento.Insertar("3", Json);
     }
     catch (Exception ex)
     {
         Mensajes.EscribirLog(Constantes.MensajeError, ex.Message, "SAF.Negocios.ElementoNegocio - Insertar");
         throw;
     }
 }
Пример #3
0
        private async Task ubicacionesCasilleros(int idDispensador)
        {
            var url                  = GlobalSettings.BASE_URL + GlobalSettings.ELEMENTOS + idDispensador + "/1"; //Bug del servicio, no esta validando por usuario solo por casillero , por eso le queme un numero
            var ubicacion            = new ElementoModelo();
            var getUbicaciones       = new GetService <ElementoModelo>(url);
            Tuple <bool, string> ans = await getUbicaciones.SendRequest(ubicacion);

            if (ans.Item1)
            {
                List <ElementoModelo> listadoElementos = JsonConvert.DeserializeObject <List <ElementoModelo> >(ans.Item2);
                Elementos = new ObservableCollection <ElementoModelo>(listadoElementos);
            }
        }
Пример #4
0
        private async Task listarElementos()
        {
            var idEmpresa            = Application.Current.Properties["idEmpresa"];
            var idUsuario            = Application.Current.Properties["UserID"];
            var url                  = GlobalSettings.BASE_URL + GlobalSettings.ELEMENTOS + idEmpresa + '/' + idUsuario;
            var elemento             = new ElementoModelo();
            var getElementos         = new GetService <ElementoModelo>(url);
            Tuple <bool, string> ans = await getElementos.SendRequest(elemento);

            if (ans.Item1)
            {
                List <ElementoModelo> listaElementos = JsonConvert.DeserializeObject <List <ElementoModelo> >(ans.Item2);
                try
                {
                    var position = await Geolocation.GetLastKnownLocationAsync();//gt current location

                    if (position != null)
                    {
                        var locator = CrossGeolocator.Current;
                        locator.DesiredAccuracy = 50;

                        Location locacionUsuario = new Location(position.Latitude, position.Longitude);
                        var      numDispositivos = listaElementos.Count;

                        for (int i = 0; i < numDispositivos; i++)
                        {
                            Location dispositivoLocacion = new Location(listaElementos[i].Latitud, listaElementos[i].Longitud);
                            listaElementos[i].Distancia = Math.Round(Location.CalculateDistance(dispositivoLocacion, locacionUsuario, DistanceUnits.Kilometers), 1);
                        }
                        listaElementos = listaElementos.OrderBy(item => item.Distancia).ToList <ElementoModelo>();
                    }
                }
                catch (FeatureNotSupportedException fnsEx)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Tu telefono no tiene gps", "OK");
                }
                catch (FeatureNotEnabledException fneEx)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "No tienes encendido el gps", "OK");
                }
                catch (PermissionException pEx)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Debes conceder los permisos para acceder a tu ubicacion", "OK");
                }
                catch (Exception ex)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "No pudimos detectar tu ubicacion", "OK");
                }
                Elementos = new ObservableCollection <ElementoModelo>(listaElementos);//displego la lista de dispensadores en la vista
            }
        }
Пример #5
0
 public bool Borrar(int id)
 {
     try
     {
         ElementoModelo objBorrar = new ElementoModelo();
         objBorrar.Id = (short)id;
         string Json = JsonConvert.SerializeObject(objBorrar);
         return(objElemento.Borrar("5", Json));
     }
     catch (Exception ex)
     {
         Mensajes.EscribirLog(Constantes.MensajeError, ex.Message, "SAF.Negocios.ElementoNegocio - Borrar");
         throw;
     }
 }
Пример #6
0
 public ActionResult ElementoInsertar(ElementoModelo objInsertar)
 {
     try
     {
         if (ModelState.IsValid)
         {
             SesionNegocio objSesionNegocio = new SesionNegocio();
             objElemento.AsignarSesion(objSesionNegocio.GetObjectFromJson <SesionModelo>(HttpContext.Session, "SesionUsuario"));
             objElemento.Insertar(objInsertar);
         }
         return(Json("{ success: 'true'}"));
     }
     catch (Exception ex)
     {
         Mensajes.EscribirLog(Constantes.MensajeError, ex.Message, "ElementoController - Insertar");
         return(View());
     }
 }
Пример #7
0
        private async Task DetalleDispositivo(ElementoModelo item) //El navigation object navigation data es la unica forma de pasar parametros con ese sistma de navegacion
        {
            item = ElementoTap as ElementoModelo;

            await NavigationService.NavigateToAsync <DetalleDispositivoViewModel>(item);
        }