diff --git a/Api/OnlineSalesAutoCrop.CoreAPI.Models/Requests/MobileApp/MobileMasterDataRequest.cs b/Api/OnlineSalesAutoCrop.CoreAPI.Models/Requests/MobileApp/MobileMasterDataRequest.cs index 71496c9..3d2e7d1 100644 --- a/Api/OnlineSalesAutoCrop.CoreAPI.Models/Requests/MobileApp/MobileMasterDataRequest.cs +++ b/Api/OnlineSalesAutoCrop.CoreAPI.Models/Requests/MobileApp/MobileMasterDataRequest.cs @@ -66,11 +66,11 @@ public class UpsertAttendanceByEmpRequest { [Required, NotNull, StringLength(maximumLength: 10, MinimumLength = 3, ErrorMessage = "EmployeeNumber must be between 3 and 10 characters.")] public string EmployeeNumber { get; set; } - public DateTime? CheckInTime { get; set; } + public TimeSpan? CheckInTime { get; set; } public string? CheckInLatitude { get; set; } public string? CheckInLongitude { get; set; } public string? CheckInLocationName { get; set; } - public DateTime? CheckOutTime { get; set; } + public TimeSpan? CheckOutTime { get; set; } public string? CheckOutLatitude { get; set; } public string? CheckOutLongitude { get; set; } public string? CheckOutLocationName { get; set; } diff --git a/Api/OnlineSalesAutoCrop.CoreAPI.Models/Responses/MobileApp/MobileMasterDataResponse.cs b/Api/OnlineSalesAutoCrop.CoreAPI.Models/Responses/MobileApp/MobileMasterDataResponse.cs index b2f6578..0d4bd16 100644 --- a/Api/OnlineSalesAutoCrop.CoreAPI.Models/Responses/MobileApp/MobileMasterDataResponse.cs +++ b/Api/OnlineSalesAutoCrop.CoreAPI.Models/Responses/MobileApp/MobileMasterDataResponse.cs @@ -136,16 +136,16 @@ public class GetCustomerResponse public class GetAttendanceByEmpResponse { - public DateTime AttendanceDate { get; set; } + public DateTime? AttendanceDate { get; set; } public string EmployeeNumber { get; set; } - public DateTime? CheckInTime { get; set; } + public TimeSpan? CheckInTime { get; set; } public string? CheckInLatitude { get; set; } public string? CheckInLongitude { get; set; } public string? CheckInLocationName { get; set; } - public DateTime? CheckOutTime { get; set; } + public TimeSpan? CheckOutTime { get; set; } public string? CheckOutLatitude { get; set; } public string? CheckOutLongitude { get; set; } public string? CheckOutLocationName { get; set; } - public bool IsCheckIn => CheckInTime.HasValue ? true : false; - public bool IsCheckOut => CheckOutTime.HasValue ? true : false; + public bool? IsCheckIn => CheckInTime.HasValue ? true : false; + public bool? IsCheckOut => CheckOutTime.HasValue ? true : false; } \ No newline at end of file diff --git a/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/MobileApp/MobileMasterDataService.cs b/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/MobileApp/MobileMasterDataService.cs index 53506d3..1f78450 100644 --- a/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/MobileApp/MobileMasterDataService.cs +++ b/Api/OnlineSalesAutoCrop.CoreAPI.Services/Services/MobileApp/MobileMasterDataService.cs @@ -491,7 +491,7 @@ public class MobileMasterDataService : IMobileMasterDataService public async Task GetAttendanceByEmpAsync(GetAttendanceByEmpRequest request) { - GetAttendanceByEmpResponse response = null; + GetAttendanceByEmpResponse response = new(); try { @@ -534,18 +534,18 @@ public class MobileMasterDataService : IMobileMasterDataService try { - using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode); + using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode,true); try { SqlParameter[] p = [ SqlHelperExtension.CreateInParam(pName: "@AttendanceDate", pType: SqlDbType.Date, pValue: DateTime.Now), 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: "@CheckInLongitude", pType: SqlDbType.VarChar, pValue: request.CheckInLongitude), 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: "@CheckOutLongitude", pType: SqlDbType.VarChar, pValue: request.CheckOutLongitude), SqlHelperExtension.CreateInParam(pName: "@CheckOutLocationName", pType: SqlDbType.VarChar, pValue: request.CheckOutLocationName) @@ -581,11 +581,11 @@ public class MobileMasterDataService : IMobileMasterDataService { AttendanceDate = dr.GetDateTime(0), 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), CheckInLongitude = dr.IsDBNull(4) ? null : dr.GetString(4), 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), CheckOutLongitude = dr.IsDBNull(8) ? null : dr.GetString(8), CheckOutLocationName = dr.IsDBNull(9) ? null : dr.GetString(9) diff --git a/Api/OnlineSalesAutoCrop.CoreAPI/Controllers/Mobile/MobileMasterDataController.cs b/Api/OnlineSalesAutoCrop.CoreAPI/Controllers/Mobile/MobileMasterDataController.cs index 41998a8..a8fc4df 100644 --- a/Api/OnlineSalesAutoCrop.CoreAPI/Controllers/Mobile/MobileMasterDataController.cs +++ b/Api/OnlineSalesAutoCrop.CoreAPI/Controllers/Mobile/MobileMasterDataController.cs @@ -179,7 +179,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers /// /// /// If login successful Return Attendance List - [HttpPost("Attendance")] + [HttpPost("SaveAttendance")] [IgnoreAntiforgeryToken] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(GetAttendanceByEmpResponse))] public async Task UpsertAttendance([FromBody] UpsertAttendanceByEmpRequest request) @@ -192,7 +192,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers } 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); return StatusCode(StatusCodes.Status500InternalServerError, MobileResponseBase.Failure(ex.InnerException != null ? ex.InnerException.Message : ex.Message, StatusCodes.Status500InternalServerError)); }