add discount endpoints without service implementation
This commit is contained in:
parent
0250908261
commit
66e52442df
|
|
@ -42,16 +42,16 @@ public class GetMaterialsRequest : PagedRequest
|
||||||
|
|
||||||
public class GetCustomersRequest : PagedRequest
|
public class GetCustomersRequest : PagedRequest
|
||||||
{
|
{
|
||||||
[StringLength(10, MinimumLength = 1, 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; }
|
||||||
|
|
||||||
[StringLength(5, MinimumLength = 1, ErrorMessage = "Teritory Code must be between 1 and 5 characters.")]
|
[StringLength(5, MinimumLength = 3, 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.")]
|
[StringLength(10, MinimumLength = 5, 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.")]
|
[StringLength(10, MinimumLength = 5, ErrorMessage = "Employee number must be between 1 and 10 characters.")]
|
||||||
public string? EmployeeNumber { get; set; }
|
public string? EmployeeNumber { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,3 +77,59 @@ public class UpsertAttendanceByEmpRequest
|
||||||
public bool IsCheckIn => CheckInTime.HasValue ? true : false;
|
public bool IsCheckIn => CheckInTime.HasValue ? true : false;
|
||||||
public bool IsCheckOut => CheckOutTime.HasValue ? true : false;
|
public bool IsCheckOut => CheckOutTime.HasValue ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class GetDiscountRequest
|
||||||
|
{
|
||||||
|
[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? DiscountCode { get; set; }
|
||||||
|
|
||||||
|
public bool IsIncludeChild { get; set; } = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetDiscountMaterialRequest
|
||||||
|
{
|
||||||
|
[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? DiscountCode { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetDiscountCustomerRequest
|
||||||
|
{
|
||||||
|
[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? DiscountCode { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -154,3 +154,39 @@ public class GetAttendanceByEmpResponse
|
||||||
public bool? IsCheckIn => CheckInTime.HasValue ? true : false;
|
public bool? IsCheckIn => CheckInTime.HasValue ? true : false;
|
||||||
public bool? IsCheckOut => CheckOutTime.HasValue ? true : false;
|
public bool? IsCheckOut => CheckOutTime.HasValue ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 class GetDiscountMaterialResponse
|
||||||
|
{
|
||||||
|
public string DiscountCode { get; set; }
|
||||||
|
public string MaterialCode { get; set; }
|
||||||
|
public string UnitOfMeasurement { get; set; }
|
||||||
|
public string CalculationType { get; set; }
|
||||||
|
public decimal DiscountValue { get; set; }
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
public DateTime EndDate { get; set; }
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
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.MobileApp;
|
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.MobileApp;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.MobileApp;
|
namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.MobileApp;
|
||||||
|
|
@ -13,5 +14,7 @@ public interface IMobileMasterDataService
|
||||||
Task<PagedResult<GetCustomerResponse>> GetCustomersAsync(GetCustomersRequest request);
|
Task<PagedResult<GetCustomerResponse>> GetCustomersAsync(GetCustomersRequest request);
|
||||||
Task<GetAttendanceByEmpResponse> GetAttendanceByEmpAsync(GetAttendanceByEmpRequest request);
|
Task<GetAttendanceByEmpResponse> GetAttendanceByEmpAsync(GetAttendanceByEmpRequest request);
|
||||||
Task<GetAttendanceByEmpResponse> UpsertAttendanceByEmpAsync(UpsertAttendanceByEmpRequest request);
|
Task<GetAttendanceByEmpResponse> UpsertAttendanceByEmpAsync(UpsertAttendanceByEmpRequest request);
|
||||||
|
Task<List<GetDiscountResponse>> GetDiscountAsync(GetDiscountRequest request);
|
||||||
|
Task<List<GetDiscountCustomerResponse>> GetDiscountCustomersAsync(GetDiscountCustomerRequest request);
|
||||||
|
Task<List<GetDiscountMaterialResponse>> GetDiscountMaterialsAsync(GetDiscountMaterialRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -595,4 +595,19 @@ public class MobileMasterDataService : IMobileMasterDataService
|
||||||
CheckOutLocationName = dr.IsDBNull(9) ? null : dr.GetString(9)
|
CheckOutLocationName = dr.IsDBNull(9) ? null : dr.GetString(9)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<List<GetDiscountResponse>> GetDiscountAsync(GetDiscountRequest request)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<List<GetDiscountCustomerResponse>> GetDiscountCustomersAsync(GetDiscountCustomerRequest request)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<List<GetDiscountMaterialResponse>> GetDiscountMaterialsAsync(GetDiscountMaterialRequest request)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Asp.Versioning;
|
using Asp.Versioning;
|
||||||
|
using DocumentFormat.OpenXml.Office2010.ExcelAc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -11,6 +12,7 @@ using OnlineSalesAutoCrop.CoreAPI.Models.Responses;
|
||||||
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.MobileApp;
|
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.MobileApp;
|
||||||
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.MobileApp;
|
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.MobileApp;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
||||||
|
|
@ -197,5 +199,85 @@ 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("Discounts")]
|
||||||
|
[IgnoreAntiforgeryToken]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetDiscountResponse))]
|
||||||
|
public async Task<IActionResult> GetDiscounts([FromQuery] GetDiscountRequest request)
|
||||||
|
{
|
||||||
|
List<GetDiscountResponse> response = new();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = await _service.GetDiscountAsync(request);
|
||||||
|
return Ok(MobileResponseBase<List<GetDiscountResponse>>.Success(response));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string msg = $"Exception occur on Get Discounts 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
|
||||||
|
/// </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
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <response code="200">If login successful Return Attendance List</response>
|
||||||
|
[HttpGet("DiscountMaterials")]
|
||||||
|
[IgnoreAntiforgeryToken]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetDiscountMaterialResponse))]
|
||||||
|
public async Task<IActionResult> GetDiscountMaterials([FromQuery] GetDiscountMaterialRequest request)
|
||||||
|
{
|
||||||
|
List<GetDiscountMaterialResponse> response = new();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = await _service.GetDiscountMaterialsAsync(request);
|
||||||
|
return Ok(MobileResponseBase<List<GetDiscountMaterialResponse>>.Success(response));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string msg = $"Exception occur on Get DiscountMaterials endpoint with request - {request?.MaterialCode} -{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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user