Esempio n. 1
0
        public async Task RemoveItem_JSON()
        {
            var removeinfo = new RemoveItemRequest(new string[] { "testseller#1", "testseller#2" });
            var result     = await fakeapi_json.RemoveItem("88237462", removeinfo);

            Assert.IsType <RemoveItemResponse>(result);
            //Assert.Equal("88237462", result.ResponseBody.Orders.OrderNumber);
        }
Esempio n. 2
0
        public async Task RemoveItem(RemoveItemRequest request)
        {
            var removed = await _todoListService.RemoveItem(request.ListId, request.ItemId);

            await Clients.Group(request.ListId.ToString()).SendAsync("Remove", new RemoveItemResponse()
            {
                Removed = removed
            });
        }
Esempio n. 3
0
        public async Task RemoveItemFromCart(Guid cartId, RemoveItemRequest request)
        {
            var command = new RemoveItem
            {
                AggregateRootId = cartId,
                ProductName     = request.ProductName
            };

            await dispatcher.SendAndPublishAsync <RemoveItem, Cart>(command);
        }
Esempio n. 4
0
        public async Task RemoveItem_JSON()
        {
            var removeinfo = new RemoveItemRequest(new string[] { "AWHZ3434" });
            var result     = await fakeapi_json.RemoveItem("88237462", removeinfo);

            Assert.IsType <RemoveItemResponse>(result);
            Assert.Equal("88237462", result.ResponseBody.Orders.OrderNumber);
            Assert.True(result.ResponseBody.Orders.Result.ItemList.Count == 1);
            Assert.Equal("AWHZ3434", result.ResponseBody.Orders.Result.ItemList[0].SellerPartNumber);
        }
Esempio n. 5
0
        public async Task <HttpResponse <RemoveItemResponse> > RemoveItemAsync(RemoveItemRequest request)
        {
            var response = await PostAsync <RemoveItemResponse>($"{ApiRoot}/BasketApi/RemoveItem", request);

            if (response.ResponseContent.ResponseCode == "99999")
            {
                response.StatusCode = HttpStatusCode.BadRequest;
            }

            return(response);
        }
Esempio n. 6
0
        public async Task <RemoveItemResponse> RemoveItem(string OrderNumber, RemoveItemRequest reqModel, ConnectSetting connectSetting = null, LoggingConfiguration logSetting = null)
        {
            var request = CreateRequest <RemoveItemRequest>(reqModel);

            request.URI = string.Format("ordermgmt/killitem/orders/{0}", OrderNumber);

            var response = await client.PutAsync(request, connectSetting);

            var result = await ProcessResponse <RemoveItemResponse>(response);

            return(result);
        }
Esempio n. 7
0
        public void RemoveItemFromCart()
        {
            using (var host = new WebHostBuilder()
                              .UseUrls(BaseUrl)
                              .UseKestrel()
                              .UseStartup <Startup>()
                              .Build())
            {
                host.Start();

                var request = new RemoveItemRequest("iPhone X");

                var cart = Client.RemoveItemFromCartWithHttpMessagesAsync(Guid.NewGuid(), Version, request);

                Assert.Equal(HttpStatusCode.NoContent, cart.Result.Response.StatusCode);
            }
        }
Esempio n. 8
0
        public async Task <IActionResult> Delete(Guid cartId, [FromBody] RemoveItemRequest request)
        {
            var validationResult = new RemoveItemValidator().Validate(request);

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.Errors));
            }

            var cart = await service.GetCart(cartId);

            if (cart == null)
            {
                return(NotFound());
            }

            await service.RemoveItemFromCart(cartId, request);

            return(NoContent());
        }
Esempio n. 9
0
        private void RemoveItem(RemoveItemRequest request)
        {
            Assert.IsNotNull(request);

            var prop  = Sequence.GetArrayElementAtIndex(request.index);
            var asset = prop.objectReferenceValue;

            Assert.IsNotNull(asset);

            if (!EditorUtility.DisplayDialog("UI Animation Asset", "Are you really want to delete " + asset.name + "?", "Delete", "Cancel"))
            {
                return;
            }

            prop.objectReferenceValue = null;
            Sequence.DeleteArrayElementAtIndex(request.index);

            ScriptableObject.DestroyImmediate(asset, true);

            ReimportMainAsset();
        }
        public async Task <IActionResult> RemoveItem(string basketId, [FromBody] RemoveItemRequest request)
        {
            var validation = new RemoveItemValidator().Validate(request);

            if (!validation.IsValid)
            {
                return(BadRequest(validation.Errors));
            }

            var basketReadModel = await queryProcessor.ProcessAsync(new ReadModelByIdQuery <BasketReadModel>(basketId), CancellationToken.None);

            if (basketReadModel == null)
            {
                return(NotFound());
            }

            try
            {
                var task = await commandBus.PublishAsync(
                    new RemoveItem(new BasketId(basketId), request.ProductName), CancellationToken.None);

                if (task.IsSuccess)
                {
                    return(NoContent());
                }
            }
            catch (BasketException ex)
            {
                return(new JsonResult(ex.Message)
                {
                    StatusCode = (int)HttpStatusCode.NotFound
                });
            }

            return(BadRequest());
        }
