public async Task <IActionResult> GetServerEndpoint([FromRoute(Name = "id")] int zoneId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ResolveServiceEndpointResponse(ResolveServiceEndpointResponseCode.GeneralRequestError)));
            }

            //We reuse the service discovery response model
            if (!await ZoneRepository.ContainsAsync(zoneId))
            {
                return(BadRequest(new ResolveServiceEndpointResponse(ResolveServiceEndpointResponseCode.ServiceUnlisted)));
            }

            //Small interval for race condition. So we try catch.
            try
            {
                ZoneInstanceEntryModel zone = await ZoneRepository.RetrieveAsync(zoneId);

                //Should be good, we just send them the endpoint
                if (zone != null)
                {
                    return(Ok(new ResolveServiceEndpointResponse(new ResolvedEndpoint(zone.ZoneServerAddress, zone.ZoneServerPort))));
                }
            }
            catch (Exception)
            {
                //TODO: Logging/event
            }

            return(BadRequest(new ResolveServiceEndpointResponse(ResolveServiceEndpointResponseCode.GeneralRequestError)));
        }
        /// <inheritdoc />
        public async Task <bool> TryCreateAsync(ZoneInstanceEntryModel model)
        {
#pragma warning disable AsyncFixer02 // Long running or blocking operations under an async method
            Context
            .ZoneEntries
            .Add(model);
#pragma warning restore AsyncFixer02 // Long running or blocking operations under an async method

            return(0 != await Context.SaveChangesAsync());
        }
        public async Task <IActionResult> GetZoneWorld([FromRoute(Name = "id")] int zoneId)
        {
            if (!await ZoneRepository.ContainsAsync(zoneId).ConfigureAwait(false))
            {
                Logger.LogError($"Failed to query for WorldId for Zone: {zoneId}");
                return(NotFound());
            }

            ZoneInstanceEntryModel entryModel = await ZoneRepository.RetrieveAsync(zoneId)
                                                .ConfigureAwait(false);

            //We just return the world that this zone is for.
            return(Ok(entryModel.WorldId));
        }
        /// <inheritdoc />
        public Task UpdateAsync(int key, ZoneInstanceEntryModel model)
        {
            GeneralGenericCrudRepositoryProvider <int, ZoneInstanceEntryModel> crudProvider = new GeneralGenericCrudRepositoryProvider <int, ZoneInstanceEntryModel>(Context.ZoneEntries, Context);

            return(crudProvider.UpdateAsync(key, model));
        }