Beispiel #1
0
 public virtual async Task AddStoreUser(string storeId, StoreUserData request,
                                        CancellationToken token = default)
 {
     if (request == null)
     {
         throw new ArgumentNullException(nameof(request));
     }
     using var response = await _httpClient.SendAsync(
               CreateHttpRequest ($"api/v1/stores/{storeId}/users", bodyPayload : request, method : HttpMethod.Post),
               token);
     await HandleResponse(response);
 }
Beispiel #2
0
        public async Task <IActionResult> AddStoreUser(string storeId, StoreUserData request)
        {
            var store = HttpContext.GetStoreData();

            if (store == null)
            {
                return(StoreNotFound());
            }
            //we do not need to validate the role string as any value other than `StoreRoles.Owner` is currently treated like a guest
            if (await _storeRepository.AddStoreUser(storeId, request.UserId, request.Role))
            {
                return(Ok());
            }

            return(this.CreateAPIError(409, "duplicate-store-user-role", "The user is already added to the store"));
        }