Esempio n. 11
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cartId'>
 /// </param>
 /// <param name='version'>
 /// </param>
 /// <param name='request'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task RemoveItemFromCartAsync(this IShoppingCartAPI operations, System.Guid cartId, string version, RemoveItemRequest request = default(RemoveItemRequest), CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.RemoveItemFromCartWithHttpMessagesAsync(cartId, version, request, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='basketId'>
 /// </param>
 /// <param name='request'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task RemoveItemAsync(this IShoppingBasketAPI operations, string basketId, RemoveItemRequest request = default(RemoveItemRequest), CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.RemoveItemWithHttpMessagesAsync(basketId, request, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='basketId'>
 /// </param>
 /// <param name='request'>
 /// </param>
 public static void RemoveItem(this IShoppingBasketAPI operations, string basketId, RemoveItemRequest request = default(RemoveItemRequest))
 {
     operations.RemoveItemAsync(basketId, request).GetAwaiter().GetResult();
 }
Esempio n. 14
0
        /// <param name='cartId'>
        /// </param>
        /// <param name='version'>
        /// </param>
        /// <param name='request'>
        /// </param>
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="HttpOperationException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <return>
        /// A response object containing the response body and response headers.
        /// </return>
        public async Task <HttpOperationResponse> RemoveItemFromCartWithHttpMessagesAsync(System.Guid cartId, string version, RemoveItemRequest request = default(RemoveItemRequest), Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (version == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "version");
            }
            // Tracing
            bool   _shouldTrace  = ServiceClientTracing.IsEnabled;
            string _invocationId = null;

            if (_shouldTrace)
            {
                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("cartId", cartId);
                tracingParameters.Add("request", request);
                tracingParameters.Add("version", version);
                tracingParameters.Add("cancellationToken", cancellationToken);
                ServiceClientTracing.Enter(_invocationId, this, "ApiVversionCartByCartIdDelete", tracingParameters);
            }
            // Construct URL
            var _baseUrl = BaseUri.AbsoluteUri;
            var _url     = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/v{version}/Cart/{cartId}").ToString();

            _url = _url.Replace("{cartId}", System.Uri.EscapeDataString(SafeJsonConvert.SerializeObject(cartId, SerializationSettings).Trim('"')));
            _url = _url.Replace("{version}", System.Uri.EscapeDataString(version));
            // Create HTTP transport objects
            var _httpRequest = new HttpRequestMessage();
            HttpResponseMessage _httpResponse = null;

            _httpRequest.Method     = new HttpMethod("DELETE");
            _httpRequest.RequestUri = new System.Uri(_url);
            // Set Headers


            if (customHeaders != null)
            {
                foreach (var _header in customHeaders)
                {
                    if (_httpRequest.Headers.Contains(_header.Key))
                    {
                        _httpRequest.Headers.Remove(_header.Key);
                    }
                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
                }
            }

            // Serialize Request
            string _requestContent = null;

            if (request != null)
            {
                _requestContent      = SafeJsonConvert.SerializeObject(request, SerializationSettings);
                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
                _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json-patch+json; charset=utf-8");
            }
            // Send Request
            if (_shouldTrace)
            {
                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);

            if (_shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
            }
            HttpStatusCode _statusCode = _httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string _responseContent = null;

            if ((int)_statusCode != 204 && (int)_statusCode != 400 && (int)_statusCode != 404)
            {
                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
                if (_httpResponse.Content != null)
                {
                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                }
                else
                {
                    _responseContent = string.Empty;
                }
                ex.Request  = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
                if (_shouldTrace)
                {
                    ServiceClientTracing.Error(_invocationId, ex);
                }
                _httpRequest.Dispose();
                if (_httpResponse != null)
                {
                    _httpResponse.Dispose();
                }
                throw ex;
            }
            // Create Result
            var _result = new HttpOperationResponse();

            _result.Request  = _httpRequest;
            _result.Response = _httpResponse;
            if (_shouldTrace)
            {
                ServiceClientTracing.Exit(_invocationId, _result);
            }
            return(_result);
        }