You built the quotes as an aggregate from the start in this module. The appointments you didn't: they come from K2, they work, the office plans with them every day, and visitors book through the public page. Since lesson 4.3.6 they have lived in the module Kladde.Appointments, but their model is still the one from K2. Now the office's owner wants two new rules: there must be at least 15 minutes between two appointments, and whoever has booked an appointment may cancel it only up to 24 hours before.

You could simply write the two rules in where the old ones are. In this lesson you do it differently: you first restructure the appointments into an aggregate without changing their behavior, and only then write the new rules in exactly one place. The tools for that are characterization tests and a series of small steps, each of which can be delivered on its own.

Where the rules of the appointments live today

After K2 and lesson 4.3.6, this is how it looks in the solutions. Your names may differ; then transfer the steps to yours.

Rule Where it lives Kind
a title, quarter hours, end after start, at most eight hours AppointmentTimes.Check, called by Appointment.Plan and MoveTo in the model
no overlap AppointmentPlanner loads the other appointments and compares; plus the primary key of the table AppointmentSlots in a service and in the database
free times of the public booking FreeSlots.For compares by itself with the occupied times a second version of the same rule
cancel a booking up to the start Booking.CanBeCancelled, asked by the page CancelBooking.razor; the store deletes without a check of its own at the edge
an appointment of the office is struck the endpoint deletes without a rule

That is the typical picture of a context that started out as CRUD. The class Appointment checks its own values, everything that concerns several appointments sits in a service next to it, and the rule for cancellation applies only if the caller thinks of it. The new buffer time would have to be added in two places, in the planner and in the free times, the cancellation notice in a third. This is exactly how contradictions arise, as in the lab of lesson 4.3.3.