Exemple #1
0
        public DetallePage(ComprasRequest comprasRequest)
        {
            try
            {
                BindingContext = new DetalleViewModel(comprasRequest);

                InitializeComponent();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw;
            }
        }
Exemple #2
0
        public DetalleViewModel(ComprasRequest comprasRequest)
        {
            try
            {
                EstadoPedido = "";
                Compra       = comprasRequest;
                geoCoder     = new Xamarin.Forms.Maps.Geocoder();

                Point p = new Point(0.48, 0.96);


                Locations = new ObservableCollection <TKCustomMapPin>();
                locations = new ObservableCollection <TKCustomMapPin>();

                Locations.Clear();

                centerSearch = (MapSpan.FromCenterAndRadius((new TK.CustomMap.Position((double)Compra.Latitud, (double)Compra.Longitud)), Distance.FromMiles(.5)));
                Locations.Add(new TKCustomMapPin
                {
                    Image       = "casa",
                    Position    = new TK.CustomMap.Position((double)Compra.Latitud, (double)Compra.Longitud),
                    Anchor      = p,
                    ShowCallout = true,
                });

                switch (comprasRequest.Estado)
                {
                case -1:
                    EstadoPedido = "Cancelado";
                    isCancelable = false;
                    break;

                case 0:
                    EstadoPedido = "No atendido";
                    isCancelable = true;
                    break;

                case 1:
                    EstadoPedido = "Pendiente";
                    isCancelable = true;
                    break;

                case 2:
                    EstadoPedido = "Entregado";
                    isCancelable = false;
                    break;
                }

                var fecha = TimeZoneInfo.ConvertTime(comprasRequest.FechaPedido.Value, TimeZoneInfo.Local);

                FechaCompra    = fecha.ToString("yyyy-MM-dd") + " " + comprasRequest.FechaPedido.Value.ToShortTimeString();
                CantidadCompra = Compra.Cantidad.ToString();
                ValorCompra    = Compra.ValorTotal.ToString();


                ObtenerDireccion((double)Compra.Latitud, (double)Compra.Longitud);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw;
            }
        }