Completed Customer, Employee and Material API

This commit is contained in:
dibakor 2026-06-18 18:19:43 +06:00
parent cc740be2d5
commit a43f4a5870
12 changed files with 1011 additions and 448 deletions

View File

@ -1,57 +1,42 @@
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
using System.ComponentModel.DataAnnotations;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
public class CustomerIntegration
{
public int CustomerId { get; set; }
public string CustomerNumber { get; set; }
public string CustomerName { get; set; }
public string AccountGroup { get; set; }
public string AccountGroupDescription { get; set; }
public string CompanyCode { get; set; }
public string CompanyCodeDescription { get; set; }
public string SalesOrganization { get; set; }
public string SalesOrganizationDescription { get; set; }
public string DistributionChannel { get; set; }
public string DistributionChannelDescription { get; set; }
public string Division { get; set; }
public string DivisionDescription { get; set; }
public string MobileNumber { get; set; }
public string EmailAddress { get; set; }
public string BusinessTaxNumber { get; set; }
public decimal? CreditLimit { get; set; }
public string SalesOffice { get; set; }
public string SalesOfficeDescription { get; set; }
public decimal CreditLimit { get; set; }
public string SalesGroup { get; set; }
public string SalesGroupDescription { get; set; }
public string CustomerGroup { get; set; }
public string Status { get; set; }
public string CustomerGroupDescription { get; set; }
public string CustomerPriceGroup { get; set; }
public string CustomerPriceGroupDescription { get; set; }
public string StatusCode { get; set; }
public string StatusDescription { get; set; }
public string PaymentTerms { get; set; }
public string PaymentTermsDescription { get; set; }
public string SearchTerm { get; set; }
public string Region { get; set; }
public string RegionName { get; set; }
public string Area { get; set; }
public string AreaName { get; set; }
public string SalesUnit { get; set; }
public string SalesUnitName { get; set; }
public string AreaRegion { get; set; }
public string AreaRegionDescription { get; set; }
public string SalesUnitAreaAV { get; set; }
public string SalesUnitAreaAVDescription { get; set; }
public string Territory { get; set; }
public string TerritoryName { get; set; }
public string Plant { get; set; }
public string PlantName { get; set; }
}

View File

@ -0,0 +1,29 @@
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
public class EmployeeIntegration
{
public string EmployeeVendorCode { get; set; }
public string EmployeeVendorName { get; set; }
public string Designation { get; set; }
public string DesignationDescription { get; set; }
public string MobileNo { get; set; }
public string Mail { get; set; }
public string CompanyCode { get; set; }
public string CompanyName { get; set; }
public string SalesOrg { get; set; }
public string SalesOrgDescription { get; set; }
public string DistChannel { get; set; }
public string DistChannelDescription { get; set; }
public string Division { get; set; }
public string DivisionDescription { get; set; }
public string RegionAreaCode { get; set; }
public string RegionAreaDescription { get; set; }
public string AreaAVSalesUnitCode { get; set; }
public string AreaAVSalesUnitDescription { get; set; }
public string Territory { get; set; }
public string TerritoryDescription { get; set; }
public string Plant { get; set; }
public string PlantDescription { get; set; }
public string Status { get; set; }
public string StatusDescription { get; set; }
}

View File

