public async Task <GeoLineResult> SendGeoLineRequest(GeoLineRequest geoLineRequest)
        {
            var sendOptions = new SendOptions();

            sendOptions.SetDestination("GeoAPI.GeoCalcServer");
            var geoLineResponse = await _messageSession.Request <GeoLineResult>(geoLineRequest, sendOptions);

            return(geoLineResponse);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CalculateDistance([FromBody] GeoPointsViewModel model)
        {
            try
            {
                log.Info($"new calculation request({User.Identity.Name}) : {model}");
                var geoLineRequest =
                    new GeoLineRequest
                {
                    FromLat  = model.FromLat,
                    FromLong = model.FromLong,
                    ToLat    = model.ToLat,
                    ToLong   = model.ToLong,
                    UserId   = User.Identity.Name
                };

                var geoLineResponse = await _busService.SendGeoLineRequest(geoLineRequest);

                await _busService.SaveGeoLineResult(new GeoLineResult
                {
                    UserId   = User.Identity.Name,
                    Distance = geoLineResponse.Distance,
                    FromLat  = geoLineResponse.FromLat,
                    FromLong = geoLineResponse.FromLong,
                    ToLat    = geoLineResponse.ToLat,
                    ToLong   = geoLineResponse.ToLong
                });


                return(Ok(new
                {
                    FromLat = model.FromLat,
                    FromLong = model.FromLong,
                    ToLat = model.ToLat,
                    ToLong = model.ToLong,
                    Distance = geoLineResponse.Distance
                }));
            }
            catch (System.Exception ex)
            {
                log.Error(ex.Message, ex);
                throw;
            }
        }