Пример #1
0
 public ISet <InstallationDto> GetAllNearby(InstallationGetAllNearbyCommand command)
 => _installationIntegration.GetInstallationsNearby(command)
 .PeekLeft(integrationFailure =>
 {
     _logger.LogWarning($"Integration failure = {integrationFailure}");
 })
 .Map(CreateOrUpdateBatch)
 .GetOrElse(new HashSet <InstallationDto>());
        public IActionResult Nearby(double latitude, double longitude) // TODO required queryParams
        {
            var installations = _integration
                                .GetAllNearby(InstallationGetAllNearbyCommand.Create(latitude, longitude))
                                .Select(InstallationViewModel.Success)
                                .ToHashSet();

            return(View(InstallationNearbyViewModel.Success(latitude, longitude, installations)));
        }
Пример #3
0
 public ISet <InstallationDto> GetAllNearby(InstallationGetAllNearbyCommand command)
 {
     return(TracedOperation.CallSync
            (
                _logger,
                InstallationOperationType.GetAllInstallationsNearby,
                command,
                () => _repository.FindAllByLocation(command.Latitude, command.Longitude, command.Radius)
                .Select(InstallationDto.FromDomain)
                .ToHashSet()
            ));
 }
 // TODO return either
 public ISet <InstallationDto> GetAllNearby(InstallationGetAllNearbyCommand command)
 => _integration.GetInstallationsNearby(command)
 // TODO createBatch
 .Map(installations =>
 {
     return(installations.Select(CreateInstallation)
            .Where(it =>
     {
         if (it.IsLeft)
         {
             // TODO info which failed through error
             _logger.LogWarning("Core result was a failure and will be skipped in result set.");
         }
         return it.IsRight;
     })
            .Select(it => it.Get)
            .ToHashSet());
 })
 .GetOrElse(new HashSet <InstallationDto>());
Пример #5
0
 public Either <InstallationError, IEnumerable <InstallationCreateCommand> > GetInstallationsNearby(InstallationGetAllNearbyCommand command)
 {
     return(TracedOperation.CallSync
            (
                _logger,
                ClientOperationType.GetNearbyInstallations,
                command,
                () => SynchronizeHttpCall // TODO move this to `TracedOperationClass` cos like that it kills a purpose of this class xD
                (
                    _airlyClient.GetInstallationsNearest(AirMonitorToAirlyClientInstallationAdapter.FromCommand(command))
                )
            )
            .Map(AirlyClientToAirMonitorInstallationAdapter.FromResponse)
            .MapLeft(AirlyClientToAirMonitorInstallationAdapter.ErrorFromResponse));
 }
 public static GetInstallationsNearestRequest FromCommand(InstallationGetAllNearbyCommand command)
 => GetInstallationsNearestRequest.Create(command.Latitude, command.Longitude, command.Radius);