コード例 #1
0
 private void Apply(RegistrationCreated @event)
 {
     Id                 = @event.AggregateRootId;
     Person             = @event.Person;
     RegistrationTarget = @event.RegistrationTarget;
     RegistrationDate   = @event.RegistrationDate;
 }
コード例 #2
0
 public void When(RegistrationCreated e)
 {
     Id = e.Id;
     Customer = e.Customer.CustomerId;
     Security = e.Security.SecurityId;
     CustomerInfo = e.Customer;
     SecurityInfo = e.Security;
 }
コード例 #3
0
 public void When(RegistrationCreated e)
 {
     _entity.Add(e.Id, new RegistrationView
     {
         Status       = "Processing registration",
         Registration = e.Id,
     });
 }
コード例 #4
0
 public void When(RegistrationCreated e)
 {
     _entity.Add(e.Id, new RegistrationView
     {
         Status = "Processing registration",
         Registration = e.Id
     });
 }
コード例 #5
0
 public void When(RegistrationCreated e)
 {
     Id           = e.Id;
     Customer     = e.Customer.CustomerId;
     Security     = e.Security.SecurityId;
     CustomerInfo = e.Customer;
     SecurityInfo = e.Security;
 }
コード例 #6
0
ファイル: Registration.cs プロジェクト: trbngr/orleans-es
        public async Task <Either <Error, RegistrationCreated> > Create(CreateRegistration command)
        {
            if (State.Created)
            {
                return(Left <Error, RegistrationCreated>(Error.New("Registration already exists")));
            }

            var e = new RegistrationCreated
            {
                Email     = command.Email,
                FirstName = command.FirstName
            };

            RaiseEvent(e);
            await SendWelcomeEmail(command);

            return(Right <Error, RegistrationCreated>(e));
        }
コード例 #7
0
        public UUID Register(string appName, string host)
        {
            if (string.IsNullOrWhiteSpace(appName))
            {
                throw new RpcException(new Grpc.Core.Status(StatusCode.InvalidArgument, $"Application name { appName } cannot be null or empty"));
            }

            if (string.IsNullOrWhiteSpace(host))
            {
                throw new RpcException(new Grpc.Core.Status(StatusCode.InvalidArgument, $"Host { host } cannot be null or empty"));
            }

            if (!Uri.TryCreate(host, UriKind.Absolute, out var _))
            {
                throw new RpcException(new Grpc.Core.Status(StatusCode.InvalidArgument, $"Host { host } is not a valid host"));
            }

            var existingRegistration = _registrations.Values.FirstOrDefault(x => x.AppName.Equals(appName, StringComparison.OrdinalIgnoreCase) && x.Host.Equals(host, StringComparison.OrdinalIgnoreCase));

            if (existingRegistration != null)
            {
                return(existingRegistration.UniqueIdentifier);
                //throw new RpcException(new Grpc.Core.Status(StatusCode.AlreadyExists, $"Application name { appName } with host { host } already registered"));
            }

            var uniqueIdGuid = Guid.NewGuid();
            var uniqueId     = new UUID()
            {
                Value = uniqueIdGuid.ToString()
            };

            _registrations.AddOrUpdate(uniqueIdGuid, (key) => new Registration(uniqueId, appName, host), (key, value) => new Registration(uniqueId, appName, host));

            var registration = new RegistrationCreatedEventArgs()
            {
                Registration = _registrations[uniqueIdGuid]
            };

            RegistrationCreated?.Invoke(this, registration);

            _logger.LogInformation($"Registered application with appName {appName} and host {host}");

            return(uniqueId);
        }
コード例 #8
0
        public void When(RegistrationCreated x)
        {
            // forwards token to customer
            var c = x.Customer;
            var s = x.Security;

            //_flow.ToCustomer(new CreateCustomerFromRegistration(
            //    c.CustomerId,
            //    x.Id,
            //    c.CompanyName,
            //    c.CustomerEmail,
            //    c.OptionalPhone,
            //    c.OptionalUrl,
            //    x.RegisteredUtc, c.CurrencyType, c.RealName));

            // and to security passport
            _flow.ToSecurity(new CreateSecurityFromRegistration(s.SecurityId, x.Id, s.Login, s.Pwd, s.UserDisplay,
                                                                s.OptionalIdentity));
            // TODO add timeout tracker
        }
コード例 #9
0
        public void When(RegistrationCreated x)
        {
            // forwards token to customer
            var c = x.Customer;
            var s = x.Security;

            //_flow.ToCustomer(new CreateCustomerFromRegistration(
            //    c.CustomerId,
            //    x.Id,
            //    c.CompanyName,
            //    c.CustomerEmail,
            //    c.OptionalPhone,
            //    c.OptionalUrl,
            //    x.RegisteredUtc, c.CurrencyType, c.RealName));

            // and to security passport
            _flow.ToSecurity(new CreateSecurityFromRegistration(s.SecurityId, x.Id, s.Login, s.Pwd, s.UserDisplay,
                s.OptionalIdentity));
            // TODO add timeout tracker
        }
コード例 #10
0
 public void Apply(RegistrationCreated _) => Created = true;