complete foc and foc material endpoints
This commit is contained in:
parent
a7467fbb39
commit
8bf59da423
|
|
@ -110,8 +110,6 @@ public class GetDiscountRequest : PagedRequest
|
||||||
|
|
||||||
[StringLength(10, MinimumLength = 1, ErrorMessage = "Discount Code must be between 1 and 10 characters.")]
|
[StringLength(10, MinimumLength = 1, ErrorMessage = "Discount Code must be between 1 and 10 characters.")]
|
||||||
public string? DiscountCode { get; set; }
|
public string? DiscountCode { get; set; }
|
||||||
|
|
||||||
public bool IsIncludeChild { get; set; } = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetDiscountMaterialRequest : PagedRequest
|
public class GetDiscountMaterialRequest : PagedRequest
|
||||||
|
|
@ -132,7 +130,9 @@ public class GetDiscountMaterialRequest : PagedRequest
|
||||||
public string? DiscountCode { get; set; }
|
public string? DiscountCode { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetDiscountCustomerRequest : PagedRequest
|
|
||||||
|
|
||||||
|
public class GetFOCRequest : PagedRequest
|
||||||
{
|
{
|
||||||
[StringLength(10, MinimumLength = 3, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
|
[StringLength(10, MinimumLength = 3, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
|
||||||
public string SalesOrgCode { get; set; }
|
public string SalesOrgCode { get; set; }
|
||||||
|
|
@ -147,5 +147,25 @@ public class GetDiscountCustomerRequest : PagedRequest
|
||||||
public string? MaterialCode { get; set; }
|
public string? MaterialCode { get; set; }
|
||||||
|
|
||||||
[StringLength(10, MinimumLength = 1, ErrorMessage = "Discount Code must be between 1 and 10 characters.")]
|
[StringLength(10, MinimumLength = 1, ErrorMessage = "Discount Code must be between 1 and 10 characters.")]
|
||||||
public string? DiscountCode { get; set; }
|
public string? FOCCode { get; set; }
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetFOCMaterialRequest : PagedRequest
|
||||||
|
{
|
||||||
|
[StringLength(10, MinimumLength = 3, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
|
||||||
|
public string SalesOrgCode { get; set; }
|
||||||
|
|
||||||
|
[StringLength(10, MinimumLength = 5, ErrorMessage = "Customer Code must be between 1 and 10 characters.")]
|
||||||
|
public string? CustomerCode { get; set; }
|
||||||
|
|
||||||
|
[StringLength(10, MinimumLength = 5, ErrorMessage = "Employee number must be between 1 and 10 characters.")]
|
||||||
|
public string? EmployeeNumber { get; set; }
|
||||||
|
|
||||||
|
[StringLength(10, MinimumLength = 3, ErrorMessage = "Material Code must be between 1 and 10 characters.")]
|
||||||
|
public string? MaterialCode { get; set; }
|
||||||
|
|
||||||
|
[StringLength(10, MinimumLength = 1, ErrorMessage = "Discount Code must be between 1 and 10 characters.")]
|
||||||
|
public string? FOCCode { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.MobileApp;
|
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.MobileApp;
|
||||||
|
|
@ -168,6 +169,7 @@ public class GetDiscountResponse
|
||||||
public string DiscountName { get; set; }
|
public string DiscountName { get; set; }
|
||||||
public string DistributorChannelCode { get; set; }
|
public string DistributorChannelCode { get; set; }
|
||||||
public string DistributorChannelName { get; set; }
|
public string DistributorChannelName { get; set; }
|
||||||
|
public string CalculationType { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,4 +183,28 @@ public class GetDiscountMaterialResponse
|
||||||
public decimal DiscountValue { get; set; }
|
public decimal DiscountValue { get; set; }
|
||||||
public DateTime StartDate { get; set; }
|
public DateTime StartDate { get; set; }
|
||||||
public DateTime EndDate { get; set; }
|
public DateTime EndDate { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetFOCResponse
|
||||||
|
{
|
||||||
|
public string SalesOrgcCode { get; set; }
|
||||||
|
public string FOCCode { get; set; }
|
||||||
|
public string FOCName { get; set; }
|
||||||
|
public string DistributorChannelCode { get; set; }
|
||||||
|
public string DistributorChannelName { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetFOCMaterialResponse
|
||||||
|
{
|
||||||
|
public string FOCCode { get; set; }
|
||||||
|
public string CustomerCode { get; set; }
|
||||||
|
public string MaterialCode { get; set; }
|
||||||
|
public string UnitOfMeasurement { get; set; }
|
||||||
|
public decimal MinimumOrderQty { get; set; }
|
||||||
|
public decimal ForQuantity { get; set; }
|
||||||
|
public decimal FreeQty { get; set; }
|
||||||
|
public string FOCUnitOfMeasurement { get; set; }
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
public DateTime EndDate { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -17,4 +17,6 @@ public interface IMobileMasterDataService
|
||||||
Task<GetAttendanceByEmpResponse> UpsertAttendanceByEmpAsync(UpsertAttendanceByEmpRequest request);
|
Task<GetAttendanceByEmpResponse> UpsertAttendanceByEmpAsync(UpsertAttendanceByEmpRequest request);
|
||||||
Task<PagedResult<GetDiscountResponse>> GetDiscountAsync(GetDiscountRequest request);
|
Task<PagedResult<GetDiscountResponse>> GetDiscountAsync(GetDiscountRequest request);
|
||||||
Task<PagedResult<GetDiscountMaterialResponse>> GetDiscountMaterialsAsync(GetDiscountMaterialRequest request);
|
Task<PagedResult<GetDiscountMaterialResponse>> GetDiscountMaterialsAsync(GetDiscountMaterialRequest request);
|
||||||
|
Task<PagedResult<GetFOCResponse>> GetFOCsAsync(GetFOCRequest request);
|
||||||
|
Task<PagedResult<GetFOCMaterialResponse>> GetFOCMaterialsAsync(GetFOCMaterialRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -677,7 +677,8 @@ public class MobileMasterDataService : IMobileMasterDataService
|
||||||
DiscountCode = dr.GetString(1),
|
DiscountCode = dr.GetString(1),
|
||||||
DiscountName = dr.GetString(2),
|
DiscountName = dr.GetString(2),
|
||||||
DistributorChannelCode = dr.GetString(3),
|
DistributorChannelCode = dr.GetString(3),
|
||||||
DistributorChannelName = dr.GetString(4)
|
DistributorChannelName = dr.GetString(4),
|
||||||
|
CalculationType = dr.GetString(5)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
dr.Close();
|
dr.Close();
|
||||||
|
|
@ -760,5 +761,121 @@ public class MobileMasterDataService : IMobileMasterDataService
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<PagedResult<GetFOCResponse>> GetFOCsAsync(GetFOCRequest request)
|
||||||
|
{
|
||||||
|
PagedResult<GetFOCResponse> response = new();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SqlParameter[] p =
|
||||||
|
[
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@SalesOrgCode", pType: SqlDbType.VarChar, pValue: request.SalesOrgCode),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@CustomerCode", pType: SqlDbType.VarChar, pValue: request.CustomerCode),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeNumber", pType: SqlDbType.VarChar, pValue: request.EmployeeNumber),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@MaterialCode", pType: SqlDbType.VarChar, pValue: request.MaterialCode),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@DiscountCode", pType: SqlDbType.VarChar, pValue: request.FOCCode),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@PageNumber", pType: SqlDbType.Int, pValue: request.PageNumber),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@PageSize", pType: SqlDbType.Int, pValue: request.PageSize)
|
||||||
|
];
|
||||||
|
|
||||||
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetFOCPaginated", parameterValues: p))
|
||||||
|
{
|
||||||
|
while (dr.Read())
|
||||||
|
{
|
||||||
|
response.Items.Add(new GetFOCResponse
|
||||||
|
{
|
||||||
|
SalesOrgcCode = dr.GetString(0),
|
||||||
|
FOCCode = dr.GetString(1),
|
||||||
|
FOCName = dr.GetString(2),
|
||||||
|
DistributorChannelCode = dr.GetString(3),
|
||||||
|
DistributorChannelName = dr.GetString(4)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dr.Close();
|
||||||
|
|
||||||
|
response.TotalCount = response.Items.Count;
|
||||||
|
response.PageNumber = request.PageNumber;
|
||||||
|
response.PageSize = request.PageSize;
|
||||||
|
}
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception ie)
|
||||||
|
{
|
||||||
|
tc?.HandleError();
|
||||||
|
|
||||||
|
throw DBCustomError.GenerateCustomError(ie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PagedResult<GetFOCMaterialResponse>> GetFOCMaterialsAsync(GetFOCMaterialRequest request)
|
||||||
|
{
|
||||||
|
PagedResult<GetFOCMaterialResponse> response = new();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SqlParameter[] p =
|
||||||
|
[
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@SalesOrgCode", pType: SqlDbType.VarChar, pValue: request.SalesOrgCode),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@CustomerCode", pType: SqlDbType.VarChar, pValue: request.CustomerCode),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeNumber", pType: SqlDbType.VarChar, pValue: request.EmployeeNumber),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@MaterialCode", pType: SqlDbType.VarChar, pValue: request.MaterialCode),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@DiscountCode", pType: SqlDbType.VarChar, pValue: request.FOCCode),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@PageNumber", pType: SqlDbType.Int, pValue: request.PageNumber),
|
||||||
|
SqlHelperExtension.CreateInParam(pName: "@PageSize", pType: SqlDbType.Int, pValue: request.PageSize)
|
||||||
|
];
|
||||||
|
|
||||||
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetFOCMaterialsPaginated", parameterValues: p))
|
||||||
|
{
|
||||||
|
while (dr.Read())
|
||||||
|
{
|
||||||
|
response.Items.Add(new GetFOCMaterialResponse
|
||||||
|
{
|
||||||
|
FOCCode = dr.GetString(0),
|
||||||
|
CustomerCode = dr.GetString(1),
|
||||||
|
MaterialCode = dr.GetString(2),
|
||||||
|
UnitOfMeasurement = dr.GetString(3),
|
||||||
|
MinimumOrderQty = dr.GetDecimal(4),
|
||||||
|
ForQuantity = dr.GetDecimal(5),
|
||||||
|
FreeQty = dr.GetDecimal(6),
|
||||||
|
FOCUnitOfMeasurement = dr.GetString(7),
|
||||||
|
StartDate = dr.GetDateTime(8),
|
||||||
|
EndDate = dr.GetDateTime(9),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dr.Close();
|
||||||
|
|
||||||
|
response.TotalCount = response.Items.Count;
|
||||||
|
response.PageNumber = request.PageNumber;
|
||||||
|
response.PageSize = request.PageSize;
|
||||||
|
}
|
||||||
|
tc.End();
|
||||||
|
}
|
||||||
|
catch (Exception ie)
|
||||||
|
{
|
||||||
|
tc?.HandleError();
|
||||||
|
|
||||||
|
throw DBCustomError.GenerateCustomError(ie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -279,5 +279,59 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, MobileResponseBase<AppAuthUserResponse>.Failure(ex.InnerException != null ? ex.InnerException.Message : ex.Message, StatusCodes.Status500InternalServerError));
|
return StatusCode(StatusCodes.Status500InternalServerError, MobileResponseBase<AppAuthUserResponse>.Failure(ex.InnerException != null ? ex.InnerException.Message : ex.Message, StatusCodes.Status500InternalServerError));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Login using your credential data retrieve from SqlServer
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <response code="200">If login successful Return Attendance List</response>
|
||||||
|
[HttpGet("MaterialFOCs")]
|
||||||
|
[IgnoreAntiforgeryToken]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetFOCResponse))]
|
||||||
|
public async Task<IActionResult> GetMaterialFOCs([FromQuery] GetFOCRequest request)
|
||||||
|
{
|
||||||
|
PagedResult<GetFOCResponse> response = new();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = await _service.GetFOCsAsync(request);
|
||||||
|
return Ok(MobileResponseBase<PagedResult<GetFOCResponse>>.Success(response));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string msg = $"Exception occur on Get MaterialFOCs endpoint with request - {request?.EmployeeNumber} -{request?.FOCCode}";
|
||||||
|
_logger.LogError(exception: ex, message: msg);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, MobileResponseBase<AppAuthUserResponse>.Failure(ex.InnerException != null ? ex.InnerException.Message : ex.Message, StatusCodes.Status500InternalServerError));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Login using your credential data retrieve from SqlServer
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <response code="200">If login successful Return Attendance List</response>
|
||||||
|
[HttpGet("FOCsMaterials")]
|
||||||
|
[IgnoreAntiforgeryToken]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetFOCMaterialResponse))]
|
||||||
|
public async Task<IActionResult> GetFOCsMaterials([FromQuery] GetFOCMaterialRequest request)
|
||||||
|
{
|
||||||
|
PagedResult<GetFOCMaterialResponse> response = new();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = await _service.GetFOCMaterialsAsync(request);
|
||||||
|
return Ok(MobileResponseBase<PagedResult<GetFOCMaterialResponse>>.Success(response));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string msg = $"Exception occur on Get FOCsMaterials endpoint with request - {request?.MaterialCode} -{request?.FOCCode}";
|
||||||
|
_logger.LogError(exception: ex, message: msg);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError, MobileResponseBase<AppAuthUserResponse>.Failure(ex.InnerException != null ? ex.InnerException.Message : ex.Message, StatusCodes.Status500InternalServerError));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user