-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pair programming met Kai en Stefhan Phteven
- Loading branch information
Showing
6 changed files
with
255 additions
and
105 deletions.
There are no files selected for viewing
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
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
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
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,63 @@ | ||
using ProjectB.Database; | ||
using ProjectB.Models; | ||
using ProjectB.Services; | ||
|
||
namespace ProjectB.Workflows.EmployeeFlows | ||
{ | ||
public class AddGuestFlow(IDatabaseContext context, ITourService tourService, IGuestService guestService) : AbstractWorkflow(context) | ||
{ | ||
public Guest? Guest { get; private set; } | ||
public Tour? Tour { get; private set; } | ||
|
||
public (bool Success, string MessageKey) SetGuest(string ticketNumber) | ||
{ | ||
if (string.IsNullOrWhiteSpace(ticketNumber)) | ||
return (false, "guestIsNull"); | ||
|
||
var guest = guestService.FindValidGuestById(ticketNumber); | ||
|
||
if (guest == null) | ||
return (false, "invalidTicket"); | ||
|
||
if (tourService.GetTourForGuest(guest) != null) | ||
return (false, "alreadyHasReservation"); | ||
|
||
Guest = guest; | ||
|
||
return (true, string.Empty); | ||
} | ||
|
||
public (bool Success, string MessageKey) SetTour(Tour tour) | ||
{ | ||
if (tour == null) | ||
return (false, "tourIsNull"); | ||
|
||
if (tour.Participants.Count >= tour.Capacity) | ||
return (false, "tourFull"); | ||
|
||
if (tour.Start < DateTime.Now) | ||
return (false, "tourInPast"); | ||
|
||
if (tour.Departed) | ||
return (false, "tourDeparted"); | ||
|
||
Tour = tour; | ||
|
||
return (true, string.Empty); | ||
} | ||
|
||
public override (bool Success, string MessageKey) Commit() | ||
{ | ||
if (Guest == null) | ||
return (false, "guestIsNull"); | ||
|
||
if (Tour == null) | ||
return (false, "tourIsNull"); | ||
|
||
tourService.RegisterGuestForTour(Guest, Tour); | ||
|
||
//No need to call base commit for this due to the service handling the changes | ||
return (true, string.Empty); | ||
} | ||
} | ||
} |
Oops, something went wrong.