Exemplo n.º 1
0
 public Either <InstallationError, InstallationDto> GetByExternalId(long id)
 {
     return(TracedOperation.CallSync
            (
                _logger,
                InstallationOperationType.GetInstallationByExternalId,
                id,
                () => _repository.FindByExternalId(id)
                .Map(InstallationDto.FromDomain)
                .ToEither(InstallationError.NotFoundByExternalId(id))
            ));
 }
Exemplo n.º 2
0
 public Either <InstallationError, InstallationDto> CreateInstallation(InstallationCreateCommand command)
 {
     return(TracedOperation.CallSync
            (
                _logger,
                InstallationOperationType.CreateInstallation,
                command,
                () => _repository.TrySave(command.ToDomain())
                .Map(InstallationDto.FromDomain)
                .ToEither(InstallationError.DuplicateExternalId(command.ExternalId))
            ));
 }
Exemplo n.º 3
0
        private Either <InstallationError, InstallationDto> _RunIntegration(InstallationDto installation)
        {
            var measurementIntegration = RunMeasurementIntegration(installation.ExternalId);

            if (measurementIntegration.IsLeft)
            {
                return(Either <InstallationError, InstallationDto> .Left <InstallationError, InstallationDto>(
                           InstallationError.MeasurementUpdateFailed(measurementIntegration.GetLeft)));
            }
            // TODO add measurements to installation
            return(Either <InstallationError, InstallationDto> .Right <InstallationError, InstallationDto>(
                       installation.WithMeasurement(measurementIntegration.Get)));
        }
 public static InstallationError ErrorFromResponse(AirlyClientError errorResponse)
 => InstallationError.ClientError(errorResponse.Message);
Exemplo n.º 5
0
 public static InstallationViewModel Failure(InstallationError error)
 => new InstallationViewModel(error);
Exemplo n.º 6
0
 private InstallationViewModel(InstallationError error)
 {
     this._error = error;
 }