コード例 #1
0
ファイル: Events.cs プロジェクト: jezzsantos/queryany
 public static OwnershipChanged Create(Identifier id, VehicleOwner owner)
 {
     return(new OwnershipChanged
     {
         EntityId = id,
         Owner = owner.OwnerId,
         Managers = new List <string> {
             owner.OwnerId
         },
         ModifiedUtc = DateTime.UtcNow
     });
 }
コード例 #2
0
ファイル: CarEntity.cs プロジェクト: jezzsantos/queryany
        protected override void OnStateChanged(IChangeEvent @event)
        {
            switch (@event)
            {
            case Events.Car.Created _:
                break;

            case Events.Car.ManufacturerChanged changed:
                Manufacturer = new Manufacturer(changed.Year, changed.Make, changed.Model);
                Recorder.TraceDebug("Car {Id} changed manufacturer to {Year}, {Make}, {Model}", Id, changed.Year,
                                    changed.Make, changed.Model);
                break;

            case Events.Car.OwnershipChanged changed:
                Owner    = new VehicleOwner(changed.Owner);
                Managers = new VehicleManagers();
                Managers.Add(changed.Owner.ToIdentifier());

                Recorder.TraceDebug("Car {Id} changed ownership to {Owner}", Id, Owner);
                break;

            case Events.Car.RegistrationChanged changed:
                Plate = new LicensePlate(changed.Jurisdiction, changed.Number);

                Recorder.TraceDebug("Car {Id} registration changed to {Jurisdiction}, {Number}", Id,
                                    changed.Jurisdiction, changed.Number);
                break;

            case Events.Car.UnavailabilitySlotAdded added:
                var unavailability = new UnavailabilityEntity(Recorder, IdFactory);
                added.EntityId = unavailability.Id;
                unavailability.SetAggregateEventHandler(RaiseChangeEvent);
                RaiseToEntity(unavailability, @event);
                Unavailabilities.Add(unavailability);
                Recorder.TraceDebug("Car {Id} had been made unavailable from {From} until {To}", Id, added.From,
                                    added.To);
                break;

            default:
                throw new InvalidOperationException($"Unknown event {@event.GetType()}");
            }
        }
コード例 #3
0
ファイル: CarEntity.cs プロジェクト: jezzsantos/queryany
 public void SetOwnership(VehicleOwner owner)
 {
     RaiseChangeEvent(CarsDomain.Events.Car.OwnershipChanged.Create(Id, owner));
 }