@ -0,0 +1,26 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
public class MaterialIntegration
{
public int MeterialId { get; set; }
public string MaterialType { get; set; }
public string MaterialTypeDescription { get; set; }
public string MaterialCode { get; set; }
public string MaterialDescription { get; set; }
public string MaterialGroupCode { get; set; }
public string MaterialGroupDescription { get; set; }
public string BaseUnitOfMeasure { get; set; }
public string SalesUnitOfMeasure { get; set; }
public decimal UnitConversionWithBaseUoM { get; set; }
public string PlantCode { get; set; }
public string PlantDescription { get; set; }
public string StorageLocationCode { get; set; }
public string StorageLocationDescription { get; set; }
public string SalesOrganization { get; set; }
public string SalesOrganizationDescription { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime? UpdatedDate { get; set; }
}

View File

@ -7,141 +7,150 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
public class CustomerIntegrationRequest
{
[Required(ErrorMessage = "Customer Number is required")]
[StringLength(10, MinimumLength = 1, ErrorMessage = "Customer Number must be between 1 and 10 characters")]
public string CustomerNumber { get; set; } = string.Empty;
[Required(ErrorMessage = "Customer number is required.")]
[StringLength(10, ErrorMessage = "Customer number cannot exceed 10 characters.")]
public string CustomerNumber { get; set; }
[Required(ErrorMessage = "Customer Name is required")]
[StringLength(35, MinimumLength = 1, ErrorMessage = "Customer Name must be between 1 and 35 characters")]
public string CustomerName { get; set; } = string.Empty;
[Required(ErrorMessage = "Customer name is required.")]
[StringLength(35, ErrorMessage = "Customer name cannot exceed 35 characters.")]
public string CustomerName { get; set; }
[Required(ErrorMessage = "Account Group is required")]
[StringLength(3, MinimumLength = 1, ErrorMessage = "Account Group must be between 1 and 3 characters")]
public string AccountGroup { get; set; } = string.Empty;
[Required(ErrorMessage = "Account group is required.")]
[StringLength(4, ErrorMessage = "Account group cannot exceed 3 characters.")]
public string AccountGroup { get; set; }
[Required(ErrorMessage = "Account Group Description is required")]
[StringLength(30, ErrorMessage = "Account Group Description cannot exceed 30 characters")]
public string AccountGroupDescription { get; set; } = string.Empty;
[Required(ErrorMessage = "Account group description is required.")]
[StringLength(30, ErrorMessage = "Account group description cannot exceed 30 characters.")]
public string AccountGroupDescription { get; set; }
[Required(ErrorMessage = "Company Code is required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Company Code must be between 1 and 4 characters")]
public string CompanyCode { get; set; } = string.Empty;
[Required(ErrorMessage = "Company code is required.")]
[StringLength(4, ErrorMessage = "Company code cannot exceed 4 characters.")]
public string CompanyCode { get; set; }
[Required(ErrorMessage = "Company Code Description is required")]
[StringLength(25, ErrorMessage = "Company Code Description cannot exceed 25 characters")]
public string CompanyCodeDescription { get; set; } = string.Empty;
[Required(ErrorMessage = "Company code description is required.")]
[StringLength(25, ErrorMessage = "Company code description cannot exceed 25 characters.")]
public string CompanyCodeDescription { get; set; }
[Required(ErrorMessage = "Sales Organization is required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Sales Organization must be between 1 and 4 characters")]
public string SalesOrganization { get; set; } = string.Empty;
[Required(ErrorMessage = "Sales organization is required.")]
[StringLength(4, ErrorMessage = "Sales organization cannot exceed 4 characters.")]
public string SalesOrganization { get; set; }
[Required(ErrorMessage = "Sales Organization Description is required")]
[StringLength(40, ErrorMessage = "Sales Organization Description cannot exceed 40 characters")]
public string SalesOrganizationDescription { get; set; } = string.Empty;
[Required(ErrorMessage = "Sales organization description is required.")]
[StringLength(40, ErrorMessage = "Sales organization description cannot exceed 40 characters.")]
public string SalesOrganizationDescription { get; set; }
[Required(ErrorMessage = "Distribution Channel is required")]
[StringLength(2, MinimumLength = 1, ErrorMessage = "Distribution Channel must be between 1 and 2 characters")]
public string DistributionChannel { get; set; } = string.Empty;
[Required(ErrorMessage = "Distribution channel is required.")]
[StringLength(2, ErrorMessage = "Distribution channel cannot exceed 2 characters.")]
public string DistributionChannel { get; set; }
[Required(ErrorMessage = "Distribution Channel Description is required")]
[StringLength(20, ErrorMessage = "Distribution Channel Description cannot exceed 20 characters")]
public string DistributionChannelDescription { get; set; } = string.Empty;
[Required(ErrorMessage = "Distribution channel description is required.")]
[StringLength(20, ErrorMessage = "Distribution channel description cannot exceed 20 characters.")]
public string DistributionChannelDescription { get; set; }
[Required(ErrorMessage = "Division is required")]
[StringLength(2, MinimumLength = 1, ErrorMessage = "Division must be between 1 and 2 characters")]
public string Division { get; set; } = string.Empty;
[Required(ErrorMessage = "Division is required.")]
[StringLength(2, ErrorMessage = "Division cannot exceed 2 characters.")]
public string Division { get; set; }
[Required(ErrorMessage = "Division Description is required")]
[StringLength(20, ErrorMessage = "Division Description cannot exceed 20 characters")]
public string DivisionDescription { get; set; } = string.Empty;
[Required(ErrorMessage = "Division description is required.")]
[StringLength(20, ErrorMessage = "Division description cannot exceed 20 characters.")]
public string DivisionDescription { get; set; }
[Required(ErrorMessage = "Mobile Number is required")]
[StringLength(31, ErrorMessage = "Mobile Number cannot exceed 31 characters")]
[Phone(ErrorMessage = "Invalid mobile number format")]
public string MobileNumber { get; set; } = string.Empty;
[Required(ErrorMessage = "Mobile number is required.")]
[StringLength(31, ErrorMessage = "Mobile number cannot exceed 31 characters.")]
[Phone(ErrorMessage = "Mobile number is not a valid phone number.")]
public string MobileNumber { get; set; }
[Required(ErrorMessage = "Email Address is required")]
[StringLength(241, ErrorMessage = "Email Address cannot exceed 241 characters")]
[EmailAddress(ErrorMessage = "Invalid email address format")]
public string EmailAddress { get; set; } = string.Empty;
[Required(ErrorMessage = "Email address is required.")]
[StringLength(241, ErrorMessage = "Email address cannot exceed 241 characters.")]
[EmailAddress(ErrorMessage = "Email address is not valid.")]
public string EmailAddress { get; set; }
[Required(ErrorMessage = "Business/Tax Number is required")]
[StringLength(16, ErrorMessage = "Business/Tax Number cannot exceed 16 characters")]
public string BusinessTaxNumber { get; set; } = string.Empty;
[Required(ErrorMessage = "Business/Tax number is required.")]
[StringLength(16, ErrorMessage = "Business/Tax number cannot exceed 16 characters.")]
public string BusinessTaxNumber { get; set; }
[Required(ErrorMessage = "Credit Limit is required")]
[Range(0, 9999999999999, ErrorMessage = "Credit Limit must be a valid number")]
[Required(ErrorMessage = "Credit limit is required.")]
[Range(0, 9999999999999.99, ErrorMessage = "Credit limit must be between 0 and 9,999,999,999,999.99.")]
public decimal CreditLimit { get; set; }
[Required(ErrorMessage = "Sales Office is required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Sales Office must be between 1 and 4 characters")]
public string SalesOffice { get; set; } = string.Empty;
[Required(ErrorMessage = "Sales group is required.")]
[StringLength(3, ErrorMessage = "Sales group cannot exceed 3 characters.")]
public string SalesGroup { get; set; }
[StringLength(255, ErrorMessage = "Sales Office Description cannot exceed 255 characters")]
public string? SalesOfficeDescription { get; set; }
[Required(ErrorMessage = "Sales group description is required.")]
[StringLength(20, ErrorMessage = "Sales group description cannot exceed 20 characters.")]
public string SalesGroupDescription { get; set; }
[Required(ErrorMessage = "Sales Group is required")]
[StringLength(3, MinimumLength = 1, ErrorMessage = "Sales Group must be between 1 and 3 characters")]
public string SalesGroup { get; set; } = string.Empty;
[Required(ErrorMessage = "Customer group is required.")]
[StringLength(2, ErrorMessage = "Customer group cannot exceed 2 characters.")]
public string CustomerGroup { get; set; }
[Required(ErrorMessage = "Customer Group is required")]
[StringLength(2, MinimumLength = 1, ErrorMessage = "Customer Group must be between 1 and 2 characters")]
public string CustomerGroup { get; set; } = string.Empty;
[Required(ErrorMessage = "Customer group description is required.")]
[StringLength(20, ErrorMessage = "Customer group description cannot exceed 20 characters.")]
public string CustomerGroupDescription { get; set; }
[Required(ErrorMessage = "Status is required")]
[StringLength(1, MinimumLength = 1, ErrorMessage = "Status must be exactly 1 character")]
public string Status { get; set; } = string.Empty;
[Required(ErrorMessage = "Customer price group is required.")]
[StringLength(2, ErrorMessage = "Customer price group cannot exceed 2 characters.")]
public string CustomerPriceGroup { get; set; }
[Required(ErrorMessage = "Payment Terms are required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Payment Terms must be between 1 and 4 characters")]
public string PaymentTerms { get; set; } = string.Empty;
[Required(ErrorMessage = "Customer price group description is required.")]
[StringLength(20, ErrorMessage = "Customer price group description cannot exceed 20 characters.")]
public string CustomerPriceGroupDescription { get; set; }
[Required(ErrorMessage = "Search Term is required")]
[StringLength(20, ErrorMessage = "Search Term cannot exceed 20 characters")]
public string SearchTerm { get; set; } = string.Empty;
[Required(ErrorMessage = "Status code is required.")]
[StringLength(1, ErrorMessage = "Status code cannot exceed 1 character.")]
public string StatusCode { get; set; }
[Required(ErrorMessage = "Region is required")]
[StringLength(3, MinimumLength = 1, ErrorMessage = "Region must be between 1 and 3 characters")]
public string Region { get; set; } = string.Empty;
[Required(ErrorMessage = "Status description is required.")]
[StringLength(30, ErrorMessage = "Status description cannot exceed 30 characters.")]
public string StatusDescription { get; set; }
[Required(ErrorMessage = "Region Name is required")]
[StringLength(40, ErrorMessage = "Region Name cannot exceed 40 characters")]
public string RegionName { get; set; } = string.Empty;
[Required(ErrorMessage = "Payment terms is required.")]
[StringLength(4, ErrorMessage = "Payment terms cannot exceed 4 characters.")]
public string PaymentTerms { get; set; }
[Required(ErrorMessage = "Area is required")]
[StringLength(10, MinimumLength = 1, ErrorMessage = "Area must be between 1 and 10 characters")]
public string Area { get; set; } = string.Empty;
[Required(ErrorMessage = "Payment terms description is required.")]
public string PaymentTermsDescription { get; set; }
[Required(ErrorMessage = "Area Name is required")]
[StringLength(40, ErrorMessage = "Area Name cannot exceed 40 characters")]
public string AreaName { get; set; } = string.Empty;
[Required(ErrorMessage = "Search term is required.")]
[StringLength(20, ErrorMessage = "Search term cannot exceed 20 characters.")]
public string SearchTerm { get; set; }
[Required(ErrorMessage = "Sales Unit is required")]
[StringLength(3, MinimumLength = 1, ErrorMessage = "Sales Unit must be between 1 and 3 characters")]
public string SalesUnit { get; set; } = string.Empty;
[Required(ErrorMessage = "Area/Region is required.")]
[StringLength(3, ErrorMessage = "Area/Region cannot exceed 3 characters.")]
public string AreaRegion { get; set; }
[Required(ErrorMessage = "Sales Unit Name is required")]
[StringLength(30, ErrorMessage = "Sales Unit Name cannot exceed 30 characters")]
public string SalesUnitName { get; set; } = string.Empty;
[Required(ErrorMessage = "Area/Region description is required.")]
[StringLength(40, ErrorMessage = "Area/Region description cannot exceed 40 characters.")]
public string AreaRegionDescription { get; set; }
[Required(ErrorMessage = "Territory is required")]
[StringLength(3, MinimumLength = 1, ErrorMessage = "Territory must be between 1 and 3 characters")]
public string Territory { get; set; } = string.Empty;
[Required(ErrorMessage = "Sales Unit/Area-AV is required.")]
[StringLength(10, ErrorMessage = "Sales Unit/Area-AV cannot exceed 10 characters.")]
public string SalesUnitAreaAV { get; set; }
[Required(ErrorMessage = "Territory Name is required")]
[StringLength(20, ErrorMessage = "Territory Name cannot exceed 20 characters")]
public string TerritoryName { get; set; } = string.Empty;
[Required(ErrorMessage = "Sales Unit/Area-AV description is required.")]
[StringLength(40, ErrorMessage = "Sales Unit/Area-AV description cannot exceed 40 characters.")]
public string SalesUnitAreaAVDescription { get; set; }
[Required(ErrorMessage = "Plant is required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Plant must be between 1 and 4 characters")]
public string Plant { get; set; } = string.Empty;
[Required(ErrorMessage = "Territory is required.")]
[StringLength(3, ErrorMessage = "Territory cannot exceed 3 characters.")]
public string Territory { get; set; }
[Required(ErrorMessage = "Plant Name is required")]
[StringLength(30, ErrorMessage = "Plant Name cannot exceed 30 characters")]
public string PlantName { get; set; } = string.Empty;
[Required(ErrorMessage = "Territory name is required.")]
[StringLength(20, ErrorMessage = "Territory name cannot exceed 20 characters.")]
public string TerritoryName { get; set; }
[Required(ErrorMessage = "Plant is required.")]
[StringLength(4, ErrorMessage = "Plant cannot exceed 4 characters.")]
public string Plant { get; set; }
[Required(ErrorMessage = "Plant name is required.")]
[StringLength(30, ErrorMessage = "Plant name cannot exceed 30 characters.")]
public string PlantName { get; set; }
}
public class CustomerByCompanyCodeRequest
{
[Required(ErrorMessage = "Customer Number is required")]

View File

@ -1,41 +1,116 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
using System.ComponentModel.DataAnnotations;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
public class EmployeeIntegrationRequest
{
[Required(ErrorMessage = "Employee vendor code is required.")]
[StringLength(10, ErrorMessage = "Employee vendor code cannot exceed 10 characters.")]
public string EmployeeVendorCode { get; set; }
[Required(ErrorMessage = "Employee vendor name is required.")]
[StringLength(35, ErrorMessage = "Employee vendor name cannot exceed 35 characters.")]
public string EmployeeVendorName { get; set; }
public string DesignationCode { get; set; }
[Required(ErrorMessage = "Designation is required.")]
[StringLength(4, ErrorMessage = "Designation cannot exceed 4 characters.")]
public string Designation { get; set; }
[Required(ErrorMessage = "Designation description is required.")]
[StringLength(30, ErrorMessage = "Designation description cannot exceed 30 characters.")]
public string DesignationDescription { get; set; }
[Required(ErrorMessage = "Mobile number is required.")]
[StringLength(31, ErrorMessage = "Mobile number cannot exceed 31 characters.")]
[Phone(ErrorMessage = "Mobile number is not a valid phone number.")]
public string MobileNo { get; set; }
public string Email { get; set; }
public string SalesOrgCode { get; set; }
[Required(ErrorMessage = "Email address is required.")]
[StringLength(241, ErrorMessage = "Email address cannot exceed 241 characters.")]
[EmailAddress(ErrorMessage = "Email address is not valid.")]
public string Mail { get; set; }
[Required(ErrorMessage = "Company code is required.")]
[StringLength(4, ErrorMessage = "Company code cannot exceed 4 characters.")]
public string CompanyCode { get; set; }
[Required(ErrorMessage = "Company name is required.")]
[StringLength(25, ErrorMessage = "Company name cannot exceed 25 characters.")]
public string CompanyName { get; set; }
[Required(ErrorMessage = "Sales org is required.")]
[StringLength(4, ErrorMessage = "Sales org cannot exceed 4 characters.")]
public string SalesOrg { get; set; }
[Required(ErrorMessage = "Sales org description is required.")]
[StringLength(40, ErrorMessage = "Sales org description cannot exceed 40 characters.")]
public string SalesOrgDescription { get; set; }
public string DistChannelCode { get; set; }
[Required(ErrorMessage = "Distribution channel is required.")]
[StringLength(2, ErrorMessage = "Distribution channel cannot exceed 2 characters.")]
public string DistChannel { get; set; }
[Required(ErrorMessage = "Distribution channel description is required.")]
[StringLength(20, ErrorMessage = "Distribution channel description cannot exceed 20 characters.")]
public string DistChannelDescription { get; set; }
public string DivisionCode { get; set; }
[Required(ErrorMessage = "Division is required.")]
[StringLength(2, ErrorMessage = "Division cannot exceed 2 characters.")]
public string Division { get; set; }
[Required(ErrorMessage = "Division description is required.")]
[StringLength(20, ErrorMessage = "Division description cannot exceed 20 characters.")]
public string DivisionDescription { get; set; }
public string RegionAAl { get; set; }
public string AreaCode { get; set; }
public string AreaDescription { get; set; }
public string SalesUnitACCLCode { get; set; }
public string SalesUnitACCLDescription { get; set; }
public string TerritoryCode { get; set; }
[Required(ErrorMessage = "Region/Area code is required.")]
[StringLength(3, ErrorMessage = "Region/Area code cannot exceed 3 characters.")]
public string RegionAreaCode { get; set; }
[Required(ErrorMessage = "Region/Area description is required.")]
[StringLength(40, ErrorMessage = "Region/Area description cannot exceed 40 characters.")]
public string RegionAreaDescription { get; set; }
[Required(ErrorMessage = "Area-AV/Sales unit code is required.")]
[StringLength(10, ErrorMessage = "Area-AV/Sales unit code cannot exceed 10 characters.")]
public string AreaAVSalesUnitCode { get; set; }
[Required(ErrorMessage = "Area-AV/Sales unit description is required.")]
[StringLength(40, ErrorMessage = "Area-AV/Sales unit description cannot exceed 40 characters.")]
public string AreaAVSalesUnitDescription { get; set; }
[Required(ErrorMessage = "Territory is required.")]
[StringLength(3, ErrorMessage = "Territory cannot exceed 3 characters.")]
public string Territory { get; set; }
[Required(ErrorMessage = "Territory description is required.")]
[StringLength(20, ErrorMessage = "Territory description cannot exceed 20 characters.")]
public string TerritoryDescription { get; set; }
public string SalesOfficeCode { get; set; }
public string SalesOfficeDescription { get; set; }
public string PlantCode { get; set; }
[Required(ErrorMessage = "Plant is required.")]
[StringLength(4, ErrorMessage = "Plant cannot exceed 4 characters.")]
public string Plant { get; set; }
[Required(ErrorMessage = "Plant description is required.")]
[StringLength(30, ErrorMessage = "Plant description cannot exceed 30 characters.")]
public string PlantDescription { get; set; }
[Required(ErrorMessage = "Status is required.")]
[StringLength(1, ErrorMessage = "Status cannot exceed 1 character.")]
public string Status { get; set; }
[Required(ErrorMessage = "Status description is required.")]
[StringLength(30, ErrorMessage = "Status description cannot exceed 30 characters.")]
public string StatusDescription { get; set; }
}
public class EmployeeBySalesOrgCodeRequest
public class EmployeeIntegrationByComapanyRequest
{
public string EmployeeVendorCode { get; set; } = string.Empty;
public string SalesOrgCode { get; set; } = string.Empty;
[Required(ErrorMessage = "Employee vendor code is required.")]
[StringLength(10, ErrorMessage = "Employee vendor code cannot exceed 10 characters.")]
public string EmployeeVendorCode { get; set; }
[Required(ErrorMessage = "Company code is required.")]
[StringLength(4, ErrorMessage = "Company code cannot exceed 4 characters.")]
public string CompanyCode { get; set; }
}

View File

@ -0,0 +1,73 @@
using System.ComponentModel.DataAnnotations;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
public class MaterialIntegrationRequest
{
[Required(ErrorMessage = "Material type is required.")]
[StringLength(4, ErrorMessage = "Material type cannot exceed 4 characters.")]
public string MaterialType { get; set; }
[Required(ErrorMessage = "Material type description is required.")]
[StringLength(25, ErrorMessage = "Material type description cannot exceed 25 characters.")]
public string MaterialTypeDescription { get; set; }
[Required(ErrorMessage = "Material code is required.")]
[StringLength(10, ErrorMessage = "Material code cannot exceed 10 characters.")]
public string MaterialCode { get; set; }
[Required(ErrorMessage = "Material description is required.")]
[StringLength(40, ErrorMessage = "Material description cannot exceed 40 characters.")]
public string MaterialDescription { get; set; }
[Required(ErrorMessage = "Material group code is required.")]
[StringLength(9, ErrorMessage = "Material group code cannot exceed 9 characters.")]
public string MaterialGroupCode { get; set; }
[Required(ErrorMessage = "Material group description is required.")]
[StringLength(20, ErrorMessage = "Material group description cannot exceed 20 characters.")]
public string MaterialGroupDescription { get; set; }
[Required(ErrorMessage = "Base unit of measure is required.")]
[StringLength(3, ErrorMessage = "Base unit of measure cannot exceed 3 characters.")]
public string BaseUnitOfMeasure { get; set; }
[Required(ErrorMessage = "Sales unit of measure is required.")]
[StringLength(3, ErrorMessage = "Sales unit of measure cannot exceed 3 characters.")]
public string SalesUnitOfMeasure { get; set; }
[Required(ErrorMessage = "Unit conversion with base UoM is required.")]
[Range(0.001, 999.999, ErrorMessage = "Unit conversion must be between 0.001 and 999.999.")]
public decimal UnitConversionWithBaseUoM { get; set; }
[Required(ErrorMessage = "Plant code is required.")]
[StringLength(4, ErrorMessage = "Plant code cannot exceed 4 characters.")]
public string PlantCode { get; set; }
[Required(ErrorMessage = "Plant description is required.")]
[StringLength(30, ErrorMessage = "Plant description cannot exceed 30 characters.")]
public string PlantDescription { get; set; }
[Required(ErrorMessage = "Storage location code is required.")]
[StringLength(4, ErrorMessage = "Storage location code cannot exceed 4 characters.")]
public string StorageLocationCode { get; set; }
[Required(ErrorMessage = "Storage location description is required.")]
[StringLength(16, ErrorMessage = "Storage location description cannot exceed 16 characters.")]
public string StorageLocationDescription { get; set; }
[Required(ErrorMessage = "Sales Organization code is required.")]
[StringLength(4, ErrorMessage = "Sales Organization code cannot exceed 4 characters.")]
public string SalesOrganization { get; set; }
[Required(ErrorMessage = "Sales Organization Description is required.")]
[StringLength(16, ErrorMessage = "Sales Organization Description cannot exceed 16 characters.")]
public string SalesOrganizationDescription { get; set; }
}
public class GetMaterialByCodeRequest
{
[Required(ErrorMessage = "Material code is required.")]
[StringLength(10, ErrorMessage = "Material code cannot exceed 10 characters.")]
public string MaterialCode { get; set; }
}

View File

@ -12,53 +12,37 @@ public class CustomerByCompanyCodeResponse : ResponseBase
public int CustomerId { get; set; }
public string CustomerNumber { get; set; }
public string CustomerName { get; set; }
public string AccountGroup { get; set; }
public string AccountGroupDescription { get; set; }
public string CompanyCode { get; set; }
public string CompanyCodeDescription { get; set; }
public string SalesOrganization { get; set; }
public string SalesOrganizationDescription { get; set; }
public string DistributionChannel { get; set; }
public string DistributionChannelDescription { get; set; }
public string Division { get; set; }
public string DivisionDescription { get; set; }
public string MobileNumber { get; set; }
public string EmailAddress { get; set; }
public string BusinessTaxNumber { get; set; }
public decimal? CreditLimit { get; set; }
public string SalesOffice { get; set; }
public string SalesOfficeDescription { get; set; }
public decimal CreditLimit { get; set; }
public string SalesGroup { get; set; }
public string SalesGroupDescription { get; set; }
public string CustomerGroup { get; set; }
public string Status { get; set; }
public string CustomerGroupDescription { get; set; }
public string CustomerPriceGroup { get; set; }
public string CustomerPriceGroupDescription { get; set; }
public string StatusCode { get; set; }
public string StatusDescription { get; set; }
public string PaymentTerms { get; set; }
public string PaymentTermsDescription { get; set; }
public string SearchTerm { get; set; }
public string Region { get; set; }
public string RegionName { get; set; }
public string Area { get; set; }
public string AreaName { get; set; }
public string SalesUnit { get; set; }
public string SalesUnitName { get; set; }
public string AreaRegion { get; set; }
public string AreaRegionDescription { get; set; }
public string SalesUnitAreaAV { get; set; }
public string SalesUnitAreaAVDescription { get; set; }
public string Territory { get; set; }
public string TerritoryName { get; set; }
public string Plant { get; set; }
public string PlantName { get; set; }
}

View File

@ -2,30 +2,28 @@
public class EmployeeIntegrationResponse : ResponseBase
{
public int EmployeeVendorId { get; set; }
public int EmployeeId { get; set; }
public string EmployeeVendorCode { get; set; }
public string EmployeeVendorName { get; set; }
public string DesignationCode { get; set; }
public string Designation { get; set; }
public string DesignationDescription { get; set; }
public string MobileNo { get; set; }
public string Email { get; set; }
public string SalesOrgCode { get; set; }
public string Mail { get; set; }
public string CompanyCode { get; set; }
public string CompanyName { get; set; }
public string SalesOrg { get; set; }
public string SalesOrgDescription { get; set; }
public string DistChannelCode { get; set; }
public string DistChannel { get; set; }
public string DistChannelDescription { get; set; }
public string DivisionCode { get; set; }
public string Division { get; set; }
public string DivisionDescription { get; set; }
public string RegionAAl { get; set; }
public string AreaCode { get; set; }
public string AreaDescription { get; set; }
public string SalesUnitACCLCode { get; set; }
public string SalesUnitACCLDescription { get; set; }
public string TerritoryCode { get; set; }
public string RegionAreaCode { get; set; }
public string RegionAreaDescription { get; set; }
public string AreaAVSalesUnitCode { get; set; }
public string AreaAVSalesUnitDescription { get; set; }
public string Territory { get; set; }
public string TerritoryDescription { get; set; }
public string SalesOfficeCode { get; set; }
public string SalesOfficeDescription { get; set; }
public string PlantCode { get; set; }
public string Plant { get; set; }
public string PlantDescription { get; set; }
public string Status { get; set; }
public string StatusDescription { get; set; }
@ -35,7 +33,7 @@ public class EmployeeIntegrationResponse : ResponseBase
public class EmployeeIntegrationReqResponse : ResponseBase
{
public string EmployeeVendorCode { get; set; }
public string SalesOrgCode { get; set; }
public string CompanyCode { get; set; }
public bool IsUpdated { get; set; }
}

View File

@ -0,0 +1,29 @@
using System.ComponentModel.DataAnnotations;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
public class MaterialIntegrationResponse : ResponseBase
{
public int MeterialId { get; set; }
public string MaterialType { get; set; }
public string MaterialTypeDescription { get; set; }
public string MaterialCode { get; set; }
public string MaterialDescription { get; set; }
public string MaterialGroupCode { get; set; }
public string MaterialGroupDescription { get; set; }
public string BaseUnitOfMeasure { get; set; }
public string SalesUnitOfMeasure { get; set; }
public decimal UnitConversionWithBaseUoM { get; set; }
public string PlantCode { get; set; }
public string PlantDescription { get; set; }
public string StorageLocationCode { get; set; }
public string StorageLocationDescription { get; set; }
public string SalesOrganization { get; set; }
public string SalesOrganizationDescription { get; set; }
}
public class MaterialIntegrationReqResponse : ResponseBase
{
public string MaterialCode { get; set; }
public bool IsUpdated { get; set; }
}

View File

@ -7,8 +7,15 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
public interface IIntegrationService
{
//Customer
Task<CustomerIntegrationResponse> UpsertCustomerAsync(CustomerIntegrationRequest request);
Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request);
//Employee
Task<EmployeeIntegrationReqResponse> UpsertEmployeeAsync(EmployeeIntegrationRequest request);
Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(EmployeeBySalesOrgCodeRequest request);
Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(EmployeeIntegrationByComapanyRequest request);
//Meterial
Task<MaterialIntegrationReqResponse > UpsertMaterialAsync(MaterialIntegrationRequest request);
Task<MaterialIntegrationResponse> GetMaterialByCodeAsync(GetMaterialByCodeRequest request);
}

View File

@ -21,6 +21,7 @@ public class IntegrationService : IIntegrationService
_settings = options.Value;
}
public async Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request)
{
CustomerByCompanyCodeResponse response = new();
@ -47,7 +48,6 @@ public class IntegrationService : IIntegrationService
return response;
}
public async Task<CustomerIntegrationResponse> UpsertCustomerAsync(CustomerIntegrationRequest request)
{
CustomerIntegrationResponse response = new();
@ -61,7 +61,7 @@ public class IntegrationService : IIntegrationService
if( customer != null && customer.CustomerId>0)
{
//Update Here
UpdateCustomer(tc, customer.CustomerId, request);
UpdateCustomer(tc, request);
response.IsUpdated = true;
}
else
@ -91,73 +91,8 @@ public class IntegrationService : IIntegrationService
return response;
}
private async Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(TransactionContext tc, CustomerByCompanyCodeRequest request)
{
CustomerByCompanyCodeResponse response = new CustomerByCompanyCodeResponse();
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@CustomerNumber", pType: SqlDbType.NVarChar,pValue: request.CustomerNumber ),
SqlHelperExtension.CreateInParam(pName: "@CompanyCode", pType: SqlDbType.NVarChar,pValue: request.CompanyCode ),
];
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetCustomerByCompanyCode", parameterValues: p))
{
if (dr.Read())
{
response = new CustomerByCompanyCodeResponse()
{
CustomerId =Convert.ToInt32( dr["CustomerId"].ToString()),
CustomerNumber = dr["CustomerNumber"].ToString(),
CustomerName = dr["CustomerName"].ToString(),
AccountGroup = dr["AccountGroup"].ToString(),
AccountGroupDescription = dr["AccountGroupDescription"].ToString(),
CompanyCode = dr["CompanyCode"].ToString(),
CompanyCodeDescription = dr["CompanyCodeDescription"].ToString(),
SalesOrganization = dr["SalesOrganization"].ToString(),
SalesOrganizationDescription = dr["SalesOrganizationDescription"].ToString(),
DistributionChannel = dr["DistributionChannel"].ToString(),
DistributionChannelDescription = dr["DistributionChannelDescription"].ToString(),
Division = dr["Division"].ToString(),
DivisionDescription = dr["DivisionDescription"].ToString(),
MobileNumber = dr["MobileNumber"].ToString(),
EmailAddress = dr["EmailAddress"].ToString(),
BusinessTaxNumber = dr["BusinessTaxNumber"].ToString(),
CreditLimit = dr["CreditLimit"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["CreditLimit"]),
SalesOffice = dr["SalesOffice"].ToString(),
SalesOfficeDescription = dr["SalesOfficeDescription"].ToString(),
SalesGroup = dr["SalesGroup"].ToString(),
CustomerGroup = dr["CustomerGroup"].ToString(),
Status = dr["Status"].ToString(),
PaymentTerms = dr["PaymentTerms"].ToString(),
SearchTerm = dr["SearchTerm"].ToString(),
Region = dr["Region"].ToString(),
RegionName = dr["RegionName"].ToString(),
Area = dr["Area"].ToString(),
AreaName = dr["AreaName"].ToString(),
SalesUnit = dr["SalesUnit"].ToString(),
SalesUnitName = dr["SalesUnitName"].ToString(),
Territory = dr["Territory"].ToString(),
TerritoryName = dr["TerritoryName"].ToString(),
Plant = dr["Plant"].ToString(),
PlantName = dr["PlantName"].ToString()
};
}
dr.Close();
}
}
catch(Exception ex)
{
throw;
}
return response;
}
public async Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(EmployeeBySalesOrgCodeRequest request)
public async Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(EmployeeIntegrationByComapanyRequest request)
{
EmployeeIntegrationResponse response = new();
try
@ -188,53 +123,26 @@ public class IntegrationService : IIntegrationService
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
try
{
EmployeeIntegrationResponse employee = await GetEmployeeBySalesOrgAsync(tc, new EmployeeBySalesOrgCodeRequest() { SalesOrgCode = request.SalesOrgCode, EmployeeVendorCode = request.EmployeeVendorCode });
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorCode", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorCode),
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorName", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorName),
SqlHelperExtension.CreateInParam(pName: "@DesignationCode", pType: SqlDbType.NVarChar, pValue: request.DesignationCode),
SqlHelperExtension.CreateInParam(pName: "@DesignationDescription", pType: SqlDbType.NVarChar, pValue: request.DesignationDescription),
SqlHelperExtension.CreateInParam(pName: "@MobileNo", pType: SqlDbType.NVarChar, pValue: request.MobileNo),
SqlHelperExtension.CreateInParam(pName: "@Email", pType: SqlDbType.NVarChar, pValue: request.Email),
SqlHelperExtension.CreateInParam(pName: "@SalesOrgCode", pType: SqlDbType.NVarChar, pValue: request.SalesOrgCode),
SqlHelperExtension.CreateInParam(pName: "@SalesOrgDescription", pType: SqlDbType.NVarChar, pValue: request.SalesOrgDescription),
SqlHelperExtension.CreateInParam(pName: "@DistChannelCode", pType: SqlDbType.NVarChar, pValue: request.DistChannelCode),
SqlHelperExtension.CreateInParam(pName: "@DistChannelDescription", pType: SqlDbType.NVarChar, pValue: request.DistChannelDescription),
SqlHelperExtension.CreateInParam(pName: "@DivisionCode", pType: SqlDbType.NVarChar, pValue: request.DivisionCode),
SqlHelperExtension.CreateInParam(pName: "@DivisionDescription", pType: SqlDbType.NVarChar, pValue: request.DivisionDescription),
SqlHelperExtension.CreateInParam(pName: "@RegionAAl", pType: SqlDbType.NVarChar, pValue: request.RegionAAl),
SqlHelperExtension.CreateInParam(pName: "@AreaCode", pType: SqlDbType.NVarChar, pValue: request.AreaCode),
SqlHelperExtension.CreateInParam(pName: "@AreaDescription", pType: SqlDbType.NVarChar, pValue: request.AreaDescription),
SqlHelperExtension.CreateInParam(pName: "@SalesUnitACCLCode", pType: SqlDbType.NVarChar, pValue: request.SalesUnitACCLCode),
SqlHelperExtension.CreateInParam(pName: "@SalesUnitACCLDescription", pType: SqlDbType.NVarChar, pValue: request.SalesUnitACCLDescription),
SqlHelperExtension.CreateInParam(pName: "@TerritoryCode", pType: SqlDbType.NVarChar, pValue: request.TerritoryCode),
SqlHelperExtension.CreateInParam(pName: "@TerritoryDescription", pType: SqlDbType.NVarChar, pValue: request.TerritoryDescription),
SqlHelperExtension.CreateInParam(pName: "@SalesOfficeCode", pType: SqlDbType.NVarChar, pValue: request.SalesOfficeCode),
SqlHelperExtension.CreateInParam(pName: "@SalesOfficeDescription", pType: SqlDbType.NVarChar, pValue: request.SalesOfficeDescription),
SqlHelperExtension.CreateInParam(pName: "@PlantCode", pType: SqlDbType.NVarChar, pValue: request.PlantCode),
SqlHelperExtension.CreateInParam(pName: "@PlantDescription", pType: SqlDbType.NVarChar, pValue: request.PlantDescription),
SqlHelperExtension.CreateInParam(pName: "@Status", pType: SqlDbType.NVarChar, pValue: request.Status),
SqlHelperExtension.CreateInParam(pName: "@StatusDescription", pType: SqlDbType.NVarChar, pValue: request.StatusDescription),
EmployeeIntegrationResponse employee = await GetEmployeeBySalesOrgAsync(tc,
new EmployeeIntegrationByComapanyRequest() { EmployeeVendorCode = request.EmployeeVendorCode, CompanyCode = request.CompanyCode });
];
if (employee != null && employee.EmployeeVendorId > 0)
if (employee != null && employee.EmployeeId > 0)
{
_= tc.ExecuteNonQuerySp("dbo.UpdateEmployee", p);
UpdateEmployee(tc, request);
response.IsUpdated = true;
}
else
{
_= tc.ExecuteNonQuerySp("dbo.InsertEmployee", p);
InsertEmployee(tc, request);
response.IsUpdated = true;
}
response.EmployeeVendorCode = request.EmployeeVendorCode;
response.SalesOrgCode = request.SalesOrgCode;
response.CompanyCode = request.CompanyCode;
tc.End();
}
catch (Exception ie)
@ -252,49 +160,130 @@ public class IntegrationService : IIntegrationService
return response;
}
private async Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(TransactionContext tc, EmployeeBySalesOrgCodeRequest request)
public async Task<MaterialIntegrationReqResponse> UpsertMaterialAsync(MaterialIntegrationRequest request)
{
EmployeeIntegrationResponse response = new EmployeeIntegrationResponse();
MaterialIntegrationReqResponse response = new MaterialIntegrationReqResponse();
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
try
{
MaterialIntegrationResponse meterial = await GetMaterialByCodeAsync(tc,
new GetMaterialByCodeRequest() { MaterialCode = request.MaterialCode });
if (meterial != null && meterial.MeterialId > 0)
{
UpdateMaterial(tc, request);
response.IsUpdated = true;
}
else
{
CreateMaterial(tc, request);
response.IsUpdated = false;
}
response.MaterialCode = request.MaterialCode;
tc.End();
}
catch (Exception ie)
{
tc?.HandleError();
throw DBCustomError.GenerateCustomError(ie);
}
}
catch (Exception ex)
{
throw;
}
return response;
}
public async Task<MaterialIntegrationResponse> GetMaterialByCodeAsync(GetMaterialByCodeRequest request)
{
MaterialIntegrationResponse response = new();
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
try
{
response= await GetMaterialByCodeAsync(tc, request);
tc.End();
}
catch (Exception ie)
{
tc?.HandleError();
throw DBCustomError.GenerateCustomError(ie);
}
}
catch (Exception ex)
{
throw;
}
return response;
}
#region Customer Private Functions
private async Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(TransactionContext tc, CustomerByCompanyCodeRequest request)
{
CustomerByCompanyCodeResponse response = new CustomerByCompanyCodeResponse();
try
{
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: "@CompanyCode", pType: SqlDbType.NVarChar, pValue: request.CompanyCode),
SqlHelperExtension.CreateInParam(pName: "@CustomerNumber", pType: SqlDbType.NVarChar, pValue: request.CustomerNumber)
];
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetEmployeeBySalesOrgCode", parameterValues: p))
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetCustomerByCompanyCode", parameterValues: p))
{
if (dr.Read())
{
response = new EmployeeIntegrationResponse()
response = new CustomerByCompanyCodeResponse()
{
EmployeeVendorId = dr.GetInt32(0),
EmployeeVendorCode = dr.GetString(1),
EmployeeVendorName = dr.GetString(2),
DesignationCode = dr.GetString(3),
DesignationDescription = dr.GetString(4),
MobileNo = dr.GetString(5),
Email = dr.GetString(6),
SalesOrgCode = dr.GetString(7),
SalesOrgDescription = dr.GetString(8),
DistChannelCode = dr.GetString(9),
DistChannelDescription = dr.GetString(10),
DivisionCode = dr.GetString(11),
CustomerId = dr.GetInt32(0),
CustomerNumber = dr.GetString(1),
CustomerName = dr.GetString(2),
AccountGroup = dr.GetString(3),
AccountGroupDescription = dr.GetString(4),
CompanyCode = dr.GetString(5),
CompanyCodeDescription = dr.GetString(6),
SalesOrganization = dr.GetString(7),
SalesOrganizationDescription = dr.GetString(8),
DistributionChannel = dr.GetString(9),
DistributionChannelDescription = dr.GetString(10),
Division = dr.GetString(11),
DivisionDescription = dr.GetString(12),
RegionAAl = dr.GetString(13),
AreaCode = dr.GetString(14),
AreaDescription = dr.GetString(15),
SalesUnitACCLCode = dr.GetString(16),
SalesUnitACCLDescription = dr.GetString(17),
TerritoryCode = dr.GetString(18),
TerritoryDescription = dr.GetString(19),
SalesOfficeCode = dr.GetString(20),
SalesOfficeDescription = dr.GetString(21),
PlantCode = dr.GetString(22),
PlantDescription = dr.GetString(23),
Status = dr.GetString(24),
StatusDescription = dr.GetString(25)
MobileNumber = dr.GetString(13),
EmailAddress = dr.GetString(14),
BusinessTaxNumber = dr.GetString(15),
CreditLimit = dr.GetDecimal(16),
SalesGroup = dr.GetString(17),
SalesGroupDescription = dr.GetString(18),
CustomerGroup = dr.GetString(19),
CustomerGroupDescription = dr.GetString(20),
CustomerPriceGroup = dr.GetString(21),
CustomerPriceGroupDescription = dr.GetString(22),
StatusCode = dr.GetString(23),
StatusDescription = dr.GetString(24),
PaymentTerms = dr.GetString(25),
PaymentTermsDescription = dr.GetString(26),
SearchTerm = dr.GetString(27),
AreaRegion = dr.GetString(28),
AreaRegionDescription = dr.GetString(29),
SalesUnitAreaAV = dr.GetString(30),
SalesUnitAreaAVDescription = dr.GetString(31),
Territory = dr.GetString(32),
TerritoryName = dr.GetString(33),
Plant = dr.GetString(34),
PlantName = dr.GetString(35)
};
}
dr.Close();
@ -304,10 +293,11 @@ public class IntegrationService : IIntegrationService
{
throw DBCustomError.GenerateCustomError(ex);
}
return response;
}
public bool CreateCustomer(TransactionContext tc, CustomerIntegrationRequest request)
private bool CreateCustomer(TransactionContext tc, CustomerIntegrationRequest request)
{
bool returnValue = false;
@ -315,62 +305,65 @@ public class IntegrationService : IIntegrationService
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.VarChar, request.CustomerNumber),
SqlHelperExtension.CreateInParam("@CustomerName", SqlDbType.VarChar, request.CustomerName),
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, request.CustomerNumber),
SqlHelperExtension.CreateInParam("@CustomerName", SqlDbType.NVarChar, request.CustomerName),
SqlHelperExtension.CreateInParam("@AccountGroup", SqlDbType.VarChar, request.AccountGroup),
SqlHelperExtension.CreateInParam("@AccountGroupDescription", SqlDbType.VarChar, request.AccountGroupDescription),
SqlHelperExtension.CreateInParam("@AccountGroup", SqlDbType.NVarChar, request.AccountGroup),
SqlHelperExtension.CreateInParam("@AccountGroupDescription", SqlDbType.NVarChar, request.AccountGroupDescription),
SqlHelperExtension.CreateInParam("@CompanyCode", SqlDbType.VarChar, request.CompanyCode),
SqlHelperExtension.CreateInParam("@CompanyCodeDescription", SqlDbType.VarChar, request.CompanyCodeDescription),
SqlHelperExtension.CreateInParam("@CompanyCode", SqlDbType.NVarChar, request.CompanyCode),
SqlHelperExtension.CreateInParam("@CompanyCodeDescription", SqlDbType.NVarChar, request.CompanyCodeDescription),
SqlHelperExtension.CreateInParam("@SalesOrganization", SqlDbType.VarChar, request.SalesOrganization),
SqlHelperExtension.CreateInParam("@SalesOrganizationDescription", SqlDbType.VarChar, request.SalesOrganizationDescription),
SqlHelperExtension.CreateInParam("@SalesOrganization", SqlDbType.NVarChar, request.SalesOrganization),
SqlHelperExtension.CreateInParam("@SalesOrganizationDescription", SqlDbType.NVarChar, request.SalesOrganizationDescription),
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.VarChar, request.DistributionChannel),
SqlHelperExtension.CreateInParam("@DistributionChannelDescription", SqlDbType.VarChar, request.DistributionChannelDescription),
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
SqlHelperExtension.CreateInParam("@DistributionChannelDescription", SqlDbType.NVarChar, request.DistributionChannelDescription),
SqlHelperExtension.CreateInParam("@Division", SqlDbType.VarChar, request.Division),
SqlHelperExtension.CreateInParam("@DivisionDescription", SqlDbType.VarChar, request.DivisionDescription),
SqlHelperExtension.CreateInParam("@Division", SqlDbType.NVarChar, request.Division),
SqlHelperExtension.CreateInParam("@DivisionDescription", SqlDbType.NVarChar, request.DivisionDescription),
SqlHelperExtension.CreateInParam("@MobileNumber", SqlDbType.VarChar, request.MobileNumber),
SqlHelperExtension.CreateInParam("@EmailAddress", SqlDbType.VarChar, request.EmailAddress),
SqlHelperExtension.CreateInParam("@MobileNumber", SqlDbType.NVarChar, request.MobileNumber),
SqlHelperExtension.CreateInParam("@EmailAddress", SqlDbType.NVarChar, request.EmailAddress),
SqlHelperExtension.CreateInParam("@BusinessTaxNumber", SqlDbType.VarChar, request.BusinessTaxNumber),
SqlHelperExtension.CreateInParam("@BusinessTaxNumber", SqlDbType.NVarChar, request.BusinessTaxNumber),
SqlHelperExtension.CreateInParam("@CreditLimit", SqlDbType.Decimal, request.CreditLimit),
SqlHelperExtension.CreateInParam("@SalesOffice", SqlDbType.VarChar, request.SalesOffice),
SqlHelperExtension.CreateInParam("@SalesOfficeDescription", SqlDbType.VarChar, request.SalesOfficeDescription),
SqlHelperExtension.CreateInParam("@SalesGroup", SqlDbType.NVarChar, request.SalesGroup),
SqlHelperExtension.CreateInParam("@SalesGroupDescription", SqlDbType.NVarChar, request.SalesGroupDescription),
SqlHelperExtension.CreateInParam("@SalesGroup", SqlDbType.VarChar, request.SalesGroup),
SqlHelperExtension.CreateInParam("@CustomerGroup", SqlDbType.VarChar, request.CustomerGroup),
SqlHelperExtension.CreateInParam("@CustomerGroup", SqlDbType.NVarChar, request.CustomerGroup),
SqlHelperExtension.CreateInParam("@CustomerGroupDescription", SqlDbType.NVarChar, request.CustomerGroupDescription),
SqlHelperExtension.CreateInParam("@Status", SqlDbType.VarChar, request.Status),
SqlHelperExtension.CreateInParam("@PaymentTerms", SqlDbType.VarChar, request.PaymentTerms),
SqlHelperExtension.CreateInParam("@CustomerPriceGroup", SqlDbType.NVarChar, request.CustomerPriceGroup),
SqlHelperExtension.CreateInParam("@CustomerPriceGroupDescription", SqlDbType.NVarChar, request.CustomerPriceGroupDescription),
SqlHelperExtension.CreateInParam("@SearchTerm", SqlDbType.VarChar, request.SearchTerm),
SqlHelperExtension.CreateInParam("@StatusCode", SqlDbType.NChar, request.StatusCode),
SqlHelperExtension.CreateInParam("@StatusDescription", SqlDbType.NVarChar, request.StatusDescription),
SqlHelperExtension.CreateInParam("@Region", SqlDbType.VarChar, request.Region),
SqlHelperExtension.CreateInParam("@RegionName", SqlDbType.VarChar, request.RegionName),
SqlHelperExtension.CreateInParam("@PaymentTerms", SqlDbType.NVarChar, request.PaymentTerms),
SqlHelperExtension.CreateInParam("@PaymentTermsDescription", SqlDbType.NVarChar, request.PaymentTermsDescription),
SqlHelperExtension.CreateInParam("@Area", SqlDbType.VarChar, request.Area),
SqlHelperExtension.CreateInParam("@AreaName", SqlDbType.VarChar, request.AreaName),
SqlHelperExtension.CreateInParam("@SearchTerm", SqlDbType.NVarChar, request.SearchTerm),
SqlHelperExtension.CreateInParam("@SalesUnit", SqlDbType.VarChar, request.SalesUnit),
SqlHelperExtension.CreateInParam("@SalesUnitName", SqlDbType.VarChar, request.SalesUnitName),
SqlHelperExtension.CreateInParam("@AreaRegion", SqlDbType.NVarChar, request.AreaRegion),
SqlHelperExtension.CreateInParam("@AreaRegionDescription", SqlDbType.NVarChar, request.AreaRegionDescription),
SqlHelperExtension.CreateInParam("@Territory", SqlDbType.VarChar, request.Territory),
SqlHelperExtension.CreateInParam("@TerritoryName", SqlDbType.VarChar, request.TerritoryName),
SqlHelperExtension.CreateInParam("@SalesUnitAreaAV", SqlDbType.NVarChar, request.SalesUnitAreaAV),
SqlHelperExtension.CreateInParam("@SalesUnitAreaAVDescription", SqlDbType.NVarChar, request.SalesUnitAreaAVDescription),
SqlHelperExtension.CreateInParam("@Plant", SqlDbType.VarChar, request.Plant),
SqlHelperExtension.CreateInParam("@PlantName", SqlDbType.VarChar, request.PlantName)
SqlHelperExtension.CreateInParam("@Territory", SqlDbType.NVarChar, request.Territory),
SqlHelperExtension.CreateInParam("@TerritoryName", SqlDbType.NVarChar, request.TerritoryName),
SqlHelperExtension.CreateInParam("@Plant", SqlDbType.NVarChar, request.Plant),
SqlHelperExtension.CreateInParam("@PlantName", SqlDbType.NVarChar, request.PlantName)
];
_ = tc.ExecuteNonQuerySp(spName: "dbo.CreateCustomer", parameterValues: p);
returnValue = true;
}
catch (Exception e)
catch (Exception)
{
throw;
}
@ -378,7 +371,7 @@ public class IntegrationService : IIntegrationService
return returnValue;
}
public bool UpdateCustomer(TransactionContext tc,int customerId, CustomerIntegrationRequest request)
private bool UpdateCustomer(TransactionContext tc, CustomerIntegrationRequest request)
{
bool returnValue = false;
@ -386,70 +379,384 @@ public class IntegrationService : IIntegrationService
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam("@CustomerId", SqlDbType.Int,customerId),
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.VarChar, request.CustomerNumber),
SqlHelperExtension.CreateInParam("@CompanyCode", SqlDbType.VarChar, request.CompanyCode),
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, request.CustomerNumber),
SqlHelperExtension.CreateInParam("@CustomerName", SqlDbType.NVarChar, request.CustomerName),
SqlHelperExtension.CreateInParam("@CustomerName", SqlDbType.VarChar, request.CustomerName),
SqlHelperExtension.CreateInParam("@AccountGroup", SqlDbType.VarChar, request.AccountGroup),
SqlHelperExtension.CreateInParam("@AccountGroupDescription", SqlDbType.VarChar, request.AccountGroupDescription),
SqlHelperExtension.CreateInParam("@AccountGroup", SqlDbType.NVarChar, request.AccountGroup),
SqlHelperExtension.CreateInParam("@AccountGroupDescription", SqlDbType.NVarChar, request.AccountGroupDescription),
SqlHelperExtension.CreateInParam("@CompanyCodeDescription", SqlDbType.VarChar, request.CompanyCodeDescription),
SqlHelperExtension.CreateInParam("@CompanyCode", SqlDbType.NVarChar, request.CompanyCode),
SqlHelperExtension.CreateInParam("@CompanyCodeDescription", SqlDbType.NVarChar, request.CompanyCodeDescription),
SqlHelperExtension.CreateInParam("@SalesOrganization", SqlDbType.VarChar, request.SalesOrganization),
SqlHelperExtension.CreateInParam("@SalesOrganizationDescription", SqlDbType.VarChar, request.SalesOrganizationDescription),
SqlHelperExtension.CreateInParam("@SalesOrganization", SqlDbType.NVarChar, request.SalesOrganization),
SqlHelperExtension.CreateInParam("@SalesOrganizationDescription", SqlDbType.NVarChar, request.SalesOrganizationDescription),
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.VarChar, request.DistributionChannel),
SqlHelperExtension.CreateInParam("@DistributionChannelDescription", SqlDbType.VarChar, request.DistributionChannelDescription),
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
SqlHelperExtension.CreateInParam("@DistributionChannelDescription", SqlDbType.NVarChar, request.DistributionChannelDescription),
SqlHelperExtension.CreateInParam("@Division", SqlDbType.VarChar, request.Division),
SqlHelperExtension.CreateInParam("@DivisionDescription", SqlDbType.VarChar, request.DivisionDescription),
SqlHelperExtension.CreateInParam("@Division", SqlDbType.NVarChar, request.Division),
SqlHelperExtension.CreateInParam("@DivisionDescription", SqlDbType.NVarChar, request.DivisionDescription),
SqlHelperExtension.CreateInParam("@MobileNumber", SqlDbType.VarChar, request.MobileNumber),
SqlHelperExtension.CreateInParam("@EmailAddress", SqlDbType.VarChar, request.EmailAddress),
SqlHelperExtension.CreateInParam("@MobileNumber", SqlDbType.NVarChar, request.MobileNumber),
SqlHelperExtension.CreateInParam("@EmailAddress", SqlDbType.NVarChar, request.EmailAddress),
SqlHelperExtension.CreateInParam("@BusinessTaxNumber", SqlDbType.VarChar, request.BusinessTaxNumber),
SqlHelperExtension.CreateInParam("@BusinessTaxNumber", SqlDbType.NVarChar, request.BusinessTaxNumber),
SqlHelperExtension.CreateInParam("@CreditLimit", SqlDbType.Decimal, request.CreditLimit),
SqlHelperExtension.CreateInParam("@SalesOffice", SqlDbType.VarChar, request.SalesOffice),
SqlHelperExtension.CreateInParam("@SalesOfficeDescription", SqlDbType.VarChar, request.SalesOfficeDescription),
SqlHelperExtension.CreateInParam("@SalesGroup", SqlDbType.NVarChar, request.SalesGroup),
SqlHelperExtension.CreateInParam("@SalesGroupDescription", SqlDbType.NVarChar, request.SalesGroupDescription),
SqlHelperExtension.CreateInParam("@SalesGroup", SqlDbType.VarChar, request.SalesGroup),
SqlHelperExtension.CreateInParam("@CustomerGroup", SqlDbType.VarChar, request.CustomerGroup),
SqlHelperExtension.CreateInParam("@CustomerGroup", SqlDbType.NVarChar, request.CustomerGroup),
SqlHelperExtension.CreateInParam("@CustomerGroupDescription", SqlDbType.NVarChar, request.CustomerGroupDescription),
SqlHelperExtension.CreateInParam("@Status", SqlDbType.VarChar, request.Status),
SqlHelperExtension.CreateInParam("@PaymentTerms", SqlDbType.VarChar, request.PaymentTerms),
SqlHelperExtension.CreateInParam("@CustomerPriceGroup", SqlDbType.NVarChar, request.CustomerPriceGroup),
SqlHelperExtension.CreateInParam("@CustomerPriceGroupDescription", SqlDbType.NVarChar, request.CustomerPriceGroupDescription),
SqlHelperExtension.CreateInParam("@SearchTerm", SqlDbType.VarChar, request.SearchTerm),
SqlHelperExtension.CreateInParam("@StatusCode", SqlDbType.NChar, request.StatusCode),
SqlHelperExtension.CreateInParam("@StatusDescription", SqlDbType.NVarChar, request.StatusDescription),
SqlHelperExtension.CreateInParam("@Region", SqlDbType.VarChar, request.Region),
SqlHelperExtension.CreateInParam("@RegionName", SqlDbType.VarChar, request.RegionName),
SqlHelperExtension.CreateInParam("@PaymentTerms", SqlDbType.NVarChar, request.PaymentTerms),
SqlHelperExtension.CreateInParam("@PaymentTermsDescription", SqlDbType.NVarChar, request.PaymentTermsDescription),
SqlHelperExtension.CreateInParam("@Area", SqlDbType.VarChar, request.Area),
SqlHelperExtension.CreateInParam("@AreaName", SqlDbType.VarChar, request.AreaName),
SqlHelperExtension.CreateInParam("@SearchTerm", SqlDbType.NVarChar, request.SearchTerm),
SqlHelperExtension.CreateInParam("@SalesUnit", SqlDbType.VarChar, request.SalesUnit),
SqlHelperExtension.CreateInParam("@SalesUnitName", SqlDbType.VarChar, request.SalesUnitName),
SqlHelperExtension.CreateInParam("@AreaRegion", SqlDbType.NVarChar, request.AreaRegion),
SqlHelperExtension.CreateInParam("@AreaRegionDescription", SqlDbType.NVarChar, request.AreaRegionDescription),
SqlHelperExtension.CreateInParam("@Territory", SqlDbType.VarChar, request.Territory),
SqlHelperExtension.CreateInParam("@TerritoryName", SqlDbType.VarChar, request.TerritoryName),
SqlHelperExtension.CreateInParam("@SalesUnitAreaAV", SqlDbType.NVarChar, request.SalesUnitAreaAV),
SqlHelperExtension.CreateInParam("@SalesUnitAreaAVDescription", SqlDbType.NVarChar, request.SalesUnitAreaAVDescription),
SqlHelperExtension.CreateInParam("@Plant", SqlDbType.VarChar, request.Plant),
SqlHelperExtension.CreateInParam("@PlantName", SqlDbType.VarChar, request.PlantName)
SqlHelperExtension.CreateInParam("@Territory", SqlDbType.NVarChar, request.Territory),
SqlHelperExtension.CreateInParam("@TerritoryName", SqlDbType.NVarChar, request.TerritoryName),
SqlHelperExtension.CreateInParam("@Plant", SqlDbType.NVarChar, request.Plant),
SqlHelperExtension.CreateInParam("@PlantName", SqlDbType.NVarChar, request.PlantName)
];
_ = tc.ExecuteNonQuerySp(
spName: "dbo.UpdateCustomerById",
parameterValues: p
);
_ = tc.ExecuteNonQuerySp(spName: "dbo.UpdateCustomer", parameterValues: p);
returnValue = true;
}
catch (Exception e)
catch (Exception)
{
throw new InvalidOperationException(e.Message, e);
throw;
}
return returnValue;
}
#endregion
#region Employee Private Functions
private async Task<EmployeeIntegrationResponse> GetEmployeeBySalesOrgAsync(TransactionContext tc, EmployeeIntegrationByComapanyRequest request)
{
EmployeeIntegrationResponse response = new EmployeeIntegrationResponse();
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorCode", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorCode),
SqlHelperExtension.CreateInParam(pName: "@CompanyCode", pType: SqlDbType.NVarChar, pValue: request.CompanyCode)
];
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetEmployeeByVendorCode", parameterValues: p))
{
if (dr.Read())
{
response = new EmployeeIntegrationResponse()
{
EmployeeId = dr.GetInt32(0),
EmployeeVendorCode = dr.GetString(1),
EmployeeVendorName = dr.GetString(2),
Designation = dr.GetString(3),
DesignationDescription = dr.GetString(4),
MobileNo = dr.GetString(5),
Mail = dr.GetString(6),
CompanyCode = dr.GetString(7),
CompanyName = dr.GetString(8),
SalesOrg = dr.GetString(9),
SalesOrgDescription = dr.GetString(10),
DistChannel = dr.GetString(11),
DistChannelDescription = dr.GetString(12),
Division = dr.GetString(13),
DivisionDescription = dr.GetString(14),
RegionAreaCode = dr.GetString(15),
RegionAreaDescription = dr.GetString(16),
AreaAVSalesUnitCode = dr.GetString(17),
AreaAVSalesUnitDescription = dr.GetString(18),
Territory = dr.GetString(19),
TerritoryDescription = dr.GetString(20),
Plant = dr.GetString(21),
PlantDescription = dr.GetString(22),
Status = dr.GetString(23),
StatusDescription = dr.GetString(24)
};
}
dr.Close();
}
}
catch (Exception ex)
{
throw DBCustomError.GenerateCustomError(ex);
}
return response;
}
private bool InsertEmployee(TransactionContext tc, EmployeeIntegrationRequest request)
{
bool returnValue = false;
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorCode", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorCode),
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorName", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorName),
SqlHelperExtension.CreateInParam(pName: "@Designation", pType: SqlDbType.NVarChar, pValue: request.Designation),
SqlHelperExtension.CreateInParam(pName: "@DesignationDescription", pType: SqlDbType.NVarChar, pValue: request.DesignationDescription),
SqlHelperExtension.CreateInParam(pName: "@MobileNo", pType: SqlDbType.NVarChar, pValue: request.MobileNo),
SqlHelperExtension.CreateInParam(pName: "@Mail", pType: SqlDbType.NVarChar, pValue: request.Mail),
SqlHelperExtension.CreateInParam(pName: "@CompanyCode", pType: SqlDbType.NVarChar, pValue: request.CompanyCode),
SqlHelperExtension.CreateInParam(pName: "@CompanyName", pType: SqlDbType.NVarChar, pValue: request.CompanyName),
SqlHelperExtension.CreateInParam(pName: "@SalesOrg", pType: SqlDbType.NVarChar, pValue: request.SalesOrg),
SqlHelperExtension.CreateInParam(pName: "@SalesOrgDescription", pType: SqlDbType.NVarChar, pValue: request.SalesOrgDescription),
SqlHelperExtension.CreateInParam(pName: "@DistChannel", pType: SqlDbType.NVarChar, pValue: request.DistChannel),
SqlHelperExtension.CreateInParam(pName: "@DistChannelDescription", pType: SqlDbType.NVarChar, pValue: request.DistChannelDescription),
SqlHelperExtension.CreateInParam(pName: "@Division", pType: SqlDbType.NVarChar, pValue: request.Division),
SqlHelperExtension.CreateInParam(pName: "@DivisionDescription", pType: SqlDbType.NVarChar, pValue: request.DivisionDescription),
SqlHelperExtension.CreateInParam(pName: "@RegionAreaCode", pType: SqlDbType.NVarChar, pValue: request.RegionAreaCode),
SqlHelperExtension.CreateInParam(pName: "@RegionAreaDescription", pType: SqlDbType.NVarChar, pValue: request.RegionAreaDescription),
SqlHelperExtension.CreateInParam(pName: "@AreaAVSalesUnitCode", pType: SqlDbType.NVarChar, pValue: request.AreaAVSalesUnitCode),
SqlHelperExtension.CreateInParam(pName: "@AreaAVSalesUnitDescription", pType: SqlDbType.NVarChar, pValue: request.AreaAVSalesUnitDescription),
SqlHelperExtension.CreateInParam(pName: "@Territory", pType: SqlDbType.NVarChar, pValue: request.Territory),
SqlHelperExtension.CreateInParam(pName: "@TerritoryDescription", pType: SqlDbType.NVarChar, pValue: request.TerritoryDescription),
SqlHelperExtension.CreateInParam(pName: "@Plant", pType: SqlDbType.NVarChar, pValue: request.Plant),
SqlHelperExtension.CreateInParam(pName: "@PlantDescription", pType: SqlDbType.NVarChar, pValue: request.PlantDescription),
SqlHelperExtension.CreateInParam(pName: "@Status", pType: SqlDbType.NChar, pValue: request.Status),
SqlHelperExtension.CreateInParam(pName: "@StatusDescription", pType: SqlDbType.NVarChar, pValue: request.StatusDescription)
];
_ = tc.ExecuteNonQuerySp(spName: "dbo.InsertEmployee", parameterValues: p);
returnValue = true;
}
catch (Exception)
{
throw;
}
return returnValue;
}
private bool UpdateEmployee(TransactionContext tc, EmployeeIntegrationRequest request)
{
bool returnValue = false;
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorCode", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorCode),
SqlHelperExtension.CreateInParam(pName: "@CompanyCode", pType: SqlDbType.NVarChar, pValue: request.CompanyCode),
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorName", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorName),
SqlHelperExtension.CreateInParam(pName: "@Designation", pType: SqlDbType.NVarChar, pValue: request.Designation),
SqlHelperExtension.CreateInParam(pName: "@DesignationDescription", pType: SqlDbType.NVarChar, pValue: request.DesignationDescription),
SqlHelperExtension.CreateInParam(pName: "@MobileNo", pType: SqlDbType.NVarChar, pValue: request.MobileNo),
SqlHelperExtension.CreateInParam(pName: "@Mail", pType: SqlDbType.NVarChar, pValue: request.Mail),
SqlHelperExtension.CreateInParam(pName: "@CompanyName", pType: SqlDbType.NVarChar, pValue: request.CompanyName),
SqlHelperExtension.CreateInParam(pName: "@SalesOrg", pType: SqlDbType.NVarChar, pValue: request.SalesOrg),
SqlHelperExtension.CreateInParam(pName: "@SalesOrgDescription", pType: SqlDbType.NVarChar, pValue: request.SalesOrgDescription),
SqlHelperExtension.CreateInParam(pName: "@DistChannel", pType: SqlDbType.NVarChar, pValue: request.DistChannel),
SqlHelperExtension.CreateInParam(pName: "@DistChannelDescription", pType: SqlDbType.NVarChar, pValue: request.DistChannelDescription),
SqlHelperExtension.CreateInParam(pName: "@Division", pType: SqlDbType.NVarChar, pValue: request.Division),
SqlHelperExtension.CreateInParam(pName: "@DivisionDescription", pType: SqlDbType.NVarChar, pValue: request.DivisionDescription),
SqlHelperExtension.CreateInParam(pName: "@RegionAreaCode", pType: SqlDbType.NVarChar, pValue: request.RegionAreaCode),
SqlHelperExtension.CreateInParam(pName: "@RegionAreaDescription", pType: SqlDbType.NVarChar, pValue: request.RegionAreaDescription),
SqlHelperExtension.CreateInParam(pName: "@AreaAVSalesUnitCode", pType: SqlDbType.NVarChar, pValue: request.AreaAVSalesUnitCode),
SqlHelperExtension.CreateInParam(pName: "@AreaAVSalesUnitDescription", pType: SqlDbType.NVarChar, pValue: request.AreaAVSalesUnitDescription),
SqlHelperExtension.CreateInParam(pName: "@Territory", pType: SqlDbType.NVarChar, pValue: request.Territory),
SqlHelperExtension.CreateInParam(pName: "@TerritoryDescription", pType: SqlDbType.NVarChar, pValue: request.TerritoryDescription),
SqlHelperExtension.CreateInParam(pName: "@Plant", pType: SqlDbType.NVarChar, pValue: request.Plant),
SqlHelperExtension.CreateInParam(pName: "@PlantDescription", pType: SqlDbType.NVarChar, pValue: request.PlantDescription),
SqlHelperExtension.CreateInParam(pName: "@Status", pType: SqlDbType.NChar, pValue: request.Status),
SqlHelperExtension.CreateInParam(pName: "@StatusDescription", pType: SqlDbType.NVarChar, pValue: request.StatusDescription)
];
_ = tc.ExecuteNonQuerySp(spName: "dbo.UpdateEmployee", parameterValues: p);
returnValue = true;
}
catch (Exception)
{
throw;
}
return returnValue;
}
#endregion
#region Meterial Private Functions
private async Task<MaterialIntegrationResponse> GetMaterialByCodeAsync(TransactionContext tc, GetMaterialByCodeRequest request)
{
MaterialIntegrationResponse response = new MaterialIntegrationResponse();
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@MaterialCode", pType: SqlDbType.NVarChar, pValue: request.MaterialCode)
];
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetMaterialByMaterialCode", parameterValues: p))
{
if (dr.Read())
{
response = new MaterialIntegrationResponse()
{
MeterialId = dr.GetInt32(0),
MaterialType = dr.GetString(1),
MaterialTypeDescription = dr.GetString(2),
MaterialCode = dr.GetString(3),
MaterialDescription = dr.GetString(4),
MaterialGroupCode = dr.GetString(5),
MaterialGroupDescription = dr.GetString(6),
BaseUnitOfMeasure = dr.GetString(7),
SalesUnitOfMeasure = dr.GetString(8),
UnitConversionWithBaseUoM = dr.GetDecimal(9),
PlantCode = dr.GetString(10),
PlantDescription = dr.GetString(11),
StorageLocationCode = dr.GetString(12),
StorageLocationDescription = dr.GetString(13),
SalesOrganization = dr.GetString(14),
SalesOrganizationDescription = dr.GetString(15),
};
}
dr.Close();
}
}
catch (Exception ex)
{
throw DBCustomError.GenerateCustomError(ex);
}
return response;
}
private bool CreateMaterial(TransactionContext tc, MaterialIntegrationRequest request)
{
bool returnValue = false;
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam("@MaterialType", SqlDbType.NVarChar, request.MaterialType),
SqlHelperExtension.CreateInParam("@MaterialTypeDescription", SqlDbType.NVarChar, request.MaterialTypeDescription),
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
SqlHelperExtension.CreateInParam("@MaterialDescription", SqlDbType.NVarChar, request.MaterialDescription),
SqlHelperExtension.CreateInParam("@MaterialGroupCode", SqlDbType.NVarChar, request.MaterialGroupCode),
SqlHelperExtension.CreateInParam("@MaterialGroupDescription", SqlDbType.NVarChar, request.MaterialGroupDescription),
SqlHelperExtension.CreateInParam("@BaseUnitOfMeasure", SqlDbType.NVarChar, request.BaseUnitOfMeasure),
SqlHelperExtension.CreateInParam("@SalesUnitOfMeasure", SqlDbType.NVarChar, request.SalesUnitOfMeasure),
SqlHelperExtension.CreateInParam("@UnitConversionWithBaseUoM", SqlDbType.Decimal, request.UnitConversionWithBaseUoM),
SqlHelperExtension.CreateInParam("@PlantCode", SqlDbType.NVarChar, request.PlantCode),
SqlHelperExtension.CreateInParam("@PlantDescription", SqlDbType.NVarChar, request.PlantDescription),
SqlHelperExtension.CreateInParam("@StorageLocationCode", SqlDbType.NVarChar, request.StorageLocationCode),
SqlHelperExtension.CreateInParam("@StorageLocationDescription", SqlDbType.NVarChar, request.StorageLocationDescription),
SqlHelperExtension.CreateInParam("@SalesOrganization", SqlDbType.NVarChar, request.SalesOrganization),
SqlHelperExtension.CreateInParam("@SalesOrganizationDescription", SqlDbType.NVarChar, request.SalesOrganizationDescription)
];
_ = tc.ExecuteNonQuerySp(spName: "dbo.CreateMaterial", parameterValues: p);
returnValue = true;
}
catch (Exception)
{
throw;
}
return returnValue;
}
private bool UpdateMaterial(TransactionContext tc, MaterialIntegrationRequest request)
{
bool returnValue = false;
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam("@MaterialType", SqlDbType.NVarChar, request.MaterialType),
SqlHelperExtension.CreateInParam("@MaterialTypeDescription", SqlDbType.NVarChar, request.MaterialTypeDescription),
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
SqlHelperExtension.CreateInParam("@MaterialDescription", SqlDbType.NVarChar, request.MaterialDescription),
SqlHelperExtension.CreateInParam("@MaterialGroupCode", SqlDbType.NVarChar, request.MaterialGroupCode),
SqlHelperExtension.CreateInParam("@MaterialGroupDescription", SqlDbType.NVarChar, request.MaterialGroupDescription),
SqlHelperExtension.CreateInParam("@BaseUnitOfMeasure", SqlDbType.NVarChar, request.BaseUnitOfMeasure),
SqlHelperExtension.CreateInParam("@SalesUnitOfMeasure", SqlDbType.NVarChar, request.SalesUnitOfMeasure),
SqlHelperExtension.CreateInParam("@UnitConversionWithBaseUoM", SqlDbType.Decimal, request.UnitConversionWithBaseUoM),
SqlHelperExtension.CreateInParam("@PlantCode", SqlDbType.NVarChar, request.PlantCode),
SqlHelperExtension.CreateInParam("@PlantDescription", SqlDbType.NVarChar, request.PlantDescription),
SqlHelperExtension.CreateInParam("@StorageLocationCode", SqlDbType.NVarChar, request.StorageLocationCode),
SqlHelperExtension.CreateInParam("@StorageLocationDescription", SqlDbType.NVarChar, request.StorageLocationDescription),
SqlHelperExtension.CreateInParam("@SalesOrganization", SqlDbType.NVarChar, request.SalesOrganization),
SqlHelperExtension.CreateInParam("@SalesOrganizationDescription", SqlDbType.NVarChar, request.SalesOrganizationDescription)
];
_ = tc.ExecuteNonQuerySp(spName: "dbo.UpdateMaterial", parameterValues: p);
returnValue = true;
}
catch (Exception)
{
throw;
}
return returnValue;
}
#endregion
}

