Example #1
0
        public async Task UpdateAsync(MarketMakerStatus marketMakerStatus, string comment, string userId)
        {
            MarketMakerState marketMakerState = await GetAsync();

            marketMakerState.Status    = marketMakerStatus;
            marketMakerState.Timestamp = DateTime.UtcNow;

            await _marketMakerStateRepository.InsertOrReplaceAsync(marketMakerState);

            _cache.Set(marketMakerState);

            _log.InfoWithDetails("Market maker status updated", new
            {
                marketMakerState,
                comment,
                userId
            });
        }
        private async Task SetStateAsync(MarketMakerStatus status, MarketMakerError marketMakerError,
                                         string errorMessages, string comment, string userId)
        {
            var marketMakerState = new MarketMakerState
            {
                Time         = DateTime.UtcNow,
                Status       = status,
                Error        = marketMakerError,
                ErrorMessage = errorMessages
            };

            MarketMakerState currentMarketMakerState = await GetStateAsync();

            await _marketMakerStateRepository.InsertOrReplaceAsync(marketMakerState);

            _cache.Set(marketMakerState);

            _log.InfoWithDetails("Market maker state is changed.",
                                 new StateOperationContext(currentMarketMakerState.Status, marketMakerState.Status, comment, userId,
                                                           marketMakerState.Error, marketMakerState.ErrorMessage));
        }