diff --git a/Back/Back.csproj b/Back/Back.csproj
index a6bcdd4..899d7e4 100644
--- a/Back/Back.csproj
+++ b/Back/Back.csproj
@@ -23,6 +23,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/Back/Controllers/TaxPayerController.cs b/Back/Controllers/TaxPayerController.cs
index 87a6145..ce8088b 100644
--- a/Back/Controllers/TaxPayerController.cs
+++ b/Back/Controllers/TaxPayerController.cs
@@ -67,5 +67,23 @@ namespace Back.Controllers
return Ok(await _servTaxPayer.PreparationInvoiceBeforeSending(item, result));
}
+ [HttpPost("CheckAuth")]
+ public async Task> CheckAuth([FromBody] CheckAuthDTO item)
+ {
+
+ if (item == null)
+ return BadRequest("مدل صحیح نمی باشد");
+
+ using (ActionTaxPayer action = new ActionTaxPayer(item.UniqueMemory, item.PrivateKey))
+ {
+ if (action.login())
+ return Ok();
+ }
+
+
+
+ return BadRequest();
+
+ }
}
}
diff --git a/Back/Services/ActionTaxPayer.cs b/Back/Services/ActionTaxPayer.cs
new file mode 100644
index 0000000..60772ea
--- /dev/null
+++ b/Back/Services/ActionTaxPayer.cs
@@ -0,0 +1,85 @@
+using Back.Common;
+using TaxCollectData.Library.Business;
+using TaxCollectData.Library.Dto.Config;
+using TaxCollectData.Library.Dto.Content;
+using TaxCollectData.Library.Dto.Properties;
+using TaxCollectData.Library.Dto.Transfer;
+using TaxCollectData.Library.Enums;
+
+namespace Back.Services
+{
+ public class ActionTaxPayer : IDisposable
+ {
+ private string _UniqueMemory;
+ public ActionTaxPayer(string UniqueMemory, string PrivateKey)
+ {
+ #region TokenTax
+ if (!string.IsNullOrEmpty(UniqueMemory) && !string.IsNullOrEmpty(PrivateKey))
+ {
+ _UniqueMemory = UniqueMemory;
+
+ TaxApiService.Instance.Init(UniqueMemory,
+ new SignatoryConfig(PrivateKey, null),
+ new NormalProperties(ClientType.SELF_TSP), "https://tp.tax.gov.ir/req/api/");
+ TaxApiService.Instance.TaxApis.GetServerInformation();
+ }
+ #endregion
+ }
+ public string GenerateTaxid(string FactorNo, string InvoiceDate)
+ {
+ return TaxApiService.Instance.TaxIdGenerator.GenerateTaxId(_UniqueMemory,
+ Convert.ToInt64(FactorNo), InvoiceDate.ToMiladi());
+ }
+
+ public InquiryResultModel GetResultByUid(string uid)
+ {
+ if (!login())
+ return null;
+ var uidAndFiscalId = new UidAndFiscalId(uid, _UniqueMemory);
+ var inquiryResultModels = TaxApiService.Instance.TaxApis.InquiryByUidAndFiscalId(new() { uidAndFiscalId });
+ if (inquiryResultModels.Count > 0)
+ return inquiryResultModels[0];
+ return null;
+ }
+ public TaxCollectData.Library.Dto.HttpResponse SendInvoice(InvoiceHeaderDto header, List InvoiceBody, PaymentDto payment)
+ {
+ if (!login())
+ return null;
+ return TaxApiService.Instance.TaxApis.SendInvoices(new List()
+ {
+ new InvoiceDto()
+ {
+ Header =header,Body =InvoiceBody,Payments = new() {payment}
+ }
+ }
+ , null);
+ }
+ public EconomicCodeModel? GetEconomicCodeInformation(string Item)
+ {
+ return TaxApiService.Instance.TaxApis.GetEconomicCodeInformation(Item);
+ }
+ //-------------------internal
+ public bool login()
+ {
+ try
+ {
+ if (TaxApiService.Instance.TaxApis.GetToken() is null)
+ {
+ if(TaxApiService.Instance.TaxApis.RequestToken()==null)
+ return false;
+ }
+ return true;
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+
+ }
+
+ public void Dispose()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Back/Services/servTaxPayer.cs b/Back/Services/servTaxPayer.cs
index e37da63..04f5941 100644
--- a/Back/Services/servTaxPayer.cs
+++ b/Back/Services/servTaxPayer.cs
@@ -251,5 +251,7 @@ namespace Back.Services
// }
}
+
+
}
}
diff --git a/Shared/DTOs/CheckAuthDTO.cs b/Shared/DTOs/CheckAuthDTO.cs
new file mode 100644
index 0000000..0b2eb6f
--- /dev/null
+++ b/Shared/DTOs/CheckAuthDTO.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Shared.DTOs
+{
+ public class CheckAuthDTO
+ {
+ public string UniqueMemory { get; set; }
+ public string PrivateKey { get; set; }
+ }
+}