public JsonResult Update(ProductDetailView vm)
        {
            GetProductRequest request = new GetProductRequest();

            request.ProductID = vm.ProductID;

            ModifyProductRequest updateRequest = _productService.GetProduct(request).Product.ConvertToModifyProductRequest();

            updateRequest.ProductID   = vm.ProductID;
            updateRequest.ProductName = vm.ProductName;
            GetSupplierRequest supplierRequest = new GetSupplierRequest();

            supplierRequest.SupplierID = vm.SupplierSupplierID;
            updateRequest.Supplier     = _supplierService.GetSupplier(supplierRequest).Supplier;
            GetCategoryRequest categoryRequest = new GetCategoryRequest();

            categoryRequest.CategoryID    = vm.CategoryCategoryID;
            updateRequest.Category        = _categoryService.GetCategory(categoryRequest).Category;
            updateRequest.QuantityPerUnit = vm.QuantityPerUnit;
            updateRequest.UnitPrice       = vm.UnitPrice;
            updateRequest.UnitsInStock    = vm.UnitsInStock;
            updateRequest.UnitsOnOrder    = vm.UnitsOnOrder;
            updateRequest.ReorderLevel    = vm.ReorderLevel;
            updateRequest.Discontinued    = vm.Discontinued;

            ModifyProductResponse response = _productService.ModifyProduct(updateRequest);

            return(Json(response));
        }
Example #2
0
        internal async Task <ModifyProductResponse> ModifyProduct(ModifyProductRequest request)
        {
            if (request == null)
            {
                throw new Exception("No data provided to API");
            }

            var idString = PrintfulIdHelper.GetIdOrExternalId(request.ProductId, request.ExternalId);

            var apiResponse =
                await _client.PutAsync <ModifyProductResponse, PutRequestProductBody>($"store/products/{idString}",
                                                                                      request.PutRequestProductBody);

            return(apiResponse);
        }
Example #3
0
        /// <summary>
        /// 修改产品信息
        /// </summary>
        /// <param name="req"><see cref="ModifyProductRequest"/></param>
        /// <returns><see cref="ModifyProductResponse"/></returns>
        public ModifyProductResponse ModifyProductSync(ModifyProductRequest req)
        {
            JsonResponseModel <ModifyProductResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "ModifyProduct");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <ModifyProductResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
Example #4
0
        public ModifyProductResponse ModifyProduct(ModifyProductRequest request)
        {
            ModifyProductResponse response = new ModifyProductResponse();

            Product product = _productRepository
                              .FindBy(request.ProductID);

            product.Id              = request.ProductID;
            product.ProductName     = request.ProductName;
            product.QuantityPerUnit = request.QuantityPerUnit;
            product.UnitPrice       = request.UnitPrice;
            product.UnitsInStock    = request.UnitsInStock;
            product.UnitsOnOrder    = request.UnitsOnOrder;
            product.ReorderLevel    = request.ReorderLevel;
            product.Discontinued    = request.Discontinued;
            product.Orders          = request.Orders.ConvertToOrders();
            product.Category        = request.Category.ConvertToCategory();
            product.Supplier        = request.Supplier.ConvertToSupplier();


            if (product.GetBrokenRules().Count() > 0)
            {
                response.Errors = product.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _productRepository.Save(product);
                    _uow.Commit();
                    response.Errors = new List <BusinessRule>();
                } catch (Exception ex)
                {
                    response.Errors = new List <BusinessRule>();
                    response.Errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message));
                }
            }


            return(response);
        }
Example #5
0
        public async Task <ModifyProductResponse> ModifyProduct(ModifyProductRequest request)
        {
            var result = await _productService.ModifyProduct(request);

            return(result);
        }