Пример #1
0
        public UpdateTransactionCommandResult UpdateTransactionUpdates(UpdateTransactionCommandResult updateTransactionCommandResult, string TargetCurrencyCode)
        {
            if (_IsGeoCurrencySelectionEnabled && updateTransactionCommandResult != null)
            {
                int TargetCurrencyID = GetCurrencyID(TargetCurrencyCode).Id;
                if (updateTransactionCommandResult.GrossTicketAmount.HasValue)
                {
                    updateTransactionCommandResult.GrossTicketAmount = _currencyConverter.Exchange(updateTransactionCommandResult.GrossTicketAmount.Value, GetCurrencyCode(updateTransactionCommandResult.CurrencyId).Code, TargetCurrencyCode);
                }

                if (updateTransactionCommandResult.DeliveryCharges.HasValue)
                {
                    updateTransactionCommandResult.DeliveryCharges = _currencyConverter.Exchange(updateTransactionCommandResult.DeliveryCharges.Value, GetCurrencyCode(updateTransactionCommandResult.CurrencyId).Code, TargetCurrencyCode);
                }

                if (updateTransactionCommandResult.ConvenienceCharges.HasValue)
                {
                    updateTransactionCommandResult.ConvenienceCharges = _currencyConverter.Exchange(updateTransactionCommandResult.ConvenienceCharges.Value, GetCurrencyCode(updateTransactionCommandResult.CurrencyId).Code, TargetCurrencyCode);
                }

                if (updateTransactionCommandResult.ServiceCharge.HasValue)
                {
                    updateTransactionCommandResult.ServiceCharge = _currencyConverter.Exchange(updateTransactionCommandResult.ServiceCharge.Value, GetCurrencyCode(updateTransactionCommandResult.CurrencyId).Code, TargetCurrencyCode);
                }

                if (updateTransactionCommandResult.DiscountAmount.HasValue)
                {
                    updateTransactionCommandResult.DiscountAmount = _currencyConverter.Exchange(updateTransactionCommandResult.DiscountAmount.Value, GetCurrencyCode(updateTransactionCommandResult.CurrencyId).Code, TargetCurrencyCode);
                }

                if (updateTransactionCommandResult.NetTicketAmount.HasValue)
                {
                    updateTransactionCommandResult.NetTicketAmount = _currencyConverter.Exchange(updateTransactionCommandResult.NetTicketAmount.Value, GetCurrencyCode(updateTransactionCommandResult.CurrencyId).Code, TargetCurrencyCode);
                }

                updateTransactionCommandResult.CurrencyId = TargetCurrencyID;;
            }

            return(updateTransactionCommandResult);
        }
Пример #2
0
        public List <ViewModels.CategoryHomePage.CategoryEventContainer> UpdateCategoriesCurrency(List <ViewModels.CategoryHomePage.CategoryEventContainer> categories,
                                                                                                  HttpContext _context)
        {
            var allCategories = new List <ViewModels.CategoryHomePage.CategoryEventContainer>(); //new categories list is to hold the filtered categories items

            try
            {
                if (_IsGeoCurrencySelectionEnabled && categories != null)
                {
                    string TargetCurrencyCode = GetSessionCurrency(_context);
                    int    TargetCurrencyID   = GetCurrencyID(TargetCurrencyCode).Id;

                    foreach (ViewModels.CategoryHomePage.CategoryEventContainer _cvc in categories)
                    {
                        if (_cvc.EventTicketAttribute.Any())
                        {
                            try
                            {
                                foreach (Contracts.Models.EventTicketAttribute _eta in _cvc.EventTicketAttribute)
                                {
                                    if (_eta.CurrencyId != 0)
                                    {
                                        _eta.Price = _currencyConverter.Exchange(_eta.Price, GetCurrencyCode(_eta.CurrencyId).Code, TargetCurrencyCode);
                                        _eta.SeasonPackagePrice = _currencyConverter.Exchange(_eta.SeasonPackagePrice, GetCurrencyCode(_eta.CurrencyId).Code, TargetCurrencyCode);
                                        _eta.Specialprice       = _currencyConverter.Exchange(_eta.Specialprice, GetCurrencyCode(_eta.CurrencyId).Code, TargetCurrencyCode);
                                        _eta.SpecialSeasonPrice = _currencyConverter.Exchange(_eta.SpecialSeasonPrice, GetCurrencyCode(_eta.CurrencyId).Code, TargetCurrencyCode);
                                        _eta.CurrencyId         = TargetCurrencyID;
                                    }
                                }
                                if (_cvc.CurrencyType != null)
                                {
                                    _cvc.CurrencyType.Code         = TargetCurrencyCode;
                                    _cvc.CurrencyType.Id           = TargetCurrencyID;
                                    _cvc.CurrencyType.CountryId    = GetCurrencyID(TargetCurrencyCode).CountryId;
                                    _cvc.CurrencyType.Name         = GetCurrencyID(TargetCurrencyCode).Name;
                                    _cvc.CurrencyType.ExchangeRate = 0; //fix this?
                                    allCategories.Add(_cvc);
                                }
                            }
                            catch (Exception e)
                            {
                                _logger.Log(LogCategory.Error, new Exception("", e));
                            }
                        }
                    }
                }
                return(allCategories);
            }
            catch (Exception e)
            {
                _logger.Log(LogCategory.Error, new Exception("", e));
                return(allCategories);
            }
        }