Пример #1
0
        public void Consume(CurrencyUpdated @event)
        {
            var currencies = _repository.Currencies.Single(x => x.Code == @event.Code);

            currencies.Code = @event.Code;
            _repository.SaveChanges();
        }
Пример #2
0
        public CurrencyCRUDStatus Save(EditCurrencyData model)
        {
            var oldCode = model.OldCode;
            var oldName = model.OldName;

            var currency = _paymentRepository.Currencies.SingleOrDefault(c => c.Code == oldCode);

            if (currency == null)
            {
                return(new CurrencyCRUDStatus {
                    IsSuccess = false, Message = "invalidId"
                });
            }

            if (_queries.GetCurrencies().Any(c => c.Code == model.Code && c.Code != oldCode))
            {
                return(new CurrencyCRUDStatus {
                    IsSuccess = false, Message = "codeUnique"
                });
            }

            if (_queries.GetCurrencies().Any(c => c.Name == model.Name && c.Name != oldName))
            {
                return(new CurrencyCRUDStatus {
                    IsSuccess = false, Message = "nameUnique"
                });
            }

            using (var scope = CustomTransactionScope.GetTransactionScope())
            {
                var username = _actorInfoProvider.Actor.UserName;
                currency.UpdatedBy   = username;
                currency.DateUpdated = DateTimeOffset.UtcNow;
                currency.Name        = model.Name;
                currency.Remarks     = model.Remarks;

                _paymentRepository.SaveChanges();

                var currencyUpdated = new CurrencyUpdated
                {
                    OldCode = model.OldCode,
                    OldName = model.OldName,
                    Code    = currency.Code,
                    Name    = currency.Name,
                    Remarks = currency.Remarks
                };

                _eventBus.Publish(currencyUpdated);

                scope.Complete();
            }

            return(new CurrencyCRUDStatus {
                IsSuccess = true, Message = "updated"
            });
        }
Пример #3
0
        public void Consume(CurrencyUpdated message)
        {
            var currency = _brandRepository.Currencies.Single(x => x.Code == message.OldCode);

            if (currency == null)
            {
                throw new RegoException("No appropriate Currency found. Code: " + message.Code);
            }

            currency.Code = message.Code;
            currency.Name = message.Name;

            _brandRepository.SaveChanges();
        }
Пример #4
0
 private void UpdateProfitRate()
 {
     if (rate.coin != null)
     {
         CoinD = RoundDouble(rate.coin.Value * AVG.Value, 4);
         CoinM = RoundDouble(rate.coin.Value * AVG.Value * 30, 4);
     }
     if (rate.RUB != null)
     {
         СurrencyD    = RoundDouble(rate.RUB.Value * AVG.Value, 4);
         СurrencyM    = RoundDouble(rate.RUB.Value * AVG.Value * 30, 4);
         СurrencyType = "RUB";
         CurrencyUpdated?.Invoke();
     }
     else if (rate.USD != null)
     {
         СurrencyD    = RoundDouble(rate.USD.Value * AVG.Value, 4);
         СurrencyM    = RoundDouble(rate.USD.Value * AVG.Value * 30, 4);
         СurrencyType = "USD";
     }
 }
 public void Consume(CurrencyUpdated message)
 {
     _eventHandlers.Handle(message);
 }
Пример #6
0
 public void Handle(CurrencyUpdated @event)
 {
     AddActivityLog(AdminActivityLogCategory.Currency, @event);
 }