|
|
@ -7,7 +7,6 @@ |
|
|
// ==========================================================================
|
|
|
// ==========================================================================
|
|
|
|
|
|
|
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
|
|
|
using Squidex.Domain.Apps.Core; |
|
|
using Squidex.Domain.Apps.Core; |
|
|
using Squidex.Domain.Apps.Core.Apps; |
|
|
using Squidex.Domain.Apps.Core.Apps; |
|
|
using Squidex.Domain.Apps.Events; |
|
|
using Squidex.Domain.Apps.Events; |
|
|
@ -48,11 +47,6 @@ namespace Squidex.Domain.Apps.Write.Apps |
|
|
get { return contributors.Count; } |
|
|
get { return contributors.Count; } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public IReadOnlyDictionary<string, AppClient> Clients |
|
|
|
|
|
{ |
|
|
|
|
|
get { return clients.Clients; } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public AppDomainObject(Guid id, int version) |
|
|
public AppDomainObject(Guid id, int version) |
|
|
: base(id, version) |
|
|
: base(id, version) |
|
|
{ |
|
|
{ |
|
|
@ -78,6 +72,11 @@ namespace Squidex.Domain.Apps.Write.Apps |
|
|
clients.Add(@event.Id, @event.Secret); |
|
|
clients.Add(@event.Id, @event.Secret); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void On(AppClientChanged @event) |
|
|
|
|
|
{ |
|
|
|
|
|
clients.Change(@event.Id, @event.IsReader); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
protected void On(AppClientRenamed @event) |
|
|
protected void On(AppClientRenamed @event) |
|
|
{ |
|
|
{ |
|
|
clients.Rename(@event.Id, @event.Name); |
|
|
clients.Rename(@event.Id, @event.Name); |
|
|
@ -131,6 +130,25 @@ namespace Squidex.Domain.Apps.Write.Apps |
|
|
return this; |
|
|
return this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public AppDomainObject UpdateClient(UpdateClient command) |
|
|
|
|
|
{ |
|
|
|
|
|
Guard.Valid(command, nameof(command), () => "Cannot rename client"); |
|
|
|
|
|
|
|
|
|
|
|
ThrowIfNotCreated(); |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(command.Name)) |
|
|
|
|
|
{ |
|
|
|
|
|
RaiseEvent(SimpleMapper.Map(command, new AppClientRenamed())); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (command.IsReader.HasValue) |
|
|
|
|
|
{ |
|
|
|
|
|
RaiseEvent(SimpleMapper.Map(command, new AppClientChanged { IsReader = command.IsReader.Value })); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public AppDomainObject AssignContributor(AssignContributor command) |
|
|
public AppDomainObject AssignContributor(AssignContributor command) |
|
|
{ |
|
|
{ |
|
|
Guard.Valid(command, nameof(command), () => "Cannot assign contributor"); |
|
|
Guard.Valid(command, nameof(command), () => "Cannot assign contributor"); |
|
|
@ -164,17 +182,6 @@ namespace Squidex.Domain.Apps.Write.Apps |
|
|
return this; |
|
|
return this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public AppDomainObject RenameClient(RenameClient command) |
|
|
|
|
|
{ |
|
|
|
|
|
Guard.Valid(command, nameof(command), () => "Cannot rename client"); |
|
|
|
|
|
|
|
|
|
|
|
ThrowIfNotCreated(); |
|
|
|
|
|
|
|
|
|
|
|
RaiseEvent(SimpleMapper.Map(command, new AppClientRenamed())); |
|
|
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public AppDomainObject RevokeClient(RevokeClient command) |
|
|
public AppDomainObject RevokeClient(RevokeClient command) |
|
|
{ |
|
|
{ |
|
|
Guard.Valid(command, nameof(command), () => "Cannot revoke client"); |
|
|
Guard.Valid(command, nameof(command), () => "Cannot revoke client"); |
|
|
|