public Form GetForm(TransferContext context) { if (null == context) { throw new ArgumentNullException(nameof(context)); } var template = TemplateLoader.LoadSubmitFormTemplate(context.ExtensionManager, ExtensionCatalog.FinishProtection); var templateWrapper = new FinishProtectionFormTemplateWrapper(template); var currencyService = context.UnityContainer.Resolve <ICurrencyService>(); var currency = currencyService.ObtainCurrencyByAccountNumber(context.Transfer.TargetPurse); templateWrapper.Control4Amount.CurrencyName = currencyService.AddPrefix(currency); var transfer = context.Transfer; var incomeValuesWrapper = new FinishProtectionFormValuesWrapper { Control1SourcePurse = transfer.SourcePurse, Control2TargetPurse = transfer.TargetPurse, Control3Amount = transfer.Amount, Control4Description = transfer.Description }; var form = new SubmitForm(); ErrorFormDisplayHelper.ApplyErrorAction(context.ExtensionManager, form); form.ApplyTemplate(template, incomeValuesWrapper.CollectIncomeValues()); form.ServiceCommand += (sender, args) => { if (!FinishProtectionFormValuesWrapper.Control1SourcePurseCommandFindIdentifier.Equals(args.Command)) { return; } var purseNumber = (string)args.Argument; IdentifierDisplayHelper.ShowFindIdentifierForm(form, context, purseNumber); }; form.WorkCallback = (step, list) => { var valuesWrapper = new FinishProtectionFormValuesWrapper(list); var transferService = context.UnityContainer.Resolve <ITransferService>(); transferService.FinishProtection(transfer.PrimaryId, valuesWrapper.Control6HoldingFeatureIsUsed ? string.Empty : valuesWrapper.Control5Code); return(new Dictionary <string, object>()); }; return(form); }
public Form GetForm(SessionContext context) { if (null == context) { throw new ArgumentNullException(nameof(context)); } var form = SubmitFormDisplayHelper.LoadSubmitFormByExtensionId(context.ExtensionManager, ExtensionCatalog.AddPurse); form.ServiceCommand += (sender, args) => { if (!AddPurseFormValuesWrapper.Control1PurseNumberCommandFindIdentifier.Equals(args.Command)) { return; } IdentifierDisplayHelper.ShowFindIdentifierForm(form, context, (string)args.Argument); }; form.WorkCallback = (step, list) => { var valuesWrapper = new AddPurseFormValuesWrapper(list); var purseService = context.UnityContainer.Resolve <IPurseService>(); purseService.AddPurse(valuesWrapper.Control1PurseNumber, valuesWrapper.Control2Alias); return(new Dictionary <string, object>()); }; form.FinalAction = objects => { EventBroker.OnPurseChanged(new DataChangedEventArgs { FreshDataRequired = false }); return(true); }; return(form); }
public Form GetForm(PurseContext context) { if (null == context) { throw new ArgumentNullException(nameof(context)); } var template = TemplateLoader.LoadSubmitFormTemplate(context.ExtensionManager, ExtensionCatalog.CreateTransfer); var origin = new AccountDropDownListOrigin(context.UnityContainer) { SelectedAccountNumber = context.Account.Number }; origin.FilterCriteria.HasMoney = true; origin.FilterCriteria.CurrencyCapabilities = CurrencyCapabilities.Transfer; var itemTemplates = AccountDisplayHelper.BuildAccountDropDownListItemTemplates(origin); var templateWrapper = new CreateTransferFormTemplateWrapper(template); templateWrapper.Control3FromPurse.Items.Clear(); templateWrapper.Control3FromPurse.Items.AddRange(itemTemplates); var form = new SubmitForm(); ErrorFormDisplayHelper.ApplyErrorAction(context.ExtensionManager, form); var incomeValuesWrapper = new CreateTransferFormValuesWrapper { Control1TransferId = context.Session.SettingsService.AllocateTransferId() }; form.ApplyTemplate(template, incomeValuesWrapper.CollectIncomeValues()); form.ServiceCommand += (sender, args) => { if (!CreateTransferFormValuesWrapper.Control2ToPurseCommandFindIdentifier.Equals(args.Command)) { return; } IdentifierDisplayHelper.ShowFindIdentifierForm(form, context, (string)args.Argument); }; form.WorkCallback = (step, list) => { var valuesWrapper = new CreateTransferFormValuesWrapper(list); var transferService = context.UnityContainer.Resolve <ITransferService>(); var originalTransfer = new OriginalTransfer(valuesWrapper.Control1TransferId, valuesWrapper.Control3FromPurse, valuesWrapper.Control2ToPurse, valuesWrapper.Control4Amount, valuesWrapper.Control5Description); if (valuesWrapper.Control6UsePaymentProtection) { originalTransfer.ProtectionPeriod = valuesWrapper.Control7ProtectionPeriod; if (!valuesWrapper.Control9ProtectionByTime) { originalTransfer.ProtectionCode = valuesWrapper.Control8ProtectionCode; } } transferService.CreateTransfer(originalTransfer); return(new Dictionary <string, object>()); }; form.FinalAction = objects => { EventBroker.OnPurseChanged(new DataChangedEventArgs { FreshDataRequired = true }); return(true); }; return(form); }
public Form GetForm(TransferContext context) { if (null == context) { throw new ArgumentNullException(nameof(context)); } var transfer = context.Transfer; var template = TemplateLoader.LoadSubmitFormTemplate(context.ExtensionManager, TransferType.Protected == context.Transfer.Type ? ExtensionCatalog.RejectProtection : ExtensionCatalog.Moneyback); var templateWrapper = new MoneybackFormTemplateWrapper(template); var currencyService = context.UnityContainer.Resolve <ICurrencyService>(); templateWrapper.Control6ReturnAmount.CurrencyName = currencyService.AddPrefix(currencyService.ObtainCurrencyByAccountNumber(transfer.SourcePurse)); templateWrapper.Control6ReturnAmount.AvailableAmount = transfer.Amount; templateWrapper.Control6ReturnAmount.DefaultValue = transfer.Amount; var form = new SubmitForm(); ErrorFormDisplayHelper.ApplyErrorAction(context.ExtensionManager, form); var formattingService = context.UnityContainer.Resolve <IFormattingService>(); var incomeValuesWrapper = new MoneybackFormValuesWrapper { Control1SourcePurse = transfer.SourcePurse, Control2TargetPurse = transfer.TargetPurse, Control3Amount = formattingService.FormatAmount(transfer.Amount), Control4Description = transfer.Description }; form.ApplyTemplate(template, incomeValuesWrapper.CollectIncomeValues()); form.ServiceCommand += (sender, args) => { if (!MoneybackFormValuesWrapper.Control1SourcePurseCommandFindIdentifier.Equals(args.Command)) { return; } var purseNumber = (string)args.Argument; IdentifierDisplayHelper.ShowFindIdentifierForm(form, context, purseNumber); }; form.WorkCallback = (step, list) => { var valuesWrapper = new MoneybackFormValuesWrapper(list); var transferService = context.UnityContainer.Resolve <ITransferService>(); if (TransferType.Protected == context.Transfer.Type) { transferService.RejectProtection(transfer.PrimaryId); } else { transferService.Moneyback(transfer.PrimaryId, valuesWrapper.Control5ReturnAmount); } return(new Dictionary <string, object>()); }; return(form); }