Beispiel #1
0
        /// <summary>
        /// Método para la busqueda del sector idoneo de la compra
        /// </summary>
        /// <param name="compra"></param>
        public async Task BuscarSector(Compra compra)
        {
            var MiPosicion = new Posicion {
                Latitud = (double)compra.Latitud, Longitud = (double)compra.Longitud
            };

            var Sectores = db.Sector.ToList();

            if (Sectores != null && Sectores.Count > 0)
            {
                foreach (var sector in Sectores)
                {
                    try
                    {
                        var puntosSector = db.PuntoSector.Where(w => w.IdSector == sector.IdSector).Select(x => new Posicion
                        {
                            Latitud = (double)x.Latitud, Longitud = (double)x.Longitud
                        }).ToList();



                        if (puntosSector != null && puntosSector.Count > 0)
                        {
                            var Poligono = new System.Collections.ObjectModel.ObservableCollection <Posicion>(puntosSector);
                            if (Geo.IsPointInPolygonV2(Poligono, MiPosicion))
                            {
                                //Retornamos un objeto tipo response con el sector de la compra
                                DistribuidoresPorSector(sector.IdSector, compra);
                            }
                            else
                            {
                            }
                        }
                        else
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Write(ex.Message);
                    }
                }
                //Buscar el sector más cercano
                await SectorCercano(Sectores, MiPosicion, compra);
            }
        }