View File

@ -37,7 +37,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
/// <remarks>
/// </remarks>
/// <param name="request"></param>
/// <returns>if created return 201 or if updated return 204 true</returns>
/// <returns>if created return 201 or if updated return 200 true</returns>
[HttpPost("Customers")]
[IgnoreAntiforgeryToken]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IntegrationLoginResponse))]
@ -76,8 +76,8 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
/// <remarks>
/// </remarks>
/// <param name="request"></param>
/// <returns>if created return 201 or if updated return 204 true</returns>
[HttpGet("Employees")]
/// <returns>if created return 201 or if updated return 200 true</returns>
[HttpPost("Employees")]
[IgnoreAntiforgeryToken]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(EmployeeIntegrationReqResponse))]
public async Task<IActionResult> UpsertEmployee(EmployeeIntegrationRequest request)
@ -88,20 +88,61 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
response = await _integrationService.UpsertEmployeeAsync(request);
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.CompanyCode}");
response.ReturnStatus = StatusCodes.Status201Created;
return StatusCode(StatusCodes.Status201Created, response);
}
else
{
response.ReturnMessage.Add($"Employee Updated Successfully for EmployeeVendorName :{request.EmployeeVendorName} & SalesOrgCode:{request.SalesOrgCode}");
response.ReturnStatus = StatusCodes.Status204NoContent;
return StatusCode(StatusCodes.Status204NoContent, response);
response.ReturnMessage.Add($"Employee Updated Successfully for EmployeeVendorName :{request.EmployeeVendorName} & SalesOrgCode:{request.CompanyCode}");
response.ReturnStatus = StatusCodes.Status200OK;
return StatusCode(StatusCodes.Status200OK, response);
}
}
catch (Exception ex)
{
string msg = $"Exception Occur in Employee Operation {request?.EmployeeVendorName}~{request?.SalesOrgCode}";
string msg = $"Exception Occur in Employee Operation {request?.EmployeeVendorName}~{request?.CompanyCode}";
_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);
}
}
/// <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("Materials")]
[IgnoreAntiforgeryToken]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(MaterialIntegrationReqResponse))]
[ProducesResponseType(StatusCodes.Status201Created, Type = typeof(MaterialIntegrationReqResponse))]
public async Task<IActionResult> UpsertMeterial(MaterialIntegrationRequest request)
{
MaterialIntegrationReqResponse response = new MaterialIntegrationReqResponse();
try
{
response = await _integrationService.UpsertMaterialAsync(request);
if (!response.IsUpdated)
{
response.ReturnMessage.Add($"Material Created Successfully for MaterialCode :{request.MaterialCode} ");
response.ReturnStatus = StatusCodes.Status201Created;
return StatusCode(StatusCodes.Status201Created, response);
}
else
{
response.ReturnMessage.Add($"Material Updated Successfully for MaterialCode :{request.MaterialCode} ");
response.ReturnStatus = StatusCodes.Status200OK;
return StatusCode(StatusCodes.Status200OK, response);
}
}
catch (Exception ex)
{
string msg = $"Exception Occur in Material Operation {request?.MaterialCode}";
_logger.LogError(exception: ex, msg);
response.ReturnStatus = StatusCodes.Status500InternalServerError;
response.ReturnMessage.Add(ex.InnerException != null ? ex.InnerException.Message : ex.Message);