update in attendance endpoint
This commit is contained in:
parent
cbd94a76ac
commit
5778ee9203
|
|
@ -66,11 +66,11 @@ public class UpsertAttendanceByEmpRequest
|
||||||
{
|
{
|
||||||
[Required, NotNull, StringLength(maximumLength: 10, MinimumLength = 3, ErrorMessage = "EmployeeNumber must be between 3 and 10 characters.")]
|
[Required, NotNull, StringLength(maximumLength: 10, MinimumLength = 3, ErrorMessage = "EmployeeNumber must be between 3 and 10 characters.")]
|
||||||
public string EmployeeNumber { get; set; }
|
public string EmployeeNumber { get; set; }
|
||||||
public DateTime? CheckInTime { get; set; }
|
public TimeSpan? CheckInTime { get; set; }
|
||||||
public string? CheckInLatitude { get; set; }
|
public string? CheckInLatitude { get; set; }
|
||||||
public string? CheckInLongitude { get; set; }
|
public string? CheckInLongitude { get; set; }
|
||||||
public string? CheckInLocationName { get; set; }
|
public string? CheckInLocationName { get; set; }
|
||||||
public DateTime? CheckOutTime { get; set; }
|
public TimeSpan? CheckOutTime { get; set; }
|
||||||
public string? CheckOutLatitude { get; set; }
|
public string? CheckOutLatitude { get; set; }
|
||||||
public string? CheckOutLongitude { get; set; }
|
public string? CheckOutLongitude { get; set; }
|
||||||
public string? CheckOutLocationName { get; set; }
|
public string? CheckOutLocationName { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -136,16 +136,16 @@ public class GetCustomerResponse
|
||||||
|
|
||||||
public class GetAttendanceByEmpResponse
|
public class GetAttendanceByEmpResponse
|
||||||
{
|
{
|
||||||
public DateTime AttendanceDate { get; set; }
|
public DateTime? AttendanceDate { get; set; }
|
||||||
public string EmployeeNumber { get; set; }
|
public string EmployeeNumber { get; set; }
|
||||||
public DateTime? CheckInTime { get; set; }
|
public TimeSpan? CheckInTime { get; set; }
|
||||||
public string? CheckInLatitude { get; set; }
|
public string? CheckInLatitude { get; set; }
|
||||||
public string? CheckInLongitude { get; set; }
|
public string? CheckInLongitude { get; set; }
|
||||||
public string? CheckInLocationName { get; set; }
|
public string? CheckInLocationName { get; set; }
|
||||||
public DateTime? CheckOutTime { get; set; }
|
public TimeSpan? CheckOutTime { get; set; }
|
||||||
public string? CheckOutLatitude { get; set; }
|
public string? CheckOutLatitude { get; set; }
|
||||||
public string? CheckOutLongitude { get; set; }
|
public string? CheckOutLongitude { get; set; }
|
||||||
public string? CheckOutLocationName { get; set; }
|
public string? CheckOutLocationName { get; set; }
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
@ -491,7 +491,7 @@ public class MobileMasterDataService : IMobileMasterDataService
|
||||||
|
|
||||||
public async Task<GetAttendanceByEmpResponse> GetAttendanceByEmpAsync(GetAttendanceByEmpRequest request)
|
public async Task<GetAttendanceByEmpResponse> GetAttendanceByEmpAsync(GetAttendanceByEmpRequest request)
|
||||||
{
|
{
|
||||||
GetAttendanceByEmpResponse response = null;
|
GetAttendanceByEmpResponse response = new();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -534,18 +534,18 @@ public class MobileMasterDataService : IMobileMasterDataService
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode,true);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SqlParameter[] p =
|
SqlParameter[] p =
|
||||||
[
|
[
|
||||||
SqlHelperExtension.CreateInParam(pName: "@AttendanceDate", pType: SqlDbType.Date, pValue: DateTime.Now),
|
SqlHelperExtension.CreateInParam(pName: "@AttendanceDate", pType: SqlDbType.Date, pValue: DateTime.Now),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@EmployeeNumber", pType: SqlDbType.VarChar, pValue: request.EmployeeNumber),
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeNumber", pType: SqlDbType.VarChar, pValue: request.EmployeeNumber),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@CheckInTime", pType: SqlDbType.DateTime, pValue: request.CheckInTime),
|
SqlHelperExtension.CreateInParam(pName: "@CheckInTime", pType: SqlDbType.DateTime, pValue: request.CheckInTime != null ? DateTime.Today.Add(request.CheckInTime.Value) : null),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@CheckInLatitude", pType: SqlDbType.VarChar, pValue: request.CheckInLatitude),
|
SqlHelperExtension.CreateInParam(pName: "@CheckInLatitude", pType: SqlDbType.VarChar, pValue: request.CheckInLatitude),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@CheckInLongitude", pType: SqlDbType.VarChar, pValue: request.CheckInLongitude),
|
SqlHelperExtension.CreateInParam(pName: "@CheckInLongitude", pType: SqlDbType.VarChar, pValue: request.CheckInLongitude),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@CheckInLocationName", pType: SqlDbType.VarChar, pValue: request.CheckInLocationName),
|
SqlHelperExtension.CreateInParam(pName: "@CheckInLocationName", pType: SqlDbType.VarChar, pValue: request.CheckInLocationName),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@CheckOutTime", pType: SqlDbType.DateTime, pValue: request.CheckOutTime),
|
SqlHelperExtension.CreateInParam(pName: "@CheckOutTime", pType: SqlDbType.DateTime, pValue: request.CheckOutTime != null ? DateTime.Today.Add(request.CheckOutTime.Value) : null),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@CheckOutLatitude", pType: SqlDbType.VarChar, pValue: request.CheckOutLatitude),
|
SqlHelperExtension.CreateInParam(pName: "@CheckOutLatitude", pType: SqlDbType.VarChar, pValue: request.CheckOutLatitude),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@CheckOutLongitude", pType: SqlDbType.VarChar, pValue: request.CheckOutLongitude),
|
SqlHelperExtension.CreateInParam(pName: "@CheckOutLongitude", pType: SqlDbType.VarChar, pValue: request.CheckOutLongitude),
|
||||||
SqlHelperExtension.CreateInParam(pName: "@CheckOutLocationName", pType: SqlDbType.VarChar, pValue: request.CheckOutLocationName)
|
SqlHelperExtension.CreateInParam(pName: "@CheckOutLocationName", pType: SqlDbType.VarChar, pValue: request.CheckOutLocationName)
|
||||||
|
|
@ -581,11 +581,11 @@ public class MobileMasterDataService : IMobileMasterDataService
|
||||||
{
|
{
|
||||||
AttendanceDate = dr.GetDateTime(0),
|
AttendanceDate = dr.GetDateTime(0),
|
||||||
EmployeeNumber = dr.GetString(1),
|
EmployeeNumber = dr.GetString(1),
|
||||||
CheckInTime = dr.IsDBNull(2) ? null : dr.GetDateTime(2),
|
CheckInTime = dr.IsDBNull(2) ? null : dr.GetDateTime(2).TimeOfDay,
|
||||||
CheckInLatitude = dr.IsDBNull(3) ? null : dr.GetString(3),
|
CheckInLatitude = dr.IsDBNull(3) ? null : dr.GetString(3),
|
||||||
CheckInLongitude = dr.IsDBNull(4) ? null : dr.GetString(4),
|
CheckInLongitude = dr.IsDBNull(4) ? null : dr.GetString(4),
|
||||||
CheckInLocationName = dr.IsDBNull(5) ? null : dr.GetString(5),
|
CheckInLocationName = dr.IsDBNull(5) ? null : dr.GetString(5),
|
||||||
CheckOutTime = dr.IsDBNull(6) ? null : dr.GetDateTime(6),
|
CheckOutTime = dr.IsDBNull(6) ? null : dr.GetDateTime(6).TimeOfDay,
|
||||||
CheckOutLatitude = dr.IsDBNull(7) ? null : dr.GetString(7),
|
CheckOutLatitude = dr.IsDBNull(7) ? null : dr.GetString(7),
|
||||||
CheckOutLongitude = dr.IsDBNull(8) ? null : dr.GetString(8),
|
CheckOutLongitude = dr.IsDBNull(8) ? null : dr.GetString(8),
|
||||||
CheckOutLocationName = dr.IsDBNull(9) ? null : dr.GetString(9)
|
CheckOutLocationName = dr.IsDBNull(9) ? null : dr.GetString(9)
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <response code="200">If login successful Return Attendance List</response>
|
/// <response code="200">If login successful Return Attendance List</response>
|
||||||
[HttpPost("Attendance")]
|
[HttpPost("SaveAttendance")]
|
||||||
[IgnoreAntiforgeryToken]
|
[IgnoreAntiforgeryToken]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetAttendanceByEmpResponse))]
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetAttendanceByEmpResponse))]
|
||||||
public async Task<IActionResult> UpsertAttendance([FromBody] UpsertAttendanceByEmpRequest request)
|
public async Task<IActionResult> UpsertAttendance([FromBody] UpsertAttendanceByEmpRequest request)
|
||||||
|
|
@ -192,7 +192,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
string msg = $"Exception occur on Save Attendance endpoint with employee request - {request?.EmployeeNumber} -{request?.AttendanceDate}";
|
string msg = $"Exception occur on Save Attendance endpoint with employee request - {request?.EmployeeNumber}";
|
||||||
_logger.LogError(exception: ex, message: msg);
|
_logger.LogError(exception: ex, message: msg);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user