public static RegistrationChanged Create(Identifier id, ClinicLicense license) { return(new RegistrationChanged { EntityId = id, Jurisdiction = license.Jurisdiction, Number = license.CertificateNumber, ModifiedUtc = DateTime.UtcNow }); }
protected override void OnStateChanged(IChangeEvent @event) { switch (@event) { case Events.Clinic.Created _: break; case Events.Clinic.LocationChanged changed: Location = new Location(changed.Country, changed.City, changed.Street); Logger.LogDebug("Clinic {Id} changed location to {Country}, {City}, {Street}", Id, changed.Country, changed.City, changed.Street); break; case Events.Clinic.OwnershipChanged changed: Owner = new ClinicOwner(changed.Owner); Managers.Add(changed.Owner.ToIdentifier()); Logger.LogDebug("Clinic {Id} changed ownership to {Owner}", Id, Owner); break; case Events.Clinic.RegistrationChanged changed: License = new ClinicLicense(changed.Jurisdiction, changed.Number); Logger.LogDebug("Clinic {Id} registration changed to {Jurisdiction}, {CertificateNumber}", Id, changed.Jurisdiction, changed.Number); break; case Events.Clinic.DoctorUnavailabilitySlotAdded added: var unavailability = new UnavailabilityEntity(Logger, IdFactory); added.EntityId = unavailability.Id; unavailability.SetAggregateEventHandler(RaiseChangeEvent); RaiseToEntity(unavailability, @event); Unavailabilities.Add(unavailability); Logger.LogDebug("Doctor {Id} had been made unavailable from {From} until {To}", Id, added.From, added.To); break; case Events.Clinic.DoctorRegisteredToClinic added: Doctors.Add(added.DoctorId.ToIdentifier()); Logger.LogDebug("Doctor {Id} had been registered to clinic {Clinic}", added.DoctorId, Id); break; default: throw new InvalidOperationException($"Unknown event {@event.GetType()}"); } }
public Clinic Register(ICurrentCaller caller, string id, string jurisdiction, string certificateNumber) { caller.GuardAgainstNull(nameof(caller)); id.GuardAgainstNullOrEmpty(nameof(id)); var clinic = this.storage.Load(id.ToIdentifier()); if (clinic == null) { throw new ResourceNotFoundException(); } var license = new ClinicLicense(jurisdiction, certificateNumber); clinic.Register(license); var updated = this.storage.Save(clinic); this.logger.LogInformation("Clinic {Id} was registered with plate {License}, by {Caller}", id, license, caller.Id); return(updated.ToClinic()); }
public void Register(ClinicLicense plate) { RaiseChangeEvent(ClinicsDomain.Events.Clinic.RegistrationChanged.Create(Id, plate)); }