コード例 #1
0
        public async Task <IActionResult> UpdateAddress(int Id, SkuRequest request)
        {
            var sku = await _skuService.GetSkuByIdAsync(Id);

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

            _mapper.Map(request, sku);

            _skuService.UpdateSkuAsync(sku);

            await _skuService.SaveChangesAsync();

            return(Ok(_mapper.Map <SkuResponse>(sku)));
        }
コード例 #2
0
        public async Task <IActionResult> CreateAddress([FromBody] SkuRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { error = "" }));
            }
            var sku = _mapper.Map <Sku>(request);

            var created = await _skuService.CreateSkuAsync(sku);

            if (!created)
            {
                return(BadRequest(new { error = "Unable to create sku" }));
            }

            return(CreatedAtRoute(nameof(GetSkuById), new { Id = sku.Id }, _mapper.Map <SkuResponse>(sku)));
        }
コード例 #3
0
        /// <inheritdoc />
        /// <summary>
        /// Adds a discount coupon to the cart &lt;b&gt;Permissions Needed:&lt;/b&gt; SHOPPING_CARTS_ADMIN or owner
        /// </summary>
        /// <param name="id">The id of the cart</param>
        /// <param name="skuRequest">The request of the sku</param>
        public void AddDiscountToCart(string id, SkuRequest skuRequest)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling AddDiscountToCart");
            }

            mWebCallEvent.WebPath = "/carts/{id}/discounts";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "id" + "}", KnetikClient.ParameterToString(id));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(skuRequest); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mAddDiscountToCartStartTime = DateTime.Now;
            mWebCallEvent.Context       = mAddDiscountToCartResponseContext;
            mWebCallEvent.RequestType   = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mAddDiscountToCartStartTime, "AddDiscountToCart", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
コード例 #4
0
 public ProductInfo SkuSearchRequest(SkuRequest SkuSearchRequest)
 {
     object[] results = this.Invoke("SkuSearchRequest", new object[] {
         SkuSearchRequest});
     return ((ProductInfo)(results[0]));
 }
コード例 #5
0
 public System.IAsyncResult BeginSkuSearchRequest(SkuRequest SkuSearchRequest, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("SkuSearchRequest", new object[] {
         SkuSearchRequest}, callback, asyncState);
 }