private void Apply(DemoSoftwareInstanceCreatedEvent @event) { var instance = new DemoSoftwareInstance(SoftwareInstanceId.Create(), @event.InstallDate, @event.ServerId, @event.OrganizationId, @event.Expiration); _instances.Add(instance); }
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)); }
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 void AddDemoInstance(DateTime installDate, ServerId serverId, OrganizationId organizationId, DateTime expiration) { Apply(new DemoSoftwareInstanceCreatedEvent(SoftwareInstanceId.Create(), installDate, serverId, organizationId, expiration)); }