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); } }
public async Task <Tenant> CreateAsync(string name) { Check.NotNull(name, nameof(name)); await ValidateNameAsync(name); return(new Tenant(IDUtils.NewId().ToString(), name)); }
protected virtual void SetId <TEntity>(TEntity entity) { if (entity is IEntity <string> entityWithStringId) { if (string.IsNullOrWhiteSpace(entityWithStringId.Id)) { entityWithStringId.Id = IDUtils.NewId().ToString(); } } }
/// <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)); }
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)); } }
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); }
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); }
public IntegrationEvent() { Id = IDUtils.NewId(); Timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(); }