Implementing a command
As we remember, a command is expected to carry out actions that will augment the data in the data store, otherwise called a write operation. Given that we are using the Mediator pattern to govern how we carry out these operations, we will need a command model and a handler.
Creating a command model
Our model is relatively simple to implement. It tends to be a standard class or record, but with MediatR present,we will implement a new type called IRequest. IRequest will associate this model class with an associated handler, which we will be looking into in a bit.
In the example of making an appointment in our system, we can relatively easily implement a CreateAppointmentCommand.cs file like this:
public record CreateAppointmentCommand (int   AppointmentTypeId, Guid DoctorId, Guid PatientId, Guid     RoomId, DateTime Start, DateTime End, string Title):       IRequest<string>;
We use...