|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
| 1 | +using System.Collections.Generic; |
3 | 2 | using System.Web.Mvc; |
4 | | -using SmartStore.Core; |
5 | 3 | using SmartStore.Plugin.Payments.DirectDebit.Models; |
6 | 4 | using SmartStore.Services.Configuration; |
7 | 5 | using SmartStore.Services.Localization; |
8 | 6 | using SmartStore.Services.Payments; |
9 | | -using SmartStore.Services.Stores; |
10 | 7 | using SmartStore.Web.Framework.Controllers; |
11 | | -using SmartStore.Web.Framework.Settings; |
12 | 8 |
|
13 | 9 | namespace SmartStore.Plugin.Payments.DirectDebit.Controllers |
14 | 10 | { |
15 | 11 | public class PaymentDirectDebitController : PaymentControllerBase |
16 | 12 | { |
17 | | - private readonly IWorkContext _workContext; |
18 | | - private readonly IStoreService _storeService; |
19 | | - private readonly IStoreContext _storeContext; |
20 | | - private readonly ISettingService _settingService; |
21 | | - private readonly ILocalizationService _localizationService; |
| 13 | + private readonly ISettingService _settingService; |
| 14 | + private readonly DirectDebitPaymentSettings _directDebitPaymentSettings; |
| 15 | + private readonly ILocalizationService _localizationService; |
| 16 | + |
| 17 | + public PaymentDirectDebitController(ISettingService settingService, |
| 18 | + DirectDebitPaymentSettings directDebitPaymentSettings, |
| 19 | + ILocalizationService localizationService) |
| 20 | + { |
| 21 | + this._settingService = settingService; |
| 22 | + this._directDebitPaymentSettings = directDebitPaymentSettings; |
| 23 | + this._localizationService = localizationService; |
| 24 | + } |
22 | 25 |
|
23 | | - public PaymentDirectDebitController(IWorkContext workContext, |
24 | | - IStoreService storeService, |
25 | | - IStoreContext storeContext, |
26 | | - ISettingService settingService, |
27 | | - ILocalizationService localizationService) |
28 | | - { |
29 | | - this._workContext = workContext; |
30 | | - this._storeService = storeService; |
31 | | - this._storeContext = storeContext; |
32 | | - this._settingService = settingService; |
33 | | - this._localizationService = localizationService; |
34 | | - } |
35 | 26 |
|
36 | 27 | [AdminAuthorize] |
37 | 28 | [ChildActionOnly] |
38 | 29 | public ActionResult Configure() |
39 | 30 | { |
40 | | - //load settings for a chosen store scope |
41 | | - var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); |
42 | | - var directDebitPaymentSettings = _settingService.LoadSetting<DirectDebitPaymentSettings>(storeScope); |
43 | | - |
44 | | - var model = new ConfigurationModel(); |
45 | | - model.DescriptionText = directDebitPaymentSettings.DescriptionText; |
46 | | - model.AdditionalFee = directDebitPaymentSettings.AdditionalFee; |
47 | | - model.AdditionalFeePercentage = directDebitPaymentSettings.AdditionalFeePercentage; |
48 | | - |
49 | | - var storeDependingSettings = new StoreDependingSettingHelper(ViewData); |
50 | | - storeDependingSettings.GetOverrideKeys(directDebitPaymentSettings, model, storeScope, _settingService); |
| 31 | + var model = new ConfigurationModel(); |
| 32 | + model.DescriptionText = _directDebitPaymentSettings.DescriptionText; |
| 33 | + model.AdditionalFee = _directDebitPaymentSettings.AdditionalFee; |
| 34 | + model.AdditionalFeePercentage = _directDebitPaymentSettings.AdditionalFeePercentage; |
51 | 35 |
|
52 | 36 | return View("SmartStore.Plugin.Payments.DirectDebit.Views.PaymentDirectDebit.Configure", model); |
53 | 37 | } |
54 | 38 |
|
55 | 39 | [HttpPost] |
56 | 40 | [AdminAuthorize] |
57 | 41 | [ChildActionOnly] |
| 42 | + [ValidateInput(false)] |
58 | 43 | public ActionResult Configure(ConfigurationModel model, FormCollection form) |
59 | 44 | { |
60 | 45 | if (!ModelState.IsValid) |
61 | 46 | return Configure(); |
62 | 47 |
|
63 | | - //load settings for a chosen store scope |
64 | | - var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); |
65 | | - var directDebitPaymentSettings = _settingService.LoadSetting<DirectDebitPaymentSettings>(storeScope); |
66 | | - |
67 | | - //save settings |
68 | | - directDebitPaymentSettings.DescriptionText = model.DescriptionText; |
69 | | - directDebitPaymentSettings.AdditionalFee = model.AdditionalFee; |
70 | | - directDebitPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; |
71 | | - |
72 | | - var storeDependingSettings = new StoreDependingSettingHelper(ViewData); |
73 | | - storeDependingSettings.UpdateSettings(directDebitPaymentSettings, form, storeScope, _settingService); |
74 | | - |
75 | | - //now clear settings cache |
76 | | - _settingService.ClearCache(); |
| 48 | + //save settings |
| 49 | + _directDebitPaymentSettings.DescriptionText = model.DescriptionText; |
| 50 | + _directDebitPaymentSettings.AdditionalFee = model.AdditionalFee; |
| 51 | + _directDebitPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; |
| 52 | + _settingService.SaveSetting(_directDebitPaymentSettings); |
77 | 53 |
|
78 | 54 | return View("SmartStore.Plugin.Payments.DirectDebit.Views.PaymentDirectDebit.Configure", model); |
79 | 55 | } |
80 | 56 |
|
81 | 57 | [ChildActionOnly] |
82 | 58 | public ActionResult PaymentInfo() |
83 | 59 | { |
84 | | - var directDebitPaymentSettings = _settingService.LoadSetting<DirectDebitPaymentSettings>(_storeContext.CurrentStore.Id); |
85 | | - |
86 | | - var model = new PaymentInfoModel(); |
87 | | - string desc = directDebitPaymentSettings.DescriptionText; |
| 60 | + var model = new PaymentInfoModel(); |
| 61 | + string desc = _directDebitPaymentSettings.DescriptionText; |
88 | 62 |
|
89 | 63 | if( desc.StartsWith("@") ) |
90 | 64 | { |
91 | 65 | model.DescriptionText = _localizationService.GetResource(desc.Substring(1)); |
92 | 66 | } |
93 | 67 | else { |
94 | | - model.DescriptionText = directDebitPaymentSettings.DescriptionText; |
| 68 | + model.DescriptionText = _directDebitPaymentSettings.DescriptionText; |
95 | 69 | } |
96 | 70 |
|
97 | 71 | return View("SmartStore.Plugin.Payments.DirectDebit.Views.PaymentDirectDebit.PaymentInfo", model); |
|
0 commit comments