Compare commits

...

2 Commits

Author SHA1 Message Date
cc740be2d5 update api 2026-06-17 16:02:24 +06:00
3f6204975b complete employee api 2026-06-17 13:51:19 +06:00
6 changed files with 19 additions and 31 deletions

View File

@ -34,5 +34,8 @@ public class EmployeeIntegrationResponse : ResponseBase
public class EmployeeIntegrationReqResponse : ResponseBase
{
public string EmployeeVendorCode { get; set; }
public string SalesOrgCode { get; set; }
public bool IsUpdated { get; set; }
}

View File

@ -9,6 +9,6 @@ public interface IIntegrationService
{
Task<CustomerIntegrationResponse> UpsertCustomerAsync(CustomerIntegrationRequest request);
Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request);
Task<bool> UpsertEmployeeAsync(EmployeeIntegrationRequest request);
Task<EmployeeIntegrationReqResponse> UpsertEmployeeAsync(EmployeeIntegrationRequest request);
Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(EmployeeBySalesOrgCodeRequest request);
}

View File

@ -1,5 +1,4 @@
using DocumentFormat.OpenXml.Wordprocessing;
using Ease.NetCore.DataAccess;
using Ease.NetCore.DataAccess;
using Ease.NetCore.DataAccess.SQL;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Options;
@ -9,8 +8,6 @@ using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
using System;
using System.Data;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace OnlineSalesAutoCrop.CoreAPI.Services.Services.Integrations;
@ -65,22 +62,18 @@ public class IntegrationService : IIntegrationService
{
//Update Here
UpdateCustomer(tc, customer.CustomerId, request);
response.CustomerNumber = request.CustomerNumber;
response.CompanyCode = request.CompanyCode;
response.IsUpdated = true;
}
else
{
//Insert Here
CreateCustomer(tc, request);
response.CustomerNumber = request.CustomerNumber;
response.CompanyCode = request.CompanyCode;
response.IsUpdated = false;
}
response.CustomerNumber = request.CustomerNumber;
response.CompanyCode = request.CompanyCode;
tc.End();
}
catch (Exception ie)
@ -190,9 +183,9 @@ public class IntegrationService : IIntegrationService
return response;
}
public async Task<bool> UpsertEmployeeAsync(EmployeeIntegrationRequest request)
public async Task<EmployeeIntegrationReqResponse> UpsertEmployeeAsync(EmployeeIntegrationRequest request)
{
bool response = false;
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
@ -232,12 +225,16 @@ public class IntegrationService : IIntegrationService
if (employee != null && employee.EmployeeVendorId > 0)
{
_= tc.ExecuteNonQuerySp("dbo.UpdateEmployee", p);
response.IsUpdated = true;
}
else
{
_= tc.ExecuteNonQuerySp("dbo.InsertEmployee", p);
response.IsUpdated = true;
}
response.EmployeeVendorCode = request.EmployeeVendorCode;
response.SalesOrgCode = request.SalesOrgCode;
tc.End();
}
catch (Exception ie)
@ -263,8 +260,7 @@ public class IntegrationService : IIntegrationService
SqlParameter[] p =
[
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))
@ -299,7 +295,6 @@ public class IntegrationService : IIntegrationService
PlantDescription = dr.GetString(23),
Status = dr.GetString(24),
StatusDescription = dr.GetString(25)
};
}
dr.Close();
@ -457,6 +452,4 @@ public class IntegrationService : IIntegrationService
return returnValue;
}
}

View File

@ -3,8 +3,6 @@ using Ease.NetCore.DataAccess.SQL;
using Ease.NetCore.Utility;
using OnlineSalesAutoCrop.CoreAPI.Models;
using OnlineSalesAutoCrop.CoreAPI.Models.Global;
using OnlineSalesAutoCrop.CoreAPI.Models.Objects;
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Setups;
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Systems;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Systems;

View File

@ -2,7 +2,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
@ -20,7 +19,6 @@ using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Systems;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Auth;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Systems;
using OnlineSalesAutoCrop.CoreAPI.SignalRHub;
using System;
using System.Collections.Generic;
using System.DirectoryServices;

View File

@ -4,10 +4,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Services.Services.Integrations;
using System;
using System.Threading.Tasks;
@ -87,8 +85,8 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
try
{
bool result = await _integrationService.UpsertEmployeeAsync(request);
if (result)
response = await _integrationService.UpsertEmployeeAsync(request);
if (!response.IsUpdated)
{
response.ReturnMessage.Add($"Employee Created Successfully for EmployeeVendorName :{request.EmployeeVendorName} & SalesOrgCode:{request.SalesOrgCode}");
response.ReturnStatus = StatusCodes.Status201Created;
@ -110,7 +108,5 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
return StatusCode(StatusCodes.Status500InternalServerError, response);
}
}
}
}