From ce96fca3c8f932b18a4169d762702d3cb840f541 Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 25 Feb 2021 13:36:34 +0300 Subject: [PATCH] abstract managers --- .../Managers/Insurance/InsuranceManager.cs | 18 ++++++++++++++++++ ELT.Client/Managers/Insurance/KaskoManager.cs | 6 +++--- ELT.Client/Managers/Insurance/OsagoManager.cs | 7 ++----- ELT/Controllers/InsuranceController.cs | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 ELT.Client/Managers/Insurance/InsuranceManager.cs diff --git a/ELT.Client/Managers/Insurance/InsuranceManager.cs b/ELT.Client/Managers/Insurance/InsuranceManager.cs new file mode 100644 index 0000000..9f3c628 --- /dev/null +++ b/ELT.Client/Managers/Insurance/InsuranceManager.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using ELT.Client.Models.Insurance; + +namespace ELT.Client.Managers.Insurance +{ + public abstract class InsuranceManager + { + protected AuthInfo AuthInfo => + new AuthInfo + { + Login = Environment.GetEnvironmentVariable("eltLogin"), + Password = Environment.GetEnvironmentVariable("eltPassword") + }; + + public abstract Dictionary Calculate(T1 calculateRequest, ELTPreData preRequestData); + } +} \ No newline at end of file diff --git a/ELT.Client/Managers/Insurance/KaskoManager.cs b/ELT.Client/Managers/Insurance/KaskoManager.cs index 24d3997..b779c26 100644 --- a/ELT.Client/Managers/Insurance/KaskoManager.cs +++ b/ELT.Client/Managers/Insurance/KaskoManager.cs @@ -6,16 +6,16 @@ using ELTKasko; namespace ELT.Client.Managers.Insurance { - public class KaskoManager : BaseManager + public class KaskoManager : InsuranceManager { private readonly EltSoap _eltKaskoSoap; - public KaskoManager() { _eltKaskoSoap = new EltSoapClient(); } - public Dictionary CalculateKasko(CalculateKaskoRequest calculateKaskoRequest, + public override Dictionary Calculate( + CalculateKaskoRequest calculateKaskoRequest, ELTPreData preRequestData) { var kaskoParams = calculateKaskoRequest.ELTParams; diff --git a/ELT.Client/Managers/Insurance/OsagoManager.cs b/ELT.Client/Managers/Insurance/OsagoManager.cs index 69958ac..f8e8d7c 100644 --- a/ELT.Client/Managers/Insurance/OsagoManager.cs +++ b/ELT.Client/Managers/Insurance/OsagoManager.cs @@ -6,16 +6,15 @@ using ELTOsago; namespace ELT.Client.Managers.Insurance { - public class OsagoManager : BaseManager + public class OsagoManager : InsuranceManager { private readonly EltSoap _eltOsagoSoap; - public OsagoManager() { _eltOsagoSoap = new EltSoapClient(); } - public Dictionary CalculateOsago( + public override Dictionary Calculate( CalculateOsagoRequest calculateOsagoRequest, ELTPreData preRequestData) { var result = new Dictionary(); @@ -31,7 +30,6 @@ namespace ELT.Client.Managers.Insurance }; foreach (var companyId in calculateOsagoRequest.CompanyIds) - { try { var res = _eltOsagoSoap.OSAGOFullCalculation(osagoParams); @@ -42,7 +40,6 @@ namespace ELT.Client.Managers.Insurance { // ignored } - } return result; } diff --git a/ELT/Controllers/InsuranceController.cs b/ELT/Controllers/InsuranceController.cs index 54971f7..965016f 100644 --- a/ELT/Controllers/InsuranceController.cs +++ b/ELT/Controllers/InsuranceController.cs @@ -19,7 +19,7 @@ namespace ELT.Controllers var preRequestData = preRequestManager.GetPreRequestData(calculateKaskoRequest.Preparams); var kaskoManager = new KaskoManager(); - return kaskoManager.CalculateKasko(calculateKaskoRequest, preRequestData); + return kaskoManager.Calculate(calculateKaskoRequest, preRequestData); } [HttpPost("[action]")] @@ -30,7 +30,7 @@ namespace ELT.Controllers var preRequestData = preRequestManager.GetPreRequestData(calculateOsagoRequest.Preparams); var osagoManager = new OsagoManager(); - return osagoManager.CalculateOsago(calculateOsagoRequest, preRequestData); + return osagoManager.Calculate(calculateOsagoRequest, preRequestData); } } } \ No newline at end of file