Пример #1
0
        public async Task <IActionResult> LoadStores()
        {
            RestAccess ra      = new RestAccess(Constants.ServiceClientEndPointWithApiPrefix);
            var        request = new ExGetShopsRequest
            {
                MyPosition = new BissPosition(47, 16),
                Range      = 2500
            };

            var allShops = await ra.GetShops(request);

            ShopViewModel vm = new ShopViewModel();

            vm.features = new List <Feature>();
            vm.type     = "FeatureCollection";

            if (allShops != null && allShops.Ok)
            {
                foreach (var exShop in allShops.Result)
                {
                    Feature f = new Feature();
                    f.geometry             = new Geometry();
                    f.geometry.type        = "Point";
                    f.geometry.coordinates = new List <double>();
                    f.geometry.coordinates.Add(exShop.Position.Longitude);
                    f.geometry.coordinates.Add(exShop.Position.Latitude);
                    f.type                = "Feature";
                    f.properties          = new Properties();
                    f.properties.category = String.Join(", ", exShop.Categories.Select(a => a.Name));

                    f.properties.name = exShop.Name;

                    f.properties.storeid = exShop.Id.ToString();

                    f.properties.isopen = exShop.IsOpen;

                    var color = exShop.IsOpen ? "%23FF228B22" : "%23FFDC143C";

                    var glyph = exShop.MainCategory?.Glyph ?? "E994";

                    f.properties.symbol = $"{Constants.ServiceClientEndPointWithApiPrefix}GlyphToIcon/{glyph}/{color}/%23FFFFFFFF/%20%2300FFFFFF/32/false";

                    vm.features.Add(f);
                }
            }

            // Get the data
            string ret = vm.ToJson();

            return(Content(ret, "application/json"));
        }