public SecurityPolicy( Guid policyId, string clientId, SecuredApplication root) : base(policyId, root) { //n.b. this method is called only inside an apply handler in the root aggregate // so setting values is ok, but raising events is not // the create event is raised in the root aggregate Register <ApplicationMsgs.RoleCreated>(Apply); ClientId = clientId; OneRolePerUser = root.OneRolePerUser; }
public CommandResponse Handle(ApplicationMsgs.CreateApplication cmd) { if (_rm.ApplicationExists(cmd.Name, new Version(cmd.SecurityModelVersion))) { throw new DuplicateApplicationException(cmd.Name, cmd.SecurityModelVersion); } var app = new Domain.SecuredApplication( cmd.ApplicationId, cmd.DefaultPolicyId, cmd.Name, cmd.SecurityModelVersion, cmd.OneRolePerUser, cmd); _repo.Save(app); return(cmd.Succeed()); }