// TODO based of installation id!!! public Either <MeasurementError, MeasurementDto> Create(MeasurementCreateCommand command) { return(TracedOperation.CallSync ( _logger, MeasurementOperationType.CreateMeasurement, command, () => _repository.TrySave(command.ToDomain()) .Map(MeasurementDto.FromDomain) .ToEither(MeasurementError.DuplicateExternalId(command.ExternalId)) )); }
public Either <MeasurementError, MeasurementDto> Update(MeasurementCreateCommand command) { return(TracedOperation.CallSync ( _logger, MeasurementOperationType.UpdateMeasurement, command, // TODO refactor () => { if (_repository.ExistsByExternalId(command.ExternalId)) { _repository.DeleteByExternalId(command.ExternalId); } return Create(command); } )); }
public static MeasurementCreateCommand FromApi(GetMeasurementByInstallationIdResponse api) => MeasurementCreateCommand.Create(api.Current.FromDateTime, api.Current.TillDateTime, ValueAdapter.FromApi(api.Current.Values), IndexAdapter.FromApi(api.Current.Indexes), StandardAdapter.FromApi(api.Current.Standards));