update customer,brand, material endpoint request

This commit is contained in:
dibakor 2026-07-08 14:51:20 +06:00
parent 8c6df3cd19
commit bdcda8c1fb
6 changed files with 91 additions and 86 deletions

View File

@ -1,4 +1,5 @@
 
using DocumentFormat.OpenXml.Wordprocessing;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
@ -12,18 +13,43 @@ public class GetMarketHeirarchyByEmpRequest
public class GetBrandsRequest : PagedRequest public class GetBrandsRequest : PagedRequest
{ {
[StringLength(6, MinimumLength = 1, ErrorMessage = "Brand code must be between 1 and 6 characters.")]
public string? BrandCode { get; set; } public string? BrandCode { get; set; }
[StringLength(10, MinimumLength = 1, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
public string? SalesOrgCode { get; set; }
[StringLength(10, MinimumLength = 1, ErrorMessage = "Employee number must be between 1 and 10 characters.")]
public string? EmployeeNumber { get; set; }
} }
public class GetMaterialsRequest : PagedRequest public class GetMaterialsRequest : PagedRequest
{ {
[StringLength(10, MinimumLength = 1, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
public string SalesOrgCode { get; set; }
[StringLength(6, MinimumLength = 1, ErrorMessage = "Brand code must be between 1 and 6 characters.")]
public string? BrandCode { get; set; } public string? BrandCode { get; set; }
[StringLength(10, MinimumLength = 1, ErrorMessage = "Material Code must be between 1 and 10 characters.")]
public string? MaterialCode { get; set; } public string? MaterialCode { get; set; }
[StringLength(10, MinimumLength = 1, ErrorMessage = "Employee number must be between 1 and 10 characters.")]
public string? EmployeeNumber { get; set; }
} }
public class GetCustomersRequest : PagedRequest public class GetCustomersRequest : PagedRequest
{ {
[StringLength(10, MinimumLength = 1, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
public string SalesOrgCode { get; set; }
[StringLength(5, MinimumLength = 1, ErrorMessage = "Teritory Code must be between 1 and 5 characters.")]
public string? TeritoryCode { get; set; } public string? TeritoryCode { get; set; }
[StringLength(10, MinimumLength = 1, ErrorMessage = "Customer Code must be between 1 and 10 characters.")]
public string? CustomerCode { get; set; } public string? CustomerCode { get; set; }
[StringLength(10, MinimumLength = 1, ErrorMessage = "Employee number must be between 1 and 10 characters.")]
public string? EmployeeNumber { get; set; }
} }

View File

@ -27,31 +27,31 @@ public class MarketHeirarchyByEmpResponse
public class EmpCompanyResponse public class EmpCompanyResponse
{ {
public string Code { get; set; } public string CompanyCode { get; set; }
public string Name { get; set; } public string CompanyName { get; set; }
} }
public class SalesOrgResponse public class SalesOrgResponse
{ {
public string CompanyCode { get; set; } public string CompanyCode { get; set; }
public string Code { get; set; } public string SalesOrgCode { get; set; }
public string Name { get; set; } public string SalesOrgName { get; set; }
} }
public class DistibutionChannleResponse public class DistibutionChannleResponse
{ {
public string CompanyCode { get; set; } public string CompanyCode { get; set; }
public string SalesOrgCode { get; set; } public string SalesOrgCode { get; set; }
public string Code { get; set; } public string DistributorChannelCode { get; set; }
public string Name { get; set; } public string DistributorChannelName { get; set; }
} }
public class RegionResponse public class RegionResponse
{ {
public string CompanyCode { get; set; } public string CompanyCode { get; set; }
public string SalesOrgCode { get; set; } public string SalesOrgCode { get; set; }
public string Code { get; set; } public string RegionCode { get; set; }
public string Name { get; set; } public string RegionName { get; set; }
} }
public class AreaResponse public class AreaResponse
@ -59,8 +59,8 @@ public class AreaResponse
public string CompanyCode { get; set; } public string CompanyCode { get; set; }
public string SalesOrgCode { get; set; } public string SalesOrgCode { get; set; }
public string RegionCode { get; set; } public string RegionCode { get; set; }
public string Code { get; set; } public string AreaCode { get; set; }
public string Name { get; set; } public string AreaName { get; set; }
} }
public class TeritoryResponse public class TeritoryResponse
@ -69,16 +69,16 @@ public class TeritoryResponse
public string SalesOrgCode { get; set; } public string SalesOrgCode { get; set; }
public string RegionCode { get; set; } public string RegionCode { get; set; }
public string AreaCode { get; set; } public string AreaCode { get; set; }
public string Code { get; set; } public string TeritoryCode { get; set; }
public string Name { get; set; } public string TeritoryName { get; set; }
} }
public class PlantResponse public class PlantResponse
{ {
public string CompanyCode { get; set; } public string CompanyCode { get; set; }
public string SalesOrgCode { get; set; } public string SalesOrgCode { get; set; }
public string Code { get; set; } public string PlantCode { get; set; }
public string Name { get; set; } public string PlantName { get; set; }
} }
@ -92,8 +92,8 @@ public class GetBrandResponse
public class GetMaterialResponse public class GetMaterialResponse
{ {
public string Name { get; set; } public string MaterialName { get; set; }
public string Code { get; set; } public string MaterialCode { get; set; }
public string TypeCode { get; set; } public string TypeCode { get; set; }
public string TypeName { get; set; } public string TypeName { get; set; }
public string GroupCode { get; set; } public string GroupCode { get; set; }
@ -110,8 +110,8 @@ public class GetMaterialResponse
public class GetCustomerResponse public class GetCustomerResponse
{ {
public string Code { get; set; } public string CustomerCode { get; set; }
public string Name { get; set; } public string CustomerName { get; set; }
public string AccountGroupCode { get; set; } public string AccountGroupCode { get; set; }
public string AccountGroupDescription { get; set; } public string AccountGroupDescription { get; set; }
public string DistributionChannelCode { get; set; } public string DistributionChannelCode { get; set; }
@ -128,6 +128,7 @@ public class GetCustomerResponse
public string CustomerPriceGroupCode { get; set; } public string CustomerPriceGroupCode { get; set; }
public string CustomerPriceGroupName { get; set; } public string CustomerPriceGroupName { get; set; }
public string PaymentTermCode { get; set; } public string PaymentTermCode { get; set; }
public string SalesOrgCode { get; set; }
public string TeritoryCode { get; set; } public string TeritoryCode { get; set; }
public string PlantCode { get; set; } public string PlantCode { get; set; }
} }

View File

@ -75,23 +75,14 @@ public class MobileMasterDataService : IMobileMasterDataService
SqlParameter[] p = SqlParameter[] p =
[ [
SqlHelperExtension.CreateInParam(pName: "@BrandCode", pType: SqlDbType.VarChar, pValue: request.BrandCode), SqlHelperExtension.CreateInParam(pName: "@BrandCode", pType: SqlDbType.VarChar, pValue: request.BrandCode),
SqlHelperExtension.CreateInParam(pName: "@SalesOrganization", pType: SqlDbType.VarChar, pValue: request.SalesOrgCode),
SqlHelperExtension.CreateInParam(pName: "@EmployeeNumber", pType: SqlDbType.VarChar, pValue: request.EmployeeNumber),
SqlHelperExtension.CreateInParam(pName: "@PageNumber", pType: SqlDbType.Int, pValue: request.PageNumber), SqlHelperExtension.CreateInParam(pName: "@PageNumber", pType: SqlDbType.Int, pValue: request.PageNumber),
SqlHelperExtension.CreateInParam(pName: "@PageSize", pType: SqlDbType.Int, pValue: request.PageSize) SqlHelperExtension.CreateInParam(pName: "@PageSize", pType: SqlDbType.Int, pValue: request.PageSize)
]; ];
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetBrandsPaginated", parameterValues: p)) using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetBrandsPaginated", parameterValues: p))
{ {
if (dr.Read())
{
response.TotalCount = dr.GetInt32(0);
response.PageNumber = request.PageNumber;
response.PageSize = request.PageSize;
}
// Second result set: paginated brand data
dr.NextResult();
while (dr.Read()) while (dr.Read())
{ {
response.Items.Add(new GetBrandResponse response.Items.Add(new GetBrandResponse
@ -102,6 +93,9 @@ public class MobileMasterDataService : IMobileMasterDataService
} }
dr.Close(); dr.Close();
response.TotalCount = response.Items.Count;
response.PageNumber = request.PageNumber;
response.PageSize = request.PageSize;
} }
tc.End(); tc.End();
} }
@ -120,7 +114,6 @@ public class MobileMasterDataService : IMobileMasterDataService
return response; return response;
} }
public async Task<PagedResult<GetMaterialResponse>> GetMaterialsAsync(GetMaterialsRequest request) public async Task<PagedResult<GetMaterialResponse>> GetMaterialsAsync(GetMaterialsRequest request)
{ {
PagedResult<GetMaterialResponse> response = new(); PagedResult<GetMaterialResponse> response = new();
@ -133,29 +126,20 @@ public class MobileMasterDataService : IMobileMasterDataService
[ [
SqlHelperExtension.CreateInParam(pName: "@BrandCode", pType: SqlDbType.VarChar, pValue: request.BrandCode), SqlHelperExtension.CreateInParam(pName: "@BrandCode", pType: SqlDbType.VarChar, pValue: request.BrandCode),
SqlHelperExtension.CreateInParam(pName: "@MaterialCode", pType: SqlDbType.VarChar, pValue: request.MaterialCode), SqlHelperExtension.CreateInParam(pName: "@MaterialCode", pType: SqlDbType.VarChar, pValue: request.MaterialCode),
SqlHelperExtension.CreateInParam(pName: "@SalesOrgCode", pType: SqlDbType.VarChar, pValue: request.SalesOrgCode),
SqlHelperExtension.CreateInParam(pName: "@EmployeeNumber", pType: SqlDbType.VarChar, pValue: request.EmployeeNumber),
SqlHelperExtension.CreateInParam(pName: "@PageNumber", pType: SqlDbType.Int, pValue: request.PageNumber), SqlHelperExtension.CreateInParam(pName: "@PageNumber", pType: SqlDbType.Int, pValue: request.PageNumber),
SqlHelperExtension.CreateInParam(pName: "@PageSize", pType: SqlDbType.Int, pValue: request.PageSize) SqlHelperExtension.CreateInParam(pName: "@PageSize", pType: SqlDbType.Int, pValue: request.PageSize)
]; ];
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetMaterialsPaginated", parameterValues: p)) using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetMaterialsPaginated", parameterValues: p))
{ {
if (dr.Read())
{
response.TotalCount = dr.GetInt32(0);
response.PageNumber = request.PageNumber;
response.PageSize = request.PageSize;
}
// Second result set: paginated brand data
dr.NextResult();
while (dr.Read()) while (dr.Read())
{ {
response.Items.Add(new GetMaterialResponse response.Items.Add(new GetMaterialResponse
{ {
Code = dr.GetString(0), MaterialCode = dr.GetString(0),
Name = dr.GetString(1), MaterialName = dr.GetString(1),
TypeCode = dr.GetString(2), TypeCode = dr.GetString(2),
TypeName = dr.GetString(3), TypeName = dr.GetString(3),
GroupCode = dr.GetString(4), GroupCode = dr.GetString(4),
@ -171,6 +155,11 @@ public class MobileMasterDataService : IMobileMasterDataService
} }
dr.Close(); dr.Close();
response.TotalCount = response.Items.Count;
response.PageNumber = request.PageNumber;
response.PageSize = request.PageSize;
} }
tc.End(); tc.End();
} }
@ -199,6 +188,8 @@ public class MobileMasterDataService : IMobileMasterDataService
{ {
SqlParameter[] p = SqlParameter[] p =
[ [
SqlHelperExtension.CreateInParam(pName: "@SalesOrgCode", pType: SqlDbType.VarChar, pValue: request.SalesOrgCode),
SqlHelperExtension.CreateInParam(pName: "@EmployeeNumber", pType: SqlDbType.VarChar, pValue: request.EmployeeNumber),
SqlHelperExtension.CreateInParam(pName: "@TeritoryCode", pType: SqlDbType.VarChar, pValue: request.TeritoryCode), SqlHelperExtension.CreateInParam(pName: "@TeritoryCode", pType: SqlDbType.VarChar, pValue: request.TeritoryCode),
SqlHelperExtension.CreateInParam(pName: "@CustomerCode", pType: SqlDbType.VarChar, pValue: request.CustomerCode), SqlHelperExtension.CreateInParam(pName: "@CustomerCode", pType: SqlDbType.VarChar, pValue: request.CustomerCode),
SqlHelperExtension.CreateInParam(pName: "@PageNumber", pType: SqlDbType.Int, pValue: request.PageNumber), SqlHelperExtension.CreateInParam(pName: "@PageNumber", pType: SqlDbType.Int, pValue: request.PageNumber),
@ -207,23 +198,12 @@ public class MobileMasterDataService : IMobileMasterDataService
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetCustomersPaginated", parameterValues: p)) using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetCustomersPaginated", parameterValues: p))
{ {
if (dr.Read())
{
response.TotalCount = dr.GetInt32(0);
response.PageNumber = request.PageNumber;
response.PageSize = request.PageSize;
}
// Second result set: paginated brand data
dr.NextResult();
while (dr.Read()) while (dr.Read())
{ {
response.Items.Add(new GetCustomerResponse response.Items.Add(new GetCustomerResponse
{ {
Code = dr.GetString(0), CustomerCode = dr.GetString(0),
Name = dr.GetString(1), CustomerName = dr.GetString(1),
AccountGroupCode = dr.GetString(2), AccountGroupCode = dr.GetString(2),
AccountGroupDescription = dr.GetString(3), AccountGroupDescription = dr.GetString(3),
DistributionChannelCode = dr.GetString(4), DistributionChannelCode = dr.GetString(4),
@ -241,11 +221,15 @@ public class MobileMasterDataService : IMobileMasterDataService
CustomerPriceGroupName = dr.GetString(16), CustomerPriceGroupName = dr.GetString(16),
PaymentTermCode = dr.GetString(17), PaymentTermCode = dr.GetString(17),
TeritoryCode = dr.GetString(18), TeritoryCode = dr.GetString(18),
PlantCode = dr.GetString(19) SalesOrgCode = dr.GetString(19),
PlantCode = dr.GetString(20)
}); });
} }
dr.Close(); dr.Close();
response.TotalCount = response.Items.Count;
response.PageNumber = request.PageNumber;
response.PageSize = request.PageSize;
} }
tc.End(); tc.End();
} }
@ -281,8 +265,8 @@ public class MobileMasterDataService : IMobileMasterDataService
{ {
response.Add(new EmpCompanyResponse response.Add(new EmpCompanyResponse
{ {
Code = dr.GetString(0), CompanyCode = dr.GetString(0),
Name = dr.GetString(1) CompanyName = dr.GetString(1)
}); });
} }
dr.Close(); dr.Close();
@ -314,8 +298,8 @@ public class MobileMasterDataService : IMobileMasterDataService
response.Add(new SalesOrgResponse response.Add(new SalesOrgResponse
{ {
CompanyCode = dr.GetString(0), CompanyCode = dr.GetString(0),
Code = dr.GetString(1), SalesOrgCode = dr.GetString(1),
Name = dr.GetString(2) SalesOrgName = dr.GetString(2)
}); });
} }
dr.Close(); dr.Close();
@ -348,8 +332,8 @@ public class MobileMasterDataService : IMobileMasterDataService
{ {
CompanyCode = dr.GetString(0), CompanyCode = dr.GetString(0),
SalesOrgCode = dr.GetString(1), SalesOrgCode = dr.GetString(1),
Code = dr.GetString(2), DistributorChannelCode = dr.GetString(2),
Name = dr.GetString(3) DistributorChannelName = dr.GetString(3)
}); });
} }
dr.Close(); dr.Close();
@ -382,8 +366,8 @@ public class MobileMasterDataService : IMobileMasterDataService
{ {
CompanyCode = dr.GetString(0), CompanyCode = dr.GetString(0),
SalesOrgCode = dr.GetString(1), SalesOrgCode = dr.GetString(1),
Code = dr.GetString(2), RegionCode = dr.GetString(2),
Name = dr.GetString(3) RegionName = dr.GetString(3)
}); });
} }
dr.Close(); dr.Close();
@ -417,8 +401,8 @@ public class MobileMasterDataService : IMobileMasterDataService
CompanyCode = dr.GetString(0), CompanyCode = dr.GetString(0),
SalesOrgCode = dr.GetString(1), SalesOrgCode = dr.GetString(1),
RegionCode = dr.GetString(2), RegionCode = dr.GetString(2),
Code = dr.GetString(3), AreaCode = dr.GetString(3),
Name = dr.GetString(4) AreaName = dr.GetString(4)
}); });
} }
dr.Close(); dr.Close();
@ -453,8 +437,8 @@ public class MobileMasterDataService : IMobileMasterDataService
SalesOrgCode = dr.GetString(1), SalesOrgCode = dr.GetString(1),
RegionCode = dr.GetString(2), RegionCode = dr.GetString(2),
AreaCode = dr.GetString(3), AreaCode = dr.GetString(3),
Code = dr.GetString(4), TeritoryCode = dr.GetString(4),
Name = dr.GetString(5) TeritoryName = dr.GetString(5)
}); });
} }
dr.Close(); dr.Close();
@ -487,8 +471,8 @@ public class MobileMasterDataService : IMobileMasterDataService
{ {
CompanyCode = dr.GetString(0), CompanyCode = dr.GetString(0),
SalesOrgCode = dr.GetString(1), SalesOrgCode = dr.GetString(1),
Code = dr.GetString(2), PlantCode = dr.GetString(2),
Name = dr.GetString(3) PlantName = dr.GetString(3)
}); });
} }
dr.Close(); dr.Close();
@ -501,5 +485,4 @@ public class MobileMasterDataService : IMobileMasterDataService
return response; return response;
} }
} }

