diff --git a/Api/OnlineSalesAutoCrop.CoreAPI.Models/Responses/Integrations/CustomerIntegrationResponse.cs b/Api/OnlineSalesAutoCrop.CoreAPI.Models/Responses/Integrations/CustomerIntegrationResponse.cs index a1ba8ec..082634b 100644 --- a/Api/OnlineSalesAutoCrop.CoreAPI.Models/Responses/Integrations/CustomerIntegrationResponse.cs +++ b/Api/OnlineSalesAutoCrop.CoreAPI.Models/Responses/Integrations/CustomerIntegrationResponse.cs @@ -2,7 +2,9 @@ public class CustomerIntegrationResponse : ResponseBase { - + public string CustomerNumber { get; set; } + public string CompanyCode { get; set; } + public bool IsUpdated { get; set; } } public class CustomerByCompanyCodeResponse : ResponseBase diff --git a/Api/OnlineSalesAutoCrop.CoreAPI.Services/Contracts/Integrations/IIntegrationService.cs b/Api/OnlineSalesAutoCrop.CoreAPI.Services/Contracts/Integrations/IIntegrationService.cs index eca423e..77c84b3 100644 --- a/Api/OnlineSalesAutoCrop.CoreAPI.Services/Contracts/Integrations/IIntegrationService.cs +++ b/Api/OnlineSalesAutoCrop.CoreAPI.Services/Contracts/Integrations/IIntegrationService.cs @@ -7,6 +7,6 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations; public interface IIntegrationService { - Task UpsertCustomerAsync(CustomerIntegrationRequest request); + Task UpsertCustomerAsync(CustomerIntegrationRequest request); Task GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request); } diff --git a/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/Integrations/IntegrationService.cs b/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/Integrations/IntegrationService.cs index 73c84d2..4aae162 100644 --- a/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/Integrations/IntegrationService.cs +++ b/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/Integrations/IntegrationService.cs @@ -50,9 +50,9 @@ public class IntegrationService : IIntegrationService } - public async Task UpsertCustomerAsync(CustomerIntegrationRequest request) + public async Task UpsertCustomerAsync(CustomerIntegrationRequest request) { - bool response = false; + CustomerIntegrationResponse response = new(); try { using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode); @@ -63,10 +63,18 @@ public class IntegrationService : IIntegrationService if( customer != null && customer.CustomerId>0) { //Update Here + + response.CustomerNumber = request.CustomerNumber; + response.CompanyCode = request.CompanyCode; + response.IsUpdated = true; } else { //Insert Here + + response.CustomerNumber = request.CustomerNumber; + response.CompanyCode = request.CompanyCode; + response.IsUpdated = false; } tc.End(); diff --git a/Api/OnlineSalesAutoCrop.CoreAPI/Controllers/IntegretionApi/IntegrationController.cs b/Api/OnlineSalesAutoCrop.CoreAPI/Controllers/IntegretionApi/IntegrationController.cs index c1a7b9c..8c98e5e 100644 --- a/Api/OnlineSalesAutoCrop.CoreAPI/Controllers/IntegretionApi/IntegrationController.cs +++ b/Api/OnlineSalesAutoCrop.CoreAPI/Controllers/IntegretionApi/IntegrationController.cs @@ -47,8 +47,8 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi CustomerIntegrationResponse response = new CustomerIntegrationResponse(); try { - bool result = await _integrationService.UpsertCustomerAsync(request); - if (result) + response = await _integrationService.UpsertCustomerAsync(request); + if (!response.IsUpdated) { response.ReturnMessage.Add($"Customer Created Successfully for CustomerNumber :{request.CustomerNumber} & CompanyCode:{request.CompanyCode}"); response.ReturnStatus = StatusCodes.Status201Created;