Esempio n. 1
0
        public async Task IndexAsync()
        {
            //var post = new Post
            //{
            //    Title = "Hello World"
            //};
            //var request = new IndexRequest<Post>(post);
            //var response = _client.Index(post, idx => idx.Index("post"));

            var collection = new string[] { "A", "B", "C", "D" };

            foreach (var item in collection)
            {
                var user = new User
                {
                    Id   = IDUtils.NewId(),
                    Name = item
                };

                var request  = new IndexRequest <User>(user);
                var response = await _client.IndexAsync(user, idx => idx.Index(nameof(User).ToLower()));

                Assert.True(response.ApiCall.Success);
            }
        }
Esempio n. 2
0
        public async Task <Tenant> CreateAsync(string name)
        {
            Check.NotNull(name, nameof(name));

            await ValidateNameAsync(name);

            return(new Tenant(IDUtils.NewId().ToString(), name));
        }
Esempio n. 3
0
 protected virtual void SetId <TEntity>(TEntity entity)
 {
     if (entity is IEntity <string> entityWithStringId)
     {
         if (string.IsNullOrWhiteSpace(entityWithStringId.Id))
         {
             entityWithStringId.Id = IDUtils.NewId().ToString();
         }
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 授权
        /// </summary>
        /// <param name="name"></param>
        /// <param name="providerKey"></param>
        /// <returns></returns>
        protected virtual async Task GrantAsync(string name, string providerKey)
        {
            var permissionGrant = await PermissionGrantRepository.FindAsync(name, Name, providerKey);

            if (permissionGrant != null)
            {
                return;
            }

            await PermissionGrantRepository.InsertAsync(new PermissionGrant(IDUtils.NewId(), name, Name, providerKey, CurrentTenant.Id));
        }
Esempio n. 5
0
        public async Task SeedAsync(string providerName, string providerKey, IEnumerable <string> grantedPermissions, string tenantId = default)
        {
            foreach (var permissionName in grantedPermissions)
            {
                if (await PermissionGrantRepository.FindAsync(permissionName, providerName, providerKey) != null)
                {
                    continue;
                }

                await PermissionGrantRepository.InsertAsync(new PermissionGrant(IDUtils.NewId(), permissionName, providerName, providerKey, tenantId));
            }
        }
Esempio n. 6
0
        public async Task SearchAsync()
        {
            var user = new User
            {
                Id = IDUtils.NewId(),
            };


            var request  = new SearchRequest <User>();
            var response = await _client.SearchAsync <User>();

            Assert.True(response.ApiCall.Success);
        }
Esempio n. 7
0
        public void CreateDocument()
        {
            var user = new User
            {
                Id   = IDUtils.NewId(),
                Name = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff")
            };

            var request = new CreateRequest <User>(user.Id);

            var response = _client.CreateDocument(user);

            Assert.True(response.ApiCall.Success);
        }
Esempio n. 8
0
 public IntegrationEvent()
 {
     Id        = IDUtils.NewId();
     Timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
 }