Completed Discount and Discount Materials route
This commit is contained in:
parent
66e52442df
commit
a7467fbb39
|
|
@ -40,6 +40,22 @@ public class GetMaterialsRequest : PagedRequest
|
|||
public string? EmployeeNumber { get; set; }
|
||||
}
|
||||
|
||||
public class GetMaterialPriceRequest : 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; }
|
||||
|
||||
[StringLength(10, MinimumLength = 1, ErrorMessage = "Material Code must be between 1 and 10 characters.")]
|
||||
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
|
||||
{
|
||||
[StringLength(10, MinimumLength = 3, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
|
||||
|
|
@ -78,7 +94,7 @@ public class UpsertAttendanceByEmpRequest
|
|||
public bool IsCheckOut => CheckOutTime.HasValue ? true : false;
|
||||
}
|
||||
|
||||
public class GetDiscountRequest
|
||||
public class GetDiscountRequest : PagedRequest
|
||||
{
|
||||
[StringLength(10, MinimumLength = 3, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
|
||||
public string SalesOrgCode { get; set; }
|
||||
|
|
@ -98,7 +114,7 @@ public class GetDiscountRequest
|
|||
public bool IsIncludeChild { get; set; } = false;
|
||||
}
|
||||
|
||||
public class GetDiscountMaterialRequest
|
||||
public class GetDiscountMaterialRequest : PagedRequest
|
||||
{
|
||||
[StringLength(10, MinimumLength = 3, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
|
||||
public string SalesOrgCode { get; set; }
|
||||
|
|
@ -116,7 +132,7 @@ public class GetDiscountMaterialRequest
|
|||
public string? DiscountCode { get; set; }
|
||||
}
|
||||
|
||||
public class GetDiscountCustomerRequest
|
||||
public class GetDiscountCustomerRequest : PagedRequest
|
||||
{
|
||||
[StringLength(10, MinimumLength = 3, ErrorMessage = "Sales organization code must be between 1 and 10 characters.")]
|
||||
public string SalesOrgCode { get; set; }
|
||||
|
|
|
|||
|
|
@ -104,9 +104,15 @@ public class GetMaterialResponse
|
|||
public string BrandCode { get; set; }
|
||||
public string BrandName { get; set; }
|
||||
public string SalesOrg { get; set; }
|
||||
public decimal BasePrice { get; set; }
|
||||
}
|
||||
|
||||
public class GetMaterialPriceResponse
|
||||
{
|
||||
public string SalesOrgCode { get; set; }
|
||||
public string CustomerCode { get; set; }
|
||||
public string MaterialCode { get; set; }
|
||||
public decimal BasePrice { get; set; }
|
||||
}
|
||||
|
||||
public class GetCustomerResponse
|
||||
{
|
||||
|
|
@ -157,32 +163,18 @@ public class GetAttendanceByEmpResponse
|
|||
|
||||
public class GetDiscountResponse
|
||||
{
|
||||
public GetDiscountResponse()
|
||||
{
|
||||
Customers = new List<GetDiscountCustomerResponse>();
|
||||
Materials = new List<GetDiscountMaterialResponse>();
|
||||
}
|
||||
public string DiscountCode { get; set; }
|
||||
public string SalesOrgcCode { get; set; }
|
||||
public string DistributorChannelCode { get; set; }
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
|
||||
public List<GetDiscountCustomerResponse> Customers { get; set; }
|
||||
public List<GetDiscountMaterialResponse> Materials { get; set; }
|
||||
}
|
||||
|
||||
public class GetDiscountCustomerResponse
|
||||
{
|
||||
public string DiscountCode { get; set; }
|
||||
public string CustomerCode { get; set; }
|
||||
public DateTime FromDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
public string DiscountName { get; set; }
|
||||
public string DistributorChannelCode { get; set; }
|
||||
public string DistributorChannelName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class GetDiscountMaterialResponse
|
||||
{
|
||||
public string DiscountCode { get; set; }
|
||||
public string CustomerCode { get; set; }
|
||||
public string MaterialCode { get; set; }
|
||||
public string UnitOfMeasurement { get; set; }
|
||||
public string CalculationType { get; set; }
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ public interface IMobileMasterDataService
|
|||
Task<MarketHeirarchyByEmpResponse> GetMarketHeirarchiesByEmpAsync(GetMarketHeirarchyByEmpRequest request);
|
||||
Task<PagedResult<GetBrandResponse>> GetBrandsAsync(GetBrandsRequest request);
|
||||
Task<PagedResult<GetMaterialResponse>> GetMaterialsAsync(GetMaterialsRequest request);
|
||||
Task<PagedResult<GetMaterialPriceResponse>> GetMaterialPricesAsync(GetMaterialPriceRequest request);
|
||||
Task<PagedResult<GetCustomerResponse>> GetCustomersAsync(GetCustomersRequest request);
|
||||
Task<GetAttendanceByEmpResponse> GetAttendanceByEmpAsync(GetAttendanceByEmpRequest request);
|
||||
Task<GetAttendanceByEmpResponse> UpsertAttendanceByEmpAsync(UpsertAttendanceByEmpRequest request);
|
||||
Task<List<GetDiscountResponse>> GetDiscountAsync(GetDiscountRequest request);
|
||||
Task<List<GetDiscountCustomerResponse>> GetDiscountCustomersAsync(GetDiscountCustomerRequest request);
|
||||
Task<List<GetDiscountMaterialResponse>> GetDiscountMaterialsAsync(GetDiscountMaterialRequest request);
|
||||
Task<PagedResult<GetDiscountResponse>> GetDiscountAsync(GetDiscountRequest request);
|
||||
Task<PagedResult<GetDiscountMaterialResponse>> GetDiscountMaterialsAsync(GetDiscountMaterialRequest request);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,8 +115,6 @@ public class MobileMasterDataService : IMobileMasterDataService
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<PagedResult<GetMaterialResponse>> GetMaterialsAsync(GetMaterialsRequest request)
|
||||
{
|
||||
PagedResult<GetMaterialResponse> response = new();
|
||||
|
|
@ -152,8 +150,62 @@ public class MobileMasterDataService : IMobileMasterDataService
|
|||
UnitConversionValue = dr.GetDecimal(8),
|
||||
BrandCode = dr.GetString(9),
|
||||
BrandName = dr.GetString(10),
|
||||
SalesOrg = dr.GetString(11),
|
||||
BasePrice = dr.GetDecimal(12)
|
||||
SalesOrg = dr.GetString(11)
|
||||
});
|
||||
}
|
||||
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<GetMaterialPriceResponse>> GetMaterialPricesAsync(GetMaterialPriceRequest request)
|
||||
{
|
||||
PagedResult<GetMaterialPriceResponse> response = new();
|
||||
try
|
||||
{
|
||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
||||
try
|
||||
{
|
||||
SqlParameter[] p =
|
||||
[
|
||||
SqlHelperExtension.CreateInParam(pName: "@BrandCode", pType: SqlDbType.VarChar, pValue: request.BrandCode),
|
||||
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: "@PageSize", pType: SqlDbType.Int, pValue: request.PageSize)
|
||||
];
|
||||
|
||||
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetMaterialPricePaginated", parameterValues: p))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
response.Items.Add(new GetMaterialPriceResponse
|
||||
{
|
||||
SalesOrgCode = dr.GetString(0),
|
||||
CustomerCode = dr.GetString(1),
|
||||
MaterialCode = dr.GetString(2),
|
||||
BasePrice = dr.GetDecimal(3)
|
||||
});
|
||||
}
|
||||
dr.Close();
|
||||
|
|
@ -596,18 +648,117 @@ public class MobileMasterDataService : IMobileMasterDataService
|
|||
};
|
||||
}
|
||||
|
||||
public Task<List<GetDiscountResponse>> GetDiscountAsync(GetDiscountRequest request)
|
||||
public async Task<PagedResult<GetDiscountResponse>> GetDiscountAsync(GetDiscountRequest request)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
PagedResult<GetDiscountResponse> 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.DiscountCode),
|
||||
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.GetDiscountPaginated", parameterValues: p))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
response.Items.Add(new GetDiscountResponse
|
||||
{
|
||||
SalesOrgcCode = dr.GetString(0),
|
||||
DiscountCode = dr.GetString(1),
|
||||
DiscountName = 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;
|
||||
}
|
||||
|
||||
public Task<List<GetDiscountCustomerResponse>> GetDiscountCustomersAsync(GetDiscountCustomerRequest request)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return response;
|
||||
}
|
||||
|
||||
public Task<List<GetDiscountMaterialResponse>> GetDiscountMaterialsAsync(GetDiscountMaterialRequest request)
|
||||
public async Task<PagedResult<GetDiscountMaterialResponse>> GetDiscountMaterialsAsync(GetDiscountMaterialRequest request)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
PagedResult<GetDiscountMaterialResponse> 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.DiscountCode),
|
||||
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.GetDiscountMaterialsPaginated", parameterValues: p))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
response.Items.Add(new GetDiscountMaterialResponse
|
||||
{
|
||||
DiscountCode = dr.GetString(0),
|
||||
CustomerCode = dr.GetString(1),
|
||||
MaterialCode = dr.GetString(2),
|
||||
UnitOfMeasurement = dr.GetString(3),
|
||||
CalculationType = dr.GetString(4),
|
||||
DiscountValue = dr.GetDecimal(5),
|
||||
StartDate = dr.GetDateTime(6),
|
||||
EndDate = dr.GetDateTime(7),
|
||||
});
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,32 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Login using your credential data retrieve from SqlServer
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// </remarks>
|
||||
/// <param name="request"></param>
|
||||
/// <response code="200">If login successful Return Material List</response>
|
||||
[HttpGet("CustomerWiseMaterialPrices")]
|
||||
[IgnoreAntiforgeryToken]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetMaterialPriceResponse))]
|
||||
public async Task<IActionResult> GetCustomerWiseMaterialPrices([FromQuery] GetMaterialPriceRequest request)
|
||||
{
|
||||
PagedResult<GetMaterialPriceResponse> response = new();
|
||||
try
|
||||
{
|
||||
response = await _service.GetMaterialPricesAsync(request);
|
||||
return Ok(MobileResponseBase<PagedResult<GetMaterialPriceResponse>>.Success(response));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string msg = $"Exception occur on Materials prices endpoint with employee request - {request?.MaterialCode} -{request?.EmployeeNumber}";
|
||||
_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>
|
||||
|
|
@ -213,11 +239,11 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetDiscountResponse))]
|
||||
public async Task<IActionResult> GetDiscounts([FromQuery] GetDiscountRequest request)
|
||||
{
|
||||
List<GetDiscountResponse> response = new();
|
||||
PagedResult<GetDiscountResponse> response = new();
|
||||
try
|
||||
{
|
||||
response = await _service.GetDiscountAsync(request);
|
||||
return Ok(MobileResponseBase<List<GetDiscountResponse>>.Success(response));
|
||||
return Ok(MobileResponseBase<PagedResult<GetDiscountResponse>>.Success(response));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -227,32 +253,6 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <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("DiscountCustomers")]
|
||||
[IgnoreAntiforgeryToken]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetDiscountCustomerResponse))]
|
||||
public async Task<IActionResult> GetDiscountCustomers([FromQuery] GetDiscountCustomerRequest request)
|
||||
{
|
||||
List<GetDiscountCustomerResponse> response = new();
|
||||
try
|
||||
{
|
||||
response = await _service.GetDiscountCustomersAsync(request);
|
||||
return Ok(MobileResponseBase<List<GetDiscountCustomerResponse>>.Success(response));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string msg = $"Exception occur on Get DiscountCustomers endpoint with request - {request?.EmployeeNumber} -{request?.DiscountCode}";
|
||||
_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
|
||||
|
|
@ -266,11 +266,11 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetDiscountMaterialResponse))]
|
||||
public async Task<IActionResult> GetDiscountMaterials([FromQuery] GetDiscountMaterialRequest request)
|
||||
{
|
||||
List<GetDiscountMaterialResponse> response = new();
|
||||
PagedResult<GetDiscountMaterialResponse> response = new();
|
||||
try
|
||||
{
|
||||
response = await _service.GetDiscountMaterialsAsync(request);
|
||||
return Ok(MobileResponseBase<List<GetDiscountMaterialResponse>>.Success(response));
|
||||
return Ok(MobileResponseBase<PagedResult<GetDiscountMaterialResponse>>.Success(response));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user