-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#129 Accessibility - overriding accessibilities by period of time and…
… employee
- Loading branch information
1 parent
36addda
commit 361c6b3
Showing
9 changed files
with
105 additions
and
118 deletions.
There are no files selected for viewing
13 changes: 0 additions & 13 deletions
13
...service/src/Accessibility.Api/Availabilities/UpdateAvailabilitiesInPeriodOfTimeRequest.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ility.Application/Availabilities/Commands/UpdateInPeriodOfTime/UpdateAvailabilitiesDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Accessibility.Application.Availabilities.Commands.UpdateInPeriodOfTime | ||
{ | ||
public record UpdateAvailabilitiesDto( | ||
DateTime DateFrom, | ||
DateTime DateTo, | ||
Guid EmployeeId, | ||
Guid CreatorId, | ||
IEnumerable<UpdatedAvailability> Availabilities | ||
); | ||
|
||
public record UpdatedAvailability( | ||
DateTime StartTime, | ||
DateTime EndTime | ||
); | ||
} |
14 changes: 4 additions & 10 deletions
14
...Availabilities/Commands/UpdateInPeriodOfTime/UpdateAvailabilitiesInPeriodOfTimeCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Accessibility.Domain.Schedules; | ||
using Accessibility.Domain.SharedKernel; | ||
using Core.Commands; | ||
using MediatR; | ||
|
||
namespace Accessibility.Application.Availabilities.Commands.UpdateInPeriodOfTime | ||
{ | ||
public record UpdateAvailabilitiesInPeriodOfTimeCommand( | ||
FacilityId FacilityId, | ||
ScheduleId ScheduleId, | ||
DateTime DateFrom, | ||
DateTime DateTo, | ||
IEnumerable<AvailabilityDto> Availabilities | ||
) : IRequest<CommandResult<int>>; | ||
Guid FacilityId, | ||
Guid ScheduleId, | ||
UpdateAvailabilitiesDto Dto | ||
) : ICommand; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...src/Accessibility.Domain/Schedules/Rules/AvailabilityCanNotDuplicateInPeriodOfTimeRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Accessibility.Domain.SharedKernel; | ||
using Core.Domain; | ||
|
||
namespace Accessibility.Domain.Schedules.Rules | ||
{ | ||
public class AvailabilityCanNotDuplicateInPeriodOfTimeRule : IBusinessRule | ||
{ | ||
private readonly IEnumerable<PeriodOfTime> availabilities; | ||
|
||
public AvailabilityCanNotDuplicateInPeriodOfTimeRule(IEnumerable<PeriodOfTime> availabilities) | ||
{ | ||
this.availabilities = availabilities; | ||
} | ||
|
||
public string Message => $"Employee can not have more than one record in the same period of time in rage of one schedule."; | ||
|
||
public bool IsBroken() | ||
{ | ||
int skipCount = 1; | ||
|
||
foreach (var availability in availabilities) | ||
{ | ||
if (availabilities | ||
.Skip(skipCount) | ||
.Any(a => a.HasCommonPeriodWithEdges(availability))) | ||
{ | ||
return true; | ||
} | ||
|
||
skipCount++; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
...cessibility.Domain/Schedules/Rules/WorkerAvailabilityCanNotDuplicateInPeriodOfTimeRule.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters