change return prop in customer upsert
This commit is contained in:
parent
b71003f000
commit
99f820ff0f
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
public class CustomerIntegrationResponse : ResponseBase
|
public class CustomerIntegrationResponse : ResponseBase
|
||||||
{
|
{
|
||||||
|
public string CustomerNumber { get; set; }
|
||||||
|
public string CompanyCode { get; set; }
|
||||||
|
public bool IsUpdated { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CustomerByCompanyCodeResponse : ResponseBase
|
public class CustomerByCompanyCodeResponse : ResponseBase
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
|
||||||
|
|
||||||
public interface IIntegrationService
|
public interface IIntegrationService
|
||||||
{
|
{
|
||||||
Task<bool> UpsertCustomerAsync(CustomerIntegrationRequest request);
|
Task<CustomerIntegrationResponse> UpsertCustomerAsync(CustomerIntegrationRequest request);
|
||||||
Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request);
|
Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
try
|
||||||
{
|
{
|
||||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
||||||
|
|
@ -63,10 +63,18 @@ public class IntegrationService : IIntegrationService
|
||||||
if( customer != null && customer.CustomerId>0)
|
if( customer != null && customer.CustomerId>0)
|
||||||
{
|
{
|
||||||
//Update Here
|
//Update Here
|
||||||
|
|
||||||
|
response.CustomerNumber = request.CustomerNumber;
|
||||||
|
response.CompanyCode = request.CompanyCode;
|
||||||
|
response.IsUpdated = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Insert Here
|
//Insert Here
|
||||||
|
|
||||||
|
response.CustomerNumber = request.CustomerNumber;
|
||||||
|
response.CompanyCode = request.CompanyCode;
|
||||||
|
response.IsUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
tc.End();
|
tc.End();
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
|
||||||
CustomerIntegrationResponse response = new CustomerIntegrationResponse();
|
CustomerIntegrationResponse response = new CustomerIntegrationResponse();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool result = await _integrationService.UpsertCustomerAsync(request);
|
response = await _integrationService.UpsertCustomerAsync(request);
|
||||||
if (result)
|
if (!response.IsUpdated)
|
||||||
{
|
{
|
||||||
response.ReturnMessage.Add($"Customer Created Successfully for CustomerNumber :{request.CustomerNumber} & CompanyCode:{request.CompanyCode}");
|
response.ReturnMessage.Add($"Customer Created Successfully for CustomerNumber :{request.CustomerNumber} & CompanyCode:{request.CompanyCode}");
|
||||||
response.ReturnStatus = StatusCodes.Status201Created;
|
response.ReturnStatus = StatusCodes.Status201Created;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user