Add Integration Material Price Api
This commit is contained in:
parent
4068d2d8a3
commit
7ae8591ce6
|
|
@ -700,4 +700,22 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models
|
||||||
[Description("From Others")]
|
[Description("From Others")]
|
||||||
FromOthers = 3,
|
FromOthers = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum IntegrationMaterialCalCulationType : short
|
||||||
|
{
|
||||||
|
[Description("Percentage")]
|
||||||
|
A = 1,
|
||||||
|
[Description("Fixed value ")]
|
||||||
|
B = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum IntegrationMaterialPriceType: short
|
||||||
|
{
|
||||||
|
[Description("Base Price")]
|
||||||
|
PR00 = 1 ,
|
||||||
|
[Description("Amount Based Discount")]
|
||||||
|
ZDS1 = 2 ,
|
||||||
|
[Description("Percentage Based Discount")]
|
||||||
|
ZDS2 = 3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
|
||||||
|
|
||||||
public class CustomerIntegration
|
public class IntegrationCustomer
|
||||||
{
|
{
|
||||||
public string CustomerNumber { get; set; }
|
public string CustomerNumber { get; set; }
|
||||||
public string CustomerName { get; set; }
|
public string CustomerName { get; set; }
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
|
||||||
|
|
||||||
public class EmployeeIntegration
|
public class IntegrationEmployee
|
||||||
{
|
{
|
||||||
public string EmployeeVendorCode { get; set; }
|
public string EmployeeVendorCode { get; set; }
|
||||||
public string EmployeeVendorName { get; set; }
|
public string EmployeeVendorName { get; set; }
|
||||||
|
|
@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
|
||||||
|
|
||||||
public class MaterialIntegration
|
public class IntegrationMaterial
|
||||||
{
|
{
|
||||||
public int MeterialId { get; set; }
|
public int MeterialId { get; set; }
|
||||||
public string MaterialType { get; set; }
|
public string MaterialType { get; set; }
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
|
||||||
|
|
||||||
|
public class IntegrationMaterialPrice
|
||||||
|
{
|
||||||
|
public int MaterialPriceId { get; set; }
|
||||||
|
public string SalesOrg { get; set; }
|
||||||
|
public string DistributionChannel { get; set; }
|
||||||
|
public string CustomerNumber { get; set; }
|
||||||
|
public string CustomerGroupCode { get; set; }
|
||||||
|
public string MaterialCode { get; set; }
|
||||||
|
public string ConditionType { get; set; }
|
||||||
|
public string CalculationType { get; set; }
|
||||||
|
public string PricingUnit { get; set; }
|
||||||
|
public string UnitOfMeasure { get; set; }
|
||||||
|
public DateTime ValidFrom { get; set; }
|
||||||
|
public DateTime ValidTo { get; set; }
|
||||||
|
public string Status { get; set; }
|
||||||
|
public decimal ConditionValue { get; set; }
|
||||||
|
public DateTime CreatedDate { get; set; }
|
||||||
|
public DateTime ModifiedDate { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ using System.Text;
|
||||||
|
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
||||||
|
|
||||||
public class CustomerIntegrationRequest
|
public class IntegrationCustomerRequest
|
||||||
{
|
{
|
||||||
[Required(ErrorMessage = "Customer number is required.")]
|
[Required(ErrorMessage = "Customer number is required.")]
|
||||||
[StringLength(10, ErrorMessage = "Customer number cannot exceed 10 characters.")]
|
[StringLength(10, ErrorMessage = "Customer number cannot exceed 10 characters.")]
|
||||||
|
|
@ -16,7 +16,7 @@ public class CustomerIntegrationRequest
|
||||||
public string CustomerName { get; set; }
|
public string CustomerName { get; set; }
|
||||||
|
|
||||||
[Required(ErrorMessage = "Account group is required.")]
|
[Required(ErrorMessage = "Account group is required.")]
|
||||||
[StringLength(4, ErrorMessage = "Account group cannot exceed 3 characters.")]
|
[StringLength(4, ErrorMessage = "Account group cannot exceed 4 characters.")]
|
||||||
public string AccountGroup { get; set; }
|
public string AccountGroup { get; set; }
|
||||||
|
|
||||||
[Required(ErrorMessage = "Account group description is required.")]
|
[Required(ErrorMessage = "Account group description is required.")]
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
||||||
|
|
||||||
public class EmployeeIntegrationRequest
|
public class IntegrationEmployeeRequest
|
||||||
{
|
{
|
||||||
[Required(ErrorMessage = "Employee vendor code is required.")]
|
[Required(ErrorMessage = "Employee vendor code is required.")]
|
||||||
[StringLength(10, ErrorMessage = "Employee vendor code cannot exceed 10 characters.")]
|
[StringLength(10, ErrorMessage = "Employee vendor code cannot exceed 10 characters.")]
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
||||||
|
|
||||||
|
public class IntegrationMaterialPriceRequest
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "Sales Org is required.")]
|
||||||
|
[StringLength(4, ErrorMessage = "Sales Org cannot exceed 4 characters.")]
|
||||||
|
public string SalesOrg { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Distribution Channel is required.")]
|
||||||
|
[StringLength(2, ErrorMessage = "Distribution Channel cannot exceed 2 characters.")]
|
||||||
|
public string DistributionChannel { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Customer Number is required.")]
|
||||||
|
[StringLength(13, ErrorMessage = "Customer Number cannot exceed 13 characters.")]
|
||||||
|
public string CustomerNumber { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Customer Group Code is required.")]
|
||||||
|
[StringLength(10, ErrorMessage = "Customer Group Code cannot exceed 10 characters.")]
|
||||||
|
public string CustomerGroupCode { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Material Code is required.")]
|
||||||
|
[StringLength(10, ErrorMessage = "Material Code cannot exceed 10 characters.")]
|
||||||
|
public string MaterialCode { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Condition Type is required.")]
|
||||||
|
[StringLength(4, ErrorMessage = "Condition Type cannot exceed 4 characters.")]
|
||||||
|
public string ConditionType { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Calculation Type is required.")]
|
||||||
|
[StringLength(1, ErrorMessage = "Calculation Type cannot exceed 1 character.")]
|
||||||
|
public string CalculationType { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Pricing Unit is required.")]
|
||||||
|
[StringLength(1, ErrorMessage = "Pricing Unit cannot exceed 1 character.")]
|
||||||
|
public string PricingUnit { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Unit Of Measure is required.")]
|
||||||
|
[StringLength(3, ErrorMessage = "Unit Of Measure cannot exceed 3 characters.")]
|
||||||
|
public string UnitOfMeasure { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Valid From date is required.")]
|
||||||
|
public DateTime ValidFrom { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Valid To date is required.")]
|
||||||
|
public DateTime ValidTo { get; set; }
|
||||||
|
|
||||||
|
[StringLength(1, ErrorMessage = "Status cannot exceed 1 character.")]
|
||||||
|
[RegularExpression(@"^$|^X$", ErrorMessage = "Status must be blank (Active) or 'X' (Inactive).")]
|
||||||
|
public string Status { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Condition Value is required.")]
|
||||||
|
[Range(typeof(decimal), "0", "999999999999999999.99",
|
||||||
|
ErrorMessage = "Condition Value must be greater than or equal to 0.")]
|
||||||
|
public decimal ConditionValue { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetMaterialPriceByCodeRequest
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "Material Code is required.")]
|
||||||
|
[StringLength(10, ErrorMessage = "Material Code cannot exceed 10 characters.")]
|
||||||
|
public string MaterialCode { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "Condition Type is required.")]
|
||||||
|
[StringLength(4, ErrorMessage = "Condition Type cannot exceed 4 characters.")]
|
||||||
|
public string ConditionType { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
||||||
|
|
||||||
public class MaterialIntegrationRequest
|
public class IntegrationMaterialRequest
|
||||||
{
|
{
|
||||||
[Required(ErrorMessage = "Material type is required.")]
|
[Required(ErrorMessage = "Material type is required.")]
|
||||||
[StringLength(4, ErrorMessage = "Material type cannot exceed 4 characters.")]
|
[StringLength(4, ErrorMessage = "Material type cannot exceed 4 characters.")]
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
||||||
|
|
||||||
public class CustomerIntegrationResponse : ResponseBase
|
public class IntegrationCustomerResponse : ResponseBase
|
||||||
{
|
{
|
||||||
public string CustomerNumber { get; set; }
|
public string CustomerNumber { get; set; }
|
||||||
public string CompanyCode { get; set; }
|
public string CompanyCode { get; set; }
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
||||||
|
|
||||||
public class EmployeeIntegrationResponse : ResponseBase
|
public class IntegrationEmployeeResponse : ResponseBase
|
||||||
{
|
{
|
||||||
public int EmployeeId { get; set; }
|
public int EmployeeId { get; set; }
|
||||||
public string EmployeeVendorCode { get; set; }
|
public string EmployeeVendorCode { get; set; }
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
||||||
|
|
||||||
|
public class IntegrationMaterialPriceResponse : ResponseBase
|
||||||
|
{
|
||||||
|
public int MaterialPriceId { get; set; }
|
||||||
|
public string SalesOrg { get; set; }
|
||||||
|
public string DistributionChannel { get; set; }
|
||||||
|
public string CustomerNumber { get; set; }
|
||||||
|
public string CustomerGroupCode { get; set; }
|
||||||
|
public string MaterialCode { get; set; }
|
||||||
|
public string ConditionType { get; set; }
|
||||||
|
public string CalculationType { get; set; }
|
||||||
|
public string PricingUnit { get; set; }
|
||||||
|
public string UnitOfMeasure { get; set; }
|
||||||
|
public DateTime ValidFrom { get; set; }
|
||||||
|
public DateTime ValidTo { get; set; }
|
||||||
|
public string Status { get; set; }
|
||||||
|
public decimal ConditionValue { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MaterialIntegrationPriceReqResponse : ResponseBase
|
||||||
|
{
|
||||||
|
public string MaterialCode { get; set; }
|
||||||
|
public string ConditionType { get; set; }
|
||||||
|
public bool IsUpdated { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
||||||
|
|
||||||
public class MaterialIntegrationResponse : ResponseBase
|
public class IntegrationMaterialResponse : ResponseBase
|
||||||
{
|
{
|
||||||
public int MeterialId { get; set; }
|
public int MeterialId { get; set; }
|
||||||
public string MaterialType { get; set; }
|
public string MaterialType { get; set; }
|
||||||
|
|
@ -8,14 +8,19 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
|
||||||
public interface IIntegrationService
|
public interface IIntegrationService
|
||||||
{
|
{
|
||||||
//Customer
|
//Customer
|
||||||
Task<CustomerIntegrationResponse> UpsertCustomerAsync(CustomerIntegrationRequest request);
|
Task<IntegrationCustomerResponse> UpsertCustomerAsync(IntegrationCustomerRequest request);
|
||||||
Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request);
|
Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request);
|
||||||
|
|
||||||
//Employee
|
//Employee
|
||||||
Task<EmployeeIntegrationReqResponse> UpsertEmployeeAsync(EmployeeIntegrationRequest request);
|
Task<EmployeeIntegrationReqResponse> UpsertEmployeeAsync(IntegrationEmployeeRequest request);
|
||||||
Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(EmployeeIntegrationByComapanyRequest request);
|
Task<IntegrationEmployeeResponse> GetEmployeeBySalesOrgAsync(EmployeeIntegrationByComapanyRequest request);
|
||||||
|
|
||||||
//Meterial
|
//Material
|
||||||
Task<MaterialIntegrationReqResponse > UpsertMaterialAsync(MaterialIntegrationRequest request);
|
Task<MaterialIntegrationReqResponse > UpsertMaterialAsync(IntegrationMaterialRequest request);
|
||||||
Task<MaterialIntegrationResponse> GetMaterialByCodeAsync(GetMaterialByCodeRequest request);
|
Task<IntegrationMaterialResponse> GetMaterialByCodeAsync(GetMaterialByCodeRequest request);
|
||||||
|
|
||||||
|
|
||||||
|
//Material Price
|
||||||
|
Task<MaterialIntegrationPriceReqResponse> UpsertMaterialPriceAsync(IntegrationMaterialPriceRequest request);
|
||||||
|
Task<IntegrationMaterialPriceResponse> GetMaterialPriceByCodeAsync( GetMaterialPriceByCodeRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
||||||
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
||||||
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
|
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
@ -48,9 +49,9 @@ public class IntegrationService : IIntegrationService
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<CustomerIntegrationResponse> UpsertCustomerAsync(CustomerIntegrationRequest request)
|
public async Task<IntegrationCustomerResponse> UpsertCustomerAsync(IntegrationCustomerRequest request)
|
||||||
{
|
{
|
||||||
CustomerIntegrationResponse response = new();
|
IntegrationCustomerResponse response = new();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode,true);
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode,true);
|
||||||
|
|
@ -92,9 +93,9 @@ public class IntegrationService : IIntegrationService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(EmployeeIntegrationByComapanyRequest request)
|
public async Task<IntegrationEmployeeResponse> GetEmployeeBySalesOrgAsync(EmployeeIntegrationByComapanyRequest request)
|
||||||
{
|
{
|
||||||
EmployeeIntegrationResponse response = new();
|
IntegrationEmployeeResponse response = new();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
||||||
|
|
@ -118,7 +119,7 @@ public class IntegrationService : IIntegrationService
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<EmployeeIntegrationReqResponse> UpsertEmployeeAsync(EmployeeIntegrationRequest request)
|
public async Task<EmployeeIntegrationReqResponse> UpsertEmployeeAsync(IntegrationEmployeeRequest request)
|
||||||
{
|
{
|
||||||
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
|
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
|
||||||
try
|
try
|
||||||
|
|
@ -126,7 +127,7 @@ public class IntegrationService : IIntegrationService
|
||||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
EmployeeIntegrationResponse employee = await GetEmployeeBySalesOrgAsync(tc,
|
IntegrationEmployeeResponse employee = await GetEmployeeBySalesOrgAsync(tc,
|
||||||
new EmployeeIntegrationByComapanyRequest() { EmployeeVendorCode = request.EmployeeVendorCode, CompanyCode = request.CompanyCode });
|
new EmployeeIntegrationByComapanyRequest() { EmployeeVendorCode = request.EmployeeVendorCode, CompanyCode = request.CompanyCode });
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -161,7 +162,7 @@ public class IntegrationService : IIntegrationService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<MaterialIntegrationReqResponse> UpsertMaterialAsync(MaterialIntegrationRequest request)
|
public async Task<MaterialIntegrationReqResponse> UpsertMaterialAsync(IntegrationMaterialRequest request)
|
||||||
{
|
{
|
||||||
MaterialIntegrationReqResponse response = new MaterialIntegrationReqResponse();
|
MaterialIntegrationReqResponse response = new MaterialIntegrationReqResponse();
|
||||||
try
|
try
|
||||||
|
|
@ -169,7 +170,7 @@ public class IntegrationService : IIntegrationService
|
||||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MaterialIntegrationResponse meterial = await GetMaterialByCodeAsync(tc,
|
IntegrationMaterialResponse meterial = await GetMaterialByCodeAsync(tc,
|
||||||
new GetMaterialByCodeRequest() { MaterialCode = request.MaterialCode });
|
new GetMaterialByCodeRequest() { MaterialCode = request.MaterialCode });
|
||||||
|
|
||||||
if (meterial != null && meterial.MeterialId > 0)
|
if (meterial != null && meterial.MeterialId > 0)
|
||||||
|
|
@ -201,9 +202,9 @@ public class IntegrationService : IIntegrationService
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<MaterialIntegrationResponse> GetMaterialByCodeAsync(GetMaterialByCodeRequest request)
|
public async Task<IntegrationMaterialResponse> GetMaterialByCodeAsync(GetMaterialByCodeRequest request)
|
||||||
{
|
{
|
||||||
MaterialIntegrationResponse response = new();
|
IntegrationMaterialResponse response = new();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
||||||
|
|
@ -227,6 +228,73 @@ public class IntegrationService : IIntegrationService
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<MaterialIntegrationPriceReqResponse> UpsertMaterialPriceAsync(IntegrationMaterialPriceRequest request)
|
||||||
|
{
|
||||||
|
MaterialIntegrationPriceReqResponse response = new MaterialIntegrationPriceReqResponse();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IntegrationMaterialPriceResponse meterialPrice = await GetMaterialPriceByCodeAndConditionTypeAsync(tc,
|
||||||
|
new GetMaterialPriceByCodeRequest() { MaterialCode = request.MaterialCode, ConditionType = request.ConditionType });
|
||||||
|
|
||||||
|
if (meterialPrice != null && !string.IsNullOrWhiteSpace(meterialPrice.MaterialCode))
|
||||||
|
{
|
||||||
|
UpdateMaterialPrice(tc, request);
|
||||||
|
response.IsUpdated = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CreateMaterialPrice(tc, request);
|
||||||
|
response.IsUpdated = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
response.MaterialCode = request.MaterialCode;
|
||||||
|
response.ConditionType = request.ConditionType;
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception ie)
|
||||||
|
{
|
||||||
|
tc?.HandleError();
|
||||||
|
|
||||||
|
throw DBCustomError.GenerateCustomError(ie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IntegrationMaterialPriceResponse> GetMaterialPriceByCodeAsync(GetMaterialPriceByCodeRequest request)
|
||||||
|
{
|
||||||
|
IntegrationMaterialPriceResponse response = new();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = await GetMaterialPriceByCodeAndConditionTypeAsync(tc, request);
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception ie)
|
||||||
|
{
|
||||||
|
tc?.HandleError();
|
||||||
|
|
||||||
|
throw DBCustomError.GenerateCustomError(ie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#region Customer Private Functions
|
#region Customer Private Functions
|
||||||
|
|
||||||
|
|
@ -297,7 +365,7 @@ public class IntegrationService : IIntegrationService
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CreateCustomer(TransactionContext tc, CustomerIntegrationRequest request)
|
private bool CreateCustomer(TransactionContext tc, IntegrationCustomerRequest request)
|
||||||
{
|
{
|
||||||
bool returnValue = false;
|
bool returnValue = false;
|
||||||
|
|
||||||
|
|
@ -371,7 +439,7 @@ public class IntegrationService : IIntegrationService
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateCustomer(TransactionContext tc, CustomerIntegrationRequest request)
|
private bool UpdateCustomer(TransactionContext tc, IntegrationCustomerRequest request)
|
||||||
{
|
{
|
||||||
bool returnValue = false;
|
bool returnValue = false;
|
||||||
|
|
||||||
|
|
@ -449,9 +517,9 @@ public class IntegrationService : IIntegrationService
|
||||||
|
|
||||||
#region Employee Private Functions
|
#region Employee Private Functions
|
||||||
|
|
||||||
private async Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(TransactionContext tc, EmployeeIntegrationByComapanyRequest request)
|
private async Task<IntegrationEmployeeResponse> GetEmployeeBySalesOrgAsync(TransactionContext tc, EmployeeIntegrationByComapanyRequest request)
|
||||||
{
|
{
|
||||||
EmployeeIntegrationResponse response = new EmployeeIntegrationResponse();
|
IntegrationEmployeeResponse response = new IntegrationEmployeeResponse();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -465,7 +533,7 @@ public class IntegrationService : IIntegrationService
|
||||||
{
|
{
|
||||||
if (dr.Read())
|
if (dr.Read())
|
||||||
{
|
{
|
||||||
response = new EmployeeIntegrationResponse()
|
response = new IntegrationEmployeeResponse()
|
||||||
{
|
{
|
||||||
EmployeeId = dr.GetInt32(0),
|
EmployeeId = dr.GetInt32(0),
|
||||||
EmployeeVendorCode = dr.GetString(1),
|
EmployeeVendorCode = dr.GetString(1),
|
||||||
|
|
@ -505,7 +573,7 @@ public class IntegrationService : IIntegrationService
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool InsertEmployee(TransactionContext tc, EmployeeIntegrationRequest request)
|
private bool InsertEmployee(TransactionContext tc, IntegrationEmployeeRequest request)
|
||||||
{
|
{
|
||||||
bool returnValue = false;
|
bool returnValue = false;
|
||||||
|
|
||||||
|
|
@ -562,7 +630,7 @@ public class IntegrationService : IIntegrationService
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateEmployee(TransactionContext tc, EmployeeIntegrationRequest request)
|
private bool UpdateEmployee(TransactionContext tc, IntegrationEmployeeRequest request)
|
||||||
{
|
{
|
||||||
bool returnValue = false;
|
bool returnValue = false;
|
||||||
|
|
||||||
|
|
@ -624,9 +692,9 @@ public class IntegrationService : IIntegrationService
|
||||||
|
|
||||||
#region Meterial Private Functions
|
#region Meterial Private Functions
|
||||||
|
|
||||||
private async Task<MaterialIntegrationResponse> GetMaterialByCodeAsync(TransactionContext tc, GetMaterialByCodeRequest request)
|
private async Task<IntegrationMaterialResponse> GetMaterialByCodeAsync(TransactionContext tc, GetMaterialByCodeRequest request)
|
||||||
{
|
{
|
||||||
MaterialIntegrationResponse response = new MaterialIntegrationResponse();
|
IntegrationMaterialResponse response = new IntegrationMaterialResponse();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -639,7 +707,7 @@ public class IntegrationService : IIntegrationService
|
||||||
{
|
{
|
||||||
if (dr.Read())
|
if (dr.Read())
|
||||||
{
|
{
|
||||||
response = new MaterialIntegrationResponse()
|
response = new IntegrationMaterialResponse()
|
||||||
{
|
{
|
||||||
MeterialId = dr.GetInt32(0),
|
MeterialId = dr.GetInt32(0),
|
||||||
MaterialType = dr.GetString(1),
|
MaterialType = dr.GetString(1),
|
||||||
|
|
@ -670,7 +738,7 @@ public class IntegrationService : IIntegrationService
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CreateMaterial(TransactionContext tc, MaterialIntegrationRequest request)
|
private bool CreateMaterial(TransactionContext tc, IntegrationMaterialRequest request)
|
||||||
{
|
{
|
||||||
bool returnValue = false;
|
bool returnValue = false;
|
||||||
|
|
||||||
|
|
@ -714,7 +782,7 @@ public class IntegrationService : IIntegrationService
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateMaterial(TransactionContext tc, MaterialIntegrationRequest request)
|
private bool UpdateMaterial(TransactionContext tc, IntegrationMaterialRequest request)
|
||||||
{
|
{
|
||||||
bool returnValue = false;
|
bool returnValue = false;
|
||||||
|
|
||||||
|
|
@ -759,4 +827,125 @@ public class IntegrationService : IIntegrationService
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Material Price Private Functions
|
||||||
|
|
||||||
|
private async Task<IntegrationMaterialPriceResponse> GetMaterialPriceByCodeAndConditionTypeAsync(
|
||||||
|
TransactionContext tc, GetMaterialPriceByCodeRequest request)
|
||||||
|
{
|
||||||
|
IntegrationMaterialPriceResponse response = new IntegrationMaterialPriceResponse();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SqlParameter[] p =
|
||||||
|
[
|
||||||
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
|
||||||
|
SqlHelperExtension.CreateInParam("@ConditionType", SqlDbType.NVarChar, request.ConditionType)
|
||||||
|
];
|
||||||
|
|
||||||
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetMaterialPriceByMaterialCodeAndConditionType", parameterValues: p))
|
||||||
|
{
|
||||||
|
while (dr.Read())
|
||||||
|
{
|
||||||
|
response=new IntegrationMaterialPriceResponse()
|
||||||
|
{
|
||||||
|
MaterialPriceId = dr.GetInt32(0),
|
||||||
|
SalesOrg = dr.GetString(1),
|
||||||
|
DistributionChannel = dr.GetString(2),
|
||||||
|
CustomerNumber = dr.GetString(3),
|
||||||
|
CustomerGroupCode = dr.IsDBNull(4) ? null : dr.GetString(4),
|
||||||
|
MaterialCode = dr.GetString(5),
|
||||||
|
ConditionType = dr.GetString(6),
|
||||||
|
CalculationType = dr.GetString(7),
|
||||||
|
PricingUnit = dr.GetString(8),
|
||||||
|
UnitOfMeasure = dr.GetString(9),
|
||||||
|
ValidFrom = dr.GetDateTime(10),
|
||||||
|
ValidTo = dr.GetDateTime(11),
|
||||||
|
Status = dr.IsDBNull(12) ? null : dr.GetString(12),
|
||||||
|
ConditionValue = dr.GetDecimal(13)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
dr.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw DBCustomError.GenerateCustomError(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int CreateMaterialPrice(TransactionContext tc, IntegrationMaterialPriceRequest request)
|
||||||
|
{
|
||||||
|
int newMaterialPriceId = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SqlParameter[] p =
|
||||||
|
[
|
||||||
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg),
|
||||||
|
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
|
||||||
|
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, request.CustomerNumber),
|
||||||
|
SqlHelperExtension.CreateInParam("@CustomerGroupCode", SqlDbType.NVarChar, request.CustomerGroupCode),
|
||||||
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
|
||||||
|
SqlHelperExtension.CreateInParam("@ConditionType", SqlDbType.NVarChar, request.ConditionType),
|
||||||
|
SqlHelperExtension.CreateInParam("@CalculationType", SqlDbType.NVarChar, request.CalculationType),
|
||||||
|
SqlHelperExtension.CreateInParam("@PricingUnit", SqlDbType.NVarChar, request.PricingUnit),
|
||||||
|
SqlHelperExtension.CreateInParam("@UnitOfMeasure", SqlDbType.NVarChar, request.UnitOfMeasure),
|
||||||
|
SqlHelperExtension.CreateInParam("@ValidFrom", SqlDbType.DateTime, request.ValidFrom),
|
||||||
|
SqlHelperExtension.CreateInParam("@ValidTo", SqlDbType.DateTime, request.ValidTo),
|
||||||
|
SqlHelperExtension.CreateInParam("@Status", SqlDbType.NVarChar, request.Status),
|
||||||
|
SqlHelperExtension.CreateInParam("@ConditionValue", SqlDbType.Decimal, request.ConditionValue),
|
||||||
|
SqlHelperExtension.CreateOutParam("@NewMaterialPriceId", SqlDbType.Int)
|
||||||
|
];
|
||||||
|
|
||||||
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.InsertIntegrationMaterialPrice", parameterValues: p);
|
||||||
|
|
||||||
|
newMaterialPriceId = (int)p[14].Value;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newMaterialPriceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool UpdateMaterialPrice(TransactionContext tc, IntegrationMaterialPriceRequest request)
|
||||||
|
{
|
||||||
|
bool returnValue = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SqlParameter[] p =
|
||||||
|
[
|
||||||
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg),
|
||||||
|
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
|
||||||
|
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, request.CustomerNumber),
|
||||||
|
SqlHelperExtension.CreateInParam("@CustomerGroupCode", SqlDbType.NVarChar, request.CustomerGroupCode),
|
||||||
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
|
||||||
|
SqlHelperExtension.CreateInParam("@ConditionType", SqlDbType.NVarChar, request.ConditionType),
|
||||||
|
SqlHelperExtension.CreateInParam("@CalculationType", SqlDbType.NVarChar, request.CalculationType),
|
||||||
|
SqlHelperExtension.CreateInParam("@PricingUnit", SqlDbType.NVarChar, request.PricingUnit),
|
||||||
|
SqlHelperExtension.CreateInParam("@UnitOfMeasure", SqlDbType.NVarChar, request.UnitOfMeasure),
|
||||||
|
SqlHelperExtension.CreateInParam("@ValidFrom", SqlDbType.DateTime, request.ValidFrom),
|
||||||
|
SqlHelperExtension.CreateInParam("@ValidTo", SqlDbType.DateTime, request.ValidTo),
|
||||||
|
SqlHelperExtension.CreateInParam("@Status", SqlDbType.NVarChar, request.Status),
|
||||||
|
SqlHelperExtension.CreateInParam("@ConditionValue", SqlDbType.Decimal, request.ConditionValue)
|
||||||
|
];
|
||||||
|
|
||||||
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.UpdateIntegrationMaterialPrice", parameterValues: p);
|
||||||
|
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,9 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
|
||||||
[HttpPost("Customers")]
|
[HttpPost("Customers")]
|
||||||
[IgnoreAntiforgeryToken]
|
[IgnoreAntiforgeryToken]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IntegrationLoginResponse))]
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IntegrationLoginResponse))]
|
||||||
public async Task<IActionResult> UpsertCustomers(CustomerIntegrationRequest request)
|
public async Task<IActionResult> UpsertCustomers(IntegrationCustomerRequest request)
|
||||||
{
|
{
|
||||||
CustomerIntegrationResponse response = new CustomerIntegrationResponse();
|
IntegrationCustomerResponse response = new IntegrationCustomerResponse();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = await _integrationService.UpsertCustomerAsync(request);
|
response = await _integrationService.UpsertCustomerAsync(request);
|
||||||
|
|
@ -80,7 +80,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
|
||||||
[HttpPost("Employees")]
|
[HttpPost("Employees")]
|
||||||
[IgnoreAntiforgeryToken]
|
[IgnoreAntiforgeryToken]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(EmployeeIntegrationReqResponse))]
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(EmployeeIntegrationReqResponse))]
|
||||||
public async Task<IActionResult> UpsertEmployee(EmployeeIntegrationRequest request)
|
public async Task<IActionResult> UpsertEmployee(IntegrationEmployeeRequest request)
|
||||||
{
|
{
|
||||||
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
|
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
|
||||||
try
|
try
|
||||||
|
|
@ -121,7 +121,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
|
||||||
[IgnoreAntiforgeryToken]
|
[IgnoreAntiforgeryToken]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(MaterialIntegrationReqResponse))]
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(MaterialIntegrationReqResponse))]
|
||||||
[ProducesResponseType(StatusCodes.Status201Created, Type = typeof(MaterialIntegrationReqResponse))]
|
[ProducesResponseType(StatusCodes.Status201Created, Type = typeof(MaterialIntegrationReqResponse))]
|
||||||
public async Task<IActionResult> UpsertMeterial(MaterialIntegrationRequest request)
|
public async Task<IActionResult> UpsertMeterial(IntegrationMaterialRequest request)
|
||||||
{
|
{
|
||||||
MaterialIntegrationReqResponse response = new MaterialIntegrationReqResponse();
|
MaterialIntegrationReqResponse response = new MaterialIntegrationReqResponse();
|
||||||
try
|
try
|
||||||
|
|
@ -149,5 +149,45 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, response);
|
return StatusCode(StatusCodes.Status500InternalServerError, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Insert or Update Material for SAP
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns>if created return 201 or if updated return 200 true</returns>
|
||||||
|
[HttpPost("MaterialPrices")]
|
||||||
|
[IgnoreAntiforgeryToken]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(MaterialIntegrationPriceReqResponse))]
|
||||||
|
[ProducesResponseType(StatusCodes.Status201Created, Type = typeof(MaterialIntegrationPriceReqResponse))]
|
||||||
|
public async Task<IActionResult> UpsertMeterialPrices(IntegrationMaterialPriceRequest request)
|
||||||
|
{
|
||||||
|
MaterialIntegrationPriceReqResponse response = new MaterialIntegrationPriceReqResponse();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = await _integrationService.UpsertMaterialPriceAsync(request);
|
||||||
|
if (!response.IsUpdated)
|
||||||
|
{
|
||||||
|
response.ReturnMessage.Add($"Material Price Created Successfully for MaterialCode :{request.MaterialCode} And ConditionType : {request.ConditionType} ");
|
||||||
|
response.ReturnStatus = StatusCodes.Status201Created;
|
||||||
|
return StatusCode(StatusCodes.Status201Created, response);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response.ReturnMessage.Add($"Material Price Updated Successfully for MaterialCode :{request.MaterialCode} And ConditionType : {request.ConditionType} ");
|
||||||
|
response.ReturnStatus = StatusCodes.Status200OK;
|
||||||
|
return StatusCode(StatusCodes.Status200OK, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string msg = $"Exception Occur in Material Price Operation {request?.MaterialCode} And ConditionType : {request.ConditionType}";
|
||||||
|
_logger.LogError(exception: ex, msg);
|
||||||
|
response.ReturnStatus = StatusCodes.Status500InternalServerError;
|
||||||
|
response.ReturnMessage.Add(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user