public SuggestionsMade(ShowId showId, PartyRequested partyRequested) { ShowId = showId; PartyRequested = partyRequested; InstantiateAnEmptyListForEveryPricingCategory(); }
public static Maybe <SuggestionsMade> TryMakeSuggestions(ShowId showId, PartyRequested partyRequested, AuditoriumSeating auditoriumSeating) { var suggestionsMade = new SuggestionsMade(showId, partyRequested); suggestionsMade.Add(GiveMeSuggestionsFor(auditoriumSeating, partyRequested, PricingCategory.First)); suggestionsMade.Add(GiveMeSuggestionsFor(auditoriumSeating, partyRequested, PricingCategory.Second)); suggestionsMade.Add(GiveMeSuggestionsFor(auditoriumSeating, partyRequested, PricingCategory.Third)); suggestionsMade.Add(GiveMeSuggestionsFor(auditoriumSeating, partyRequested, PricingCategory.Mixed)); if (suggestionsMade.MatchExpectations()) { return(new Maybe <SuggestionsMade>(suggestionsMade)); } return(new Maybe <SuggestionsMade>()); }
public async Task <SuggestionsMade> MakeSuggestions(ShowId showId, PartyRequested partyRequested) { var auditoriumSeating = await _auditoriumSeatingAdapter.GetAuditoriumSeating(showId); var suggestionsMade = new SuggestionsMade(showId, partyRequested); suggestionsMade.Add(GiveMeSuggestionsFor(auditoriumSeating, partyRequested, PricingCategoryRequested.First)); suggestionsMade.Add( GiveMeSuggestionsFor(auditoriumSeating, partyRequested, PricingCategoryRequested.Second)); suggestionsMade.Add(GiveMeSuggestionsFor(auditoriumSeating, partyRequested, PricingCategoryRequested.Third)); suggestionsMade.Add(GiveMeSuggestionsFor(auditoriumSeating, partyRequested, PricingCategoryRequested.Mixed)); if (suggestionsMade.DoesMatchExpectations()) { return(suggestionsMade); } return(new SuggestionNotAvailable(showId, partyRequested)); }
public async static Task <SuggestionsMade> MakeSuggestionsImperativeShell(Ports.IProvideUpToDateAuditoriumSeating auditoriumSeatingProvider, ShowId id, PartyRequested partyRequested) { // non-pure function var auditoriumSeating = await auditoriumSeatingProvider.GetAuditoriumSeating(id); // call pure function return(SeatAllocator .TryMakeSuggestions(id, partyRequested, auditoriumSeating) .GetValueOrFallback(new SuggestionNotAvailable(id, partyRequested))); // Balance restored: // - inner hexagon knows about adapter capabilities but not implementation // - orchestration is back in the 'core' where we can locally reason about it // Notes: // in this case the imperative shells can be easily distinguished by the 'async' keyword which kind of plays the role of the IO<> marker type. }