chnage pm shift duration method on domain
This commit is contained in:
@@ -22,7 +22,9 @@ public class WorkingHours
|
||||
PersianDayOfWeek = persianDayOfWeek;
|
||||
IsActiveDay = isActiveDay;
|
||||
|
||||
ComputeShiftDuration(startShiftOne, endShiftOne, startShiftTwo, endShiftTwo, restTime, hasShiftOne, hasShiftTwo,hasRestTime);
|
||||
var computeResult = ComputeShiftDuration(startShiftOne, endShiftOne, startShiftTwo, endShiftTwo, restTime, hasShiftOne, hasShiftTwo,hasRestTime);
|
||||
ShiftDuration = computeResult.shiftDuration;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -109,10 +111,11 @@ public class WorkingHours
|
||||
/// <param name="startShift"></param>
|
||||
/// <param name="endShift"></param>
|
||||
/// <returns></returns>
|
||||
private void ComputeShiftDuration(TimeSpan startShift, TimeSpan endShift, TimeSpan startShiftTwo, TimeSpan endShiftTwo, TimeSpan restTime, bool hasShiftOne, bool hasShiftTwo, bool hasRestTime)
|
||||
public static (TimeSpan shiftDuration, int shiftDurationInMinutes) ComputeShiftDuration(TimeSpan startShift, TimeSpan endShift, TimeSpan startShiftTwo, TimeSpan endShiftTwo, TimeSpan restTime, bool hasShiftOne, bool hasShiftTwo, bool hasRestTime)
|
||||
{
|
||||
var now = DateTime.Now.Date;
|
||||
|
||||
TimeSpan shiftDurationResult = new TimeSpan();
|
||||
int shiftDurationInMinutesResult = 0;
|
||||
if (hasShiftOne && !hasShiftTwo)
|
||||
{
|
||||
DateTime startOne = new DateTime(now.Year, now.Month, now.Day, startShift.Hours, startShift.Minutes,0);
|
||||
@@ -123,7 +126,8 @@ public class WorkingHours
|
||||
endOne = endOne.AddDays(1);
|
||||
var shiftDuration = (endOne - startOne);
|
||||
|
||||
ShiftDuration = hasRestTime ? (shiftDuration - restTime) : shiftDuration;
|
||||
shiftDurationResult = hasRestTime ? (shiftDuration - restTime) : shiftDuration;
|
||||
shiftDurationInMinutesResult = (int)shiftDurationResult.TotalMinutes;
|
||||
}
|
||||
else if (!hasShiftOne && hasShiftTwo)
|
||||
{
|
||||
@@ -134,7 +138,8 @@ public class WorkingHours
|
||||
endTow = endTow.AddDays(1);
|
||||
|
||||
|
||||
ShiftDuration = (endTow - startTow);
|
||||
shiftDurationResult = (endTow - startTow);
|
||||
shiftDurationInMinutesResult = (int)shiftDurationResult.TotalMinutes;
|
||||
}
|
||||
else if (hasShiftOne && hasShiftTwo)
|
||||
{
|
||||
@@ -152,13 +157,12 @@ public class WorkingHours
|
||||
endTow = endTow.AddDays(1);
|
||||
|
||||
var shiftDurationTow = (endTow - startTow);
|
||||
ShiftDuration = shiftOneDuration.Add(shiftDurationTow);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShiftDurationInMinutes = 0;
|
||||
shiftDurationResult = shiftOneDuration.Add(shiftDurationTow);
|
||||
shiftDurationInMinutesResult = (int)shiftDurationResult.TotalMinutes;
|
||||
}
|
||||
|
||||
|
||||
return (shiftDurationResult, shiftDurationInMinutesResult);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user