change return prop in customer upsert

This commit is contained in:
dibakor 2026-06-16 17:51:28 +06:00
parent b71003f000
commit 99f820ff0f
4 changed files with 16 additions and 6 deletions

View File

@ -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

View File

@ -7,6 +7,6 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
public interface IIntegrationService
{
Task<bool> UpsertCustomerAsync(CustomerIntegrationRequest request);
Task<CustomerIntegrationResponse> UpsertCustomerAsync(CustomerIntegrationRequest request);
Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request);
}

View File

@ -50,9 +50,9 @@ public class IntegrationService : IIntegrationService
}
public async Task<bool> UpsertCustomerAsync(CustomerIntegrationRequest request)
public async Task<CustomerIntegrationResponse> 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();

View File

@ -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;