View File

@ -406,6 +406,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Services.Systems
if (user is null) if (user is null)
{ {
tc.End(); tc.End();
response = new();
response.IsAuthorized = true; response.IsAuthorized = true;
return response; return response;
} }
@ -413,6 +414,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Services.Systems
if (!password.Equals(user.Password)) if (!password.Equals(user.Password))
{ {
tc.End(); tc.End();
response = new();
response.IsAuthorized = false; response.IsAuthorized = false;
response.LoginStatus = EnumLoginStatus.Unsuccessful; response.LoginStatus = EnumLoginStatus.Unsuccessful;
return response; return response;

View File

@ -288,6 +288,13 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers
AppChangePasswordResponse response = new(); AppChangePasswordResponse response = new();
try try
{ {
if(request.Password.Equals(request.ConfirmPassword))
{
string msg = $"You can't use your old password as your new password.";
_logger.LogError(message: msg);
return BadRequest(MobileResponseBase<AppAuthUserResponse>.Failure(msg, StatusCodes.Status400BadRequest));
}
string ipAddress = Request.HttpContext.GetIpAddress(); string ipAddress = Request.HttpContext.GetIpAddress();
response = await _service.ChangePasswordAsync(request, ipAddress); response = await _service.ChangePasswordAsync(request, ipAddress);
return Ok(MobileResponseBase<AppChangePasswordResponse>.Success(response, "Successfully Changed the Password")); return Ok(MobileResponseBase<AppChangePasswordResponse>.Success(response, "Successfully Changed the Password"));

View File

@ -4,27 +4,13 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using OnlineSalesAutoCrop.CoreAPI; using OnlineSalesAutoCrop.CoreAPI;
using OnlineSalesAutoCrop.CoreAPI.Models;
using OnlineSalesAutoCrop.CoreAPI.Models.Global; using OnlineSalesAutoCrop.CoreAPI.Models.Global;
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Common;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.MobileApp; using OnlineSalesAutoCrop.CoreAPI.Models.Requests.MobileApp;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses; using OnlineSalesAutoCrop.CoreAPI.Models.Responses;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.MobileApp; using OnlineSalesAutoCrop.CoreAPI.Models.Responses.MobileApp;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Systems;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Auth;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.MobileApp; using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.MobileApp;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Systems;
using System; using System;
using System.DirectoryServices;
using System.IdentityModel.Tokens.Jwt;
using System.Runtime.Versioning;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace OnlineSalesAutoCrop.CoreAPI.Controllers namespace OnlineSalesAutoCrop.CoreAPI.Controllers