diff --git a/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs b/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs index fa1d5a61..cdd470b2 100644 --- a/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs +++ b/CompanyManagment.App.Contracts/Leave/ILeaveApplication.cs @@ -114,6 +114,14 @@ public interface ILeaveApplication /// Task GetHourlyLeaveDuration(string startHours, string endHours); + /// + /// محاسبه مدت مرخصی روزانه + /// + /// + /// + /// + Task GetDailyLeaveDuration(string startDate, string endDate); + } public class LeavePrintResponseViewModel diff --git a/CompanyManagment.Application/LeaveApplication.cs b/CompanyManagment.Application/LeaveApplication.cs index 53d75355..92816477 100644 --- a/CompanyManagment.Application/LeaveApplication.cs +++ b/CompanyManagment.Application/LeaveApplication.cs @@ -975,6 +975,9 @@ public class LeaveApplication : ILeaveApplication public async Task GetHourlyLeaveDuration(string startHours, string endHours) { + if (string.IsNullOrWhiteSpace(startHours) || string.IsNullOrWhiteSpace(endHours)) + return ""; + var start = new DateTime(); var end = new DateTime(); try @@ -1015,4 +1018,25 @@ public class LeaveApplication : ILeaveApplication return ($"{hours}"); } + + public async Task GetDailyLeaveDuration(string startDate, string endDate) + { + if (string.IsNullOrWhiteSpace(startDate) || string.IsNullOrWhiteSpace(endDate)) + return ""; + + if (startDate.TryToGeorgianDateTime(out var start) == false || endDate.TryToGeorgianDateTime(out var end) == false) + return ""; + + + + if (end >= start) + { + var daysSpan = (end - start).TotalDays + 1; + return $"{(int)daysSpan} روز"; + } + else + { + return "تاریخ پایان از تاریخ شروع کوچکتر است."; + } + } } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Controllers/LeaveController.cs b/ServiceHost/Areas/Client/Controllers/LeaveController.cs index e55c2c8f..7c6314a6 100644 --- a/ServiceHost/Areas/Client/Controllers/LeaveController.cs +++ b/ServiceHost/Areas/Client/Controllers/LeaveController.cs @@ -86,6 +86,33 @@ public class LeaveController : ClientBaseController return await _leaveApplication.HasRotatingShift(_workshopId, employeeId, startLeaveDate); } + + /// + /// محاسبه مدت مرخصی ساعتی + /// + /// + /// + /// + [HttpGet("GetHourlyLeaveDuration")] + public async Task> GetHourlyLeaveDuration(string startHours, string endHours) + { + var result =await _leaveApplication.GetHourlyLeaveDuration(startHours, endHours); + return Ok(new { LeaveDuration = result }); + } + + /// + /// محاسبه مدت مرخصی روزانه + /// + /// + /// + /// + [HttpGet("GetDailyLeaveDuration")] + public async Task> GetDailyLeaveDuration(string startDate, string endDate) + { + var result = await _leaveApplication.GetDailyLeaveDuration(startDate, endDate); + return Ok(new { LeaveDuration = result }); + } + /// /// پرینت تکی ///