public async Task <IActionResult> PostUsers(string appId, [FromBody] UpsertUsersDto request) { var response = new List <UserDto>(); if (request?.Requests != null) { if (request.Requests.Length > 100) { throw new ValidationException($"Only 100 users can be update in one request, found: {request.Requests.Length}"); } foreach (var dto in request.Requests) { if (dto != null) { var update = dto.ToUpdate(); var user = await userStore.UpsertAsync(appId, dto.Id, update, HttpContext.RequestAborted); response.Add(UserDto.FromDomainObject(user)); } } } return(Ok(response)); }
public async Task <IActionResult> GetUser(string appId, string id) { var user = await userStore.GetAsync(appId, id, HttpContext.RequestAborted); if (user == null) { return(NotFound()); } var response = UserDto.FromDomainObject(user); return(Ok(response)); }
public async Task <IActionResult> GetUsers(string appId, [FromQuery] QueryDto q, [FromQuery] bool withDetails = false) { var users = await userStore.QueryAsync(appId, q.ToQuery <UserQuery>(true), HttpContext.RequestAborted); IReadOnlyDictionary <string, Instant>?lastUpdates = null; if (withDetails) { lastUpdates = await QueryLastNotificationsAsync(appId, users.Select(x => x.Id)); } var response = new ListResponseDto <UserDto>(); response.Items.AddRange(users.Select(x => UserDto.FromDomainObject(x, null, lastUpdates))); response.Total = users.Total; return(Ok(response)); }
public async Task <IActionResult> GetUser(string appId, string id, [FromQuery] bool withDetails = false) { var user = await userStore.GetAsync(appId, id, HttpContext.RequestAborted); if (user == null) { return(NotFound()); } IReadOnlyDictionary <string, Instant>?lastUpdates = null; if (withDetails) { lastUpdates = await QueryLastNotificationsAsync(appId, Enumerable.Repeat(user.Id, 1)); } var response = UserDto.FromDomainObject(user, GetUserProperties(), lastUpdates); return(Ok(response)); }
public async Task <IActionResult> PostUsers(string appId, [FromBody] UpsertUsersDto request) { var response = new List <UserDto>(); if (request?.Requests != null) { foreach (var dto in request.Requests) { if (dto != null) { var update = dto.ToUpdate(); var user = await userStore.UpsertAsync(appId, dto.Id, update, HttpContext.RequestAborted); response.Add(UserDto.FromDomainObject(user)); } } } return(Ok(response)); }