/// <summary>
        /// 创建一个组织
        /// </summary>
        /// <param name="org"></param>
        /// <returns></returns>
        public OperationResult CreateOrganization(OrganizationDTO organization)
        {
            //数据校验
            OperationResult result = Validate(organization);

            if (!result.Success)
            {
                return(result);
            }

            organization = _dal.CreateOrganization(organization);

            if (organization != null)
            {
                OrganizationCreatedEvent @event = new OrganizationCreatedEvent()
                {
                    OrgId  = organization.Id,
                    UserId = organization.MasterId
                };


                _eventBus.PublishAsync <OrganizationCreatedEvent>(@event);
            }

            result.Success  = organization != null;
            result.ObjectId = organization.Id;

            return(result);
        }
 public void Handle(OrganizationCreatedEvent message)
 {
     using (IDbConnection connection = _connectionFactory.CreateConnection())
     {
         connection.Execute(
             "INSERT INTO OrganizationModule.Organization(OrganizationKey, Name) VALUES(@OrganizationKey, @Name)",
             new
         {
             OrganizationKey = message.Key,
             message.Name
         });
     }
 }
Example #3
0
 private void Apply(OrganizationCreatedEvent organizationCreatedEvent)
 {
     Name = organizationCreatedEvent.Name;
 }