complete employee api
This commit is contained in:
parent
0e5a7b30ef
commit
3f6204975b
|
|
@ -34,5 +34,8 @@ public class EmployeeIntegrationResponse : ResponseBase
|
||||||
|
|
||||||
public class EmployeeIntegrationReqResponse : ResponseBase
|
public class EmployeeIntegrationReqResponse : ResponseBase
|
||||||
{
|
{
|
||||||
|
public string EmployeeVendorCode { get; set; }
|
||||||
|
public string SalesOrgCode { get; set; }
|
||||||
|
public bool IsUpdated { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -9,6 +9,6 @@ public interface IIntegrationService
|
||||||
{
|
{
|
||||||
Task<CustomerIntegrationResponse> UpsertCustomerAsync(CustomerIntegrationRequest request);
|
Task<CustomerIntegrationResponse> UpsertCustomerAsync(CustomerIntegrationRequest request);
|
||||||
Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request);
|
Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request);
|
||||||
Task<bool> UpsertEmployeeAsync(EmployeeIntegrationRequest request);
|
Task<EmployeeIntegrationReqResponse> UpsertEmployeeAsync(EmployeeIntegrationRequest request);
|
||||||
Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(EmployeeBySalesOrgCodeRequest request);
|
Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(EmployeeBySalesOrgCodeRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,22 +65,18 @@ public class IntegrationService : IIntegrationService
|
||||||
{
|
{
|
||||||
//Update Here
|
//Update Here
|
||||||
UpdateCustomer(tc, customer.CustomerId, request);
|
UpdateCustomer(tc, customer.CustomerId, request);
|
||||||
response.CustomerNumber = request.CustomerNumber;
|
|
||||||
response.CompanyCode = request.CompanyCode;
|
|
||||||
response.IsUpdated = true;
|
response.IsUpdated = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Insert Here
|
//Insert Here
|
||||||
|
|
||||||
CreateCustomer(tc, request);
|
CreateCustomer(tc, request);
|
||||||
response.CustomerNumber = request.CustomerNumber;
|
|
||||||
response.CompanyCode = request.CompanyCode;
|
|
||||||
response.IsUpdated = false;
|
response.IsUpdated = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.CustomerNumber = request.CustomerNumber;
|
||||||
|
response.CompanyCode = request.CompanyCode;
|
||||||
tc.End();
|
tc.End();
|
||||||
}
|
}
|
||||||
catch (Exception ie)
|
catch (Exception ie)
|
||||||
|
|
@ -190,9 +186,9 @@ public class IntegrationService : IIntegrationService
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> UpsertEmployeeAsync(EmployeeIntegrationRequest request)
|
public async Task<EmployeeIntegrationReqResponse> UpsertEmployeeAsync(EmployeeIntegrationRequest request)
|
||||||
{
|
{
|
||||||
bool response = false;
|
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
||||||
|
|
@ -231,13 +227,17 @@ public class IntegrationService : IIntegrationService
|
||||||
|
|
||||||
if (employee != null && employee.EmployeeVendorId > 0)
|
if (employee != null && employee.EmployeeVendorId > 0)
|
||||||
{
|
{
|
||||||
_= tc.ExecuteNonQuerySp("dbo.UpdateEmployee", p);
|
_= tc.ExecuteNonQuerySp("dbo.UpdateEmployee", p);
|
||||||
|
response.IsUpdated = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_= tc.ExecuteNonQuerySp("dbo.InsertEmployee", p);
|
_= tc.ExecuteNonQuerySp("dbo.InsertEmployee", p);
|
||||||
|
response.IsUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.EmployeeVendorCode = request.EmployeeVendorCode;
|
||||||
|
response.SalesOrgCode = request.SalesOrgCode;
|
||||||
tc.End();
|
tc.End();
|
||||||
}
|
}
|
||||||
catch (Exception ie)
|
catch (Exception ie)
|
||||||
|
|
@ -263,8 +263,7 @@ public class IntegrationService : IIntegrationService
|
||||||
SqlParameter[] p =
|
SqlParameter[] p =
|
||||||
[
|
[
|
||||||
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorCode", pType: SqlDbType.NVarChar,pValue: request.EmployeeVendorCode ),
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorCode", pType: SqlDbType.NVarChar,pValue: request.EmployeeVendorCode ),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@SalesOrgCode", pType: SqlDbType.NVarChar,pValue: request.SalesOrgCode ),
|
SqlHelperExtension.CreateInParam(pName: "@SalesOrgCode", pType: SqlDbType.NVarChar,pValue: request.SalesOrgCode )
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetEmployeeBySalesOrgCode", parameterValues: p))
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetEmployeeBySalesOrgCode", parameterValues: p))
|
||||||
|
|
@ -298,8 +297,7 @@ public class IntegrationService : IIntegrationService
|
||||||
PlantCode = dr.GetString(22),
|
PlantCode = dr.GetString(22),
|
||||||
PlantDescription = dr.GetString(23),
|
PlantDescription = dr.GetString(23),
|
||||||
Status = dr.GetString(24),
|
Status = dr.GetString(24),
|
||||||
StatusDescription = dr.GetString(25)
|
StatusDescription = dr.GetString(25)
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
dr.Close();
|
dr.Close();
|
||||||
|
|
@ -457,6 +455,4 @@ public class IntegrationService : IIntegrationService
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,8 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
|
||||||
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
|
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool result = await _integrationService.UpsertEmployeeAsync(request);
|
response = await _integrationService.UpsertEmployeeAsync(request);
|
||||||
if (result)
|
if (!response.IsUpdated)
|
||||||
{
|
{
|
||||||
response.ReturnMessage.Add($"Employee Created Successfully for EmployeeVendorName :{request.EmployeeVendorName} & SalesOrgCode:{request.SalesOrgCode}");
|
response.ReturnMessage.Add($"Employee Created Successfully for EmployeeVendorName :{request.EmployeeVendorName} & SalesOrgCode:{request.SalesOrgCode}");
|
||||||
response.ReturnStatus = StatusCodes.Status201Created;
|
response.ReturnStatus = StatusCodes.Status201Created;
|
||||||
|
|
@ -110,7 +110,5 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, response);
|
return StatusCode(StatusCodes.Status500InternalServerError, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user