public void AddInstance(DateTime installDate, ServerId serverId, OrganizationId organizationId, LicenseKey key) { var license = Licenses.First(x => x.Key.Equals(key)); if (license is null) { // todo: use domain exception throw new Exception("This key not exist"); } if (license.ActivationsInstances.Count() >= license.ActivationsCount) { // todo: use domain exception throw new Exception("This license has a maximum number of copies"); } if (!license.OrganizationId.Equals(organizationId)) { // todo: use domain exception throw new Exception("You cannot apply the license of someone else's organization"); } Apply(new LicensedSoftwareInstanceCreatedEvent(SoftwareInstanceId.Create(), installDate, serverId, organizationId, key)); }
private void Apply(DemoSoftwareInstanceCreatedEvent @event) { var instance = new DemoSoftwareInstance(SoftwareInstanceId.Create(), @event.InstallDate, @event.ServerId, @event.OrganizationId, @event.Expiration); _instances.Add(instance); }
protected SoftwareInstanceCreatedEvent(SoftwareInstanceId id, DateTime installDate, ServerId serverId, OrganizationId organizationId) { Id = id; InstallDate = installDate; ServerId = serverId; OrganizationId = organizationId; }
public void AddInstance(DateTime installDate, ServerId serverId, OrganizationId organizationId) { var instance = new FreeSoftwareInstance(SoftwareInstanceId.Create(), installDate, serverId, organizationId); _instances.Add(instance); ApplyEvent(new FreeSoftwareInstanceCreatedEvent(instance.Id, instance.InstallDate, instance.ServerId, instance.OrganizationId)); }
public LicensedSoftwareInstanceCreatedEvent(SoftwareInstanceId id, DateTime installDate, ServerId serverId, OrganizationId organizationId, LicenseKey key) : base(id, installDate, serverId, organizationId) { Key = key; }
public void AddDemoInstance(DateTime installDate, ServerId serverId, OrganizationId organizationId, DateTime expiration) { Apply(new DemoSoftwareInstanceCreatedEvent(SoftwareInstanceId.Create(), installDate, serverId, organizationId, expiration)); }
public DemoSoftwareInstanceCreatedEvent(SoftwareInstanceId id, DateTime installDate, ServerId serverId, OrganizationId organizationId, DateTime expiration) : base(id, installDate, serverId, organizationId) { Expiration = expiration; }
public FreeSoftwareInstanceCreatedEvent(SoftwareInstanceId id, DateTime installDate, ServerId serverId, OrganizationId organizationId) : base(id, installDate, serverId, organizationId) { }