💻 Sample C# Web client for the API
Website / Api
๐Ÿ‘ 0 ๐Ÿ‘Ž 0

For developers

Download sample web client code (C# / MVC) to call the API endpoints via the NuGet GeoARIt.Api library (Source code).

Try it out at dotnetfiddle.net

Not all endpoints are mapped in yet. You can generate the GeoARIt.Api C# code using these instructions.

Sample code taken from the project :-


using GeoARIt.Api;
using GeoARIt.Api.Client;
using GeoARIt.Client.Web.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;

///
/// https://geoar.it/Help/Details/๐Ÿ“‘~32~๐Ÿ”‘-How-do-I-get-an-APi-Key
/// 
namespace GeoARIt.Client.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger _logger;

        public HomeController(ILogger logger)
        {
            _logger = logger;
        }

        public async Task Index()
        {
            var apiVersion = "1";
            int rnd = new Random().Next(1, demoVenueGuids.Count + 1);

            // Added here to show example.Api key configuration would normally be called once at startup(Startup.cs)
            // Don't code ApiKeys in production code https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?tabs=windows&view=aspnetcore-6.0
            var authKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjU1MWEyZTgzLWM0MzgtNDEyNi1hMGY4LWJkOWYxM2VkMWY4NCIsIm5iZiI6MTY1Mjk5MzUyMywiZXhwIjoxOTY4MzUzNTIzLCJpYXQiOjE2NTI5OTM1MjN9.YVCid81mcqABi2H4P-aqwFZJywUjl_9aNJveARpCloI";
            var configuration = new Configuration();
            configuration.ApiKeyPrefix.Add("Authorization", $"Bearer {authKey}");

            var viewModel = new VenueHotspotsViewModel()
            {
                VenueGuid = demoVenueGuids[rnd - 1],
                Venue = await new VenueApi(configuration).VenueAsync(demoVenueGuids[rnd - 1], apiVersion, ""),

                Hotspots = (await new HotspotsForVenueApi(configuration).HotspotsForVenueAsync(demoVenueGuids[rnd - 1], 100, apiVersion, ""))
                    .OrderBy(x => x.Name)
                    .ToList()
            };

            return View(viewModel);
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }

        private readonly List<Guid> demoVenueGuids = new()
        {
            Guid.Parse("11111111-1111-1111-1111-05ECB3F6EA4C"), // Main 3D objects demo
            Guid.Parse("22222222-2222-2222-2222-f5d1563277e5"), // Acme Golf Course
            Guid.Parse("33333333-3333-3333-3333-05ECB3F6EA4A"), // Festival demo
        };
    }
}