Esempio n. 1
0
        public void RegiseterProductInfo()
        {
            try
            {
                RegisterProductAddtionalInfoRequest par  = new RegisterProductAddtionalInfoRequest();
                List <ProductAddtionalInfoView>     list = new List <ProductAddtionalInfoView>();
                list.Add(new ProductAddtionalInfoView()
                {
                    Name  = "测试附件",
                    Path  = "~~~",
                    Rtype = 1,
                });
                par.productAddtionalInfoView = list;
                RegisterProductRequest requset = new RegisterProductRequest()
                {
                    ProductInfo = new ProductInfoView()
                    {
                        Id                    = "614141999996",
                        Name                  = "测试项",
                        TypeVersion           = "测试项",
                        ProductAddtionalInfos = list
                    }
                    //RegisterProductAddtionalInfoRequest = par
                };

                RegisterProductResponse response = _service.RegisterProduct(requset);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false);
            }
        }
Esempio n. 2
0
        public RegisterProductResponse RegisterProduct(RegisterProductRequest request)
        {
            RegisterProductResponse response = new RegisterProductResponse();

            try
            {
                using (IUnitOfWork unitOfWork = RepositoryFactory.GetUnitOfWork())
                {
                    if (request != null && request.ProductInfo != null)
                    {
                        ProductInfo registerProductInfo = request.ProductInfo.Map <ProductInfo, ProductInfoView>();

                        registerProductInfo.Register();
                        IProductInfoRepository productInfoRepository = RepositoryFactory.Get(typeof(IProductInfoRepository), unitOfWork) as IProductInfoRepository;
                        if (productInfoRepository.GetAll().Where(it => it.Id.Equals(registerProductInfo.Id)).FirstOrDefault() == null)
                        {
                            productInfoRepository.Add(registerProductInfo);
                            unitOfWork.Commit();
                            response.IsSucess    = true;
                            response.ProductInfo = registerProductInfo.Map <ProductInfoView, ProductInfo>();
                        }
                        else
                        {
                            response.IsSucess = false;
                            response.Message  = "已存在的产品Id!";
                        }
                    }
                    else
                    {
                        response.IsSucess = false;
                        response.Message  = "No Input!";
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex.Message);
                response.IsSucess = false;
                response.Message  = ex.Message;
            }
            return(response);
        }
Esempio n. 3
0
        public string RegisterProduct(String username, String product)
        {
            ProductInfoView registerProduct = JsonHelper.DeserializeObject <ProductInfoView>(product);

            if (registerProduct == null)
            {
                return(JsonHelper.SerializeObject("false: NoInput!"));
            }
            RegisterProductResponse response = _productInfoService.RegisterProduct(new RegisterProductRequest()
            {
                ProductInfo = registerProduct,
                UserName    = username
            });

            if (response.IsSucess == false || response.ProductInfo == null)
            {
                return(JsonHelper.SerializeObject("false:" + response.Message));
            }
            return(JsonHelper.SerializeObject(response.ProductInfo));
        }