Esempio n. 1
0
        public async Task <UpdateTransactionResponseViewModel> UpdateTransaction([FromBody] DeliveryOptionsFormDataViewModel model)
        {
            string _TargetCurrencyCode = _geoCurrency.GetSessionCurrency(HttpContext);

            if (ModelState.IsValid)
            {
                var result = new { Succeeded = true };
                try
                {
                    UpdateTransactionCommandResult updateTransactionCommandResult = await _commandSender.Send <UpdateTransactionCommand, UpdateTransactionCommandResult>(new UpdateTransactionCommand
                    {
                        TransactionId            = model.TransactionId,
                        DeliveryDetail           = model.DeliveryDetail,
                        TargetCurrencyCode       = _TargetCurrencyCode,
                        EventTicketAttributeList = model.EventTicketAttributeList
                    });

                    UpdateTransactionResponseViewModel _returnvalue = new UpdateTransactionResponseViewModel
                    {
                        Success            = true,
                        TransactionId      = updateTransactionCommandResult.Id,
                        CurrencyId         = updateTransactionCommandResult.CurrencyId,
                        GrossTicketAmount  = updateTransactionCommandResult.GrossTicketAmount,
                        DeliveryCharges    = updateTransactionCommandResult.DeliveryCharges,
                        ConvenienceCharges = updateTransactionCommandResult.ConvenienceCharges,
                        ServiceCharge      = updateTransactionCommandResult.ServiceCharge,
                        DiscountAmount     = updateTransactionCommandResult.DiscountAmount,
                        NetTicketAmount    = updateTransactionCommandResult.NetTicketAmount,
                    };

                    //perform check for currency change to geo
                    _geoCurrency.DeliveryOptionsUpdate(_returnvalue, HttpContext);

                    return(_returnvalue);
                }
                catch (Exception ex)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, ex);
                    return(new UpdateTransactionResponseViewModel {
                        Success = false
                    });
                }
            }
            else
            {
                return(new UpdateTransactionResponseViewModel {
                    Success = false
                });
            }
        }
Esempio n. 2
0
        public UpdateTransactionResponseViewModel DeliveryOptionsUpdate(UpdateTransactionResponseViewModel updateTransactionResponseViewModel,
                                                                        HttpContext context)
        {
            if (_IsGeoCurrencySelectionEnabled && updateTransactionResponseViewModel != null)
            {
                string TargetCurrencyCode = GetSessionCurrency(context); //default or not loaded yet from home controller.
                int    TargetCurrencyID   = GetCurrencyID(TargetCurrencyCode).Id;
                if (updateTransactionResponseViewModel.GrossTicketAmount.HasValue)
                {
                    updateTransactionResponseViewModel.GrossTicketAmount = _currencyConverter.Exchange(updateTransactionResponseViewModel.GrossTicketAmount.Value, GetCurrencyCode(updateTransactionResponseViewModel.CurrencyId).Code, TargetCurrencyCode);
                }

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

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

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

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

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

                updateTransactionResponseViewModel.CurrencyId = TargetCurrencyID;
            }

            return(updateTransactionResponseViewModel);
        }