Example #1
0
        public void Test_Add_QueryById_Update_Delete_RelatedProductProvider()
        {
            var product1 = new Product
            {
                Name             = "Product1",
                ShortDescription = "this is product1",
                FullDescription  = "full",
                UtcCreationDate  = DateTime.UtcNow,
                UtcUpdateDate    = DateTime.UtcNow
            };
            var product2 = new Product
            {
                Name             = "Product2",
                ShortDescription = "this is product2",
                FullDescription  = "full",
                UtcCreationDate  = DateTime.UtcNow,
                UtcUpdateDate    = DateTime.UtcNow
            };
            var relatedProduct = new RelatedProduct
            {
                DisplayOrder = 1,
                Product1     = product1,
                Product2     = product2
            };

            //Add brand
            ProductProvider productProcider = new ProductProvider(new NoDI_NHibernateContextFactory());

            productProcider.Add(product1);
            productProcider.Add(product2);
            provider.Add(relatedProduct);
            Console.WriteLine("Add OK!");

            //QueryBy
            var relatedProductQueryBy = provider.QueryById(relatedProduct.Id);

            Assert.IsNotNull(relatedProductQueryBy);
            Console.WriteLine("QueryBy OK!");

            //update
            relatedProduct.DisplayOrder = 5;
            provider.Update(relatedProduct);
            var brandUpdate = provider.QueryById(relatedProduct.Id);

            Assert.AreEqual(5, relatedProduct.DisplayOrder);
            Console.WriteLine("Update OK!");

            //Delete
            provider.Delete(relatedProduct);
            var relatedProductDelete = provider.QueryById(relatedProduct.Id);

            Assert.IsNull(relatedProductDelete);
            Console.WriteLine("Delete OK!");
        }
        public void Test_Add_QueryById_Update_Delete_RelatedProductProvider()
        {
            var product1 = new Product
            {
                Name = "Product1",
                ShortDescription = "this is product1",
                FullDescription = "full",
                UtcCreationDate = DateTime.UtcNow,
                UtcUpdateDate = DateTime.UtcNow
            };
            var product2 = new Product
            {
                Name = "Product2",
                ShortDescription = "this is product2",
                FullDescription = "full",
                UtcCreationDate = DateTime.UtcNow,
                UtcUpdateDate = DateTime.UtcNow
            };
            var relatedProduct = new RelatedProduct
            {
                DisplayOrder = 1,
                Product1 = product1,
                Product2 = product2
            };

            //Add brand
            ProductProvider productProcider = new ProductProvider(new NoDI_NHibernateContextFactory());
            productProcider.Add(product1);
            productProcider.Add(product2);
            provider.Add(relatedProduct);
            Console.WriteLine("Add OK!");

            //QueryBy
            var relatedProductQueryBy = provider.QueryById(relatedProduct.Id);
            Assert.IsNotNull(relatedProductQueryBy);
            Console.WriteLine("QueryBy OK!");

            //update
            relatedProduct.DisplayOrder = 5;
            provider.Update(relatedProduct);
            var brandUpdate = provider.QueryById(relatedProduct.Id);
            Assert.AreEqual(5, relatedProduct.DisplayOrder);
            Console.WriteLine("Update OK!");

            //Delete
            provider.Delete(relatedProduct);
            var relatedProductDelete = provider.QueryById(relatedProduct.Id);
            Assert.IsNull(relatedProductDelete);
            Console.WriteLine("Delete OK!");
        }
Example #3
0
        public void Test_Add_QueryById_Update_Delete_ProductProvider()
        {
            var product = new Product
            {
                Name            = "Product1",
                UtcCreationDate = DateTime.UtcNow,
                UtcUpdateDate   = DateTime.UtcNow
            };

            //Add brand
            provider.Add(product);
            Console.WriteLine("Add OK!");

            //QueryBy
            var productQueryBy = provider.QueryById(product.Id);

            Assert.IsNotNull(productQueryBy);
            Console.WriteLine("QueryBy OK!");

            //update
            product.Name = "newName";
            provider.Update(product);
            var productUpdate = provider.QueryById(product.Id);

            Assert.AreEqual("newName", productUpdate.Name);
            Console.WriteLine("Update OK!");

            //Delete
            provider.Delete(product);
            var productDelete = provider.QueryById(product.Id);

            Assert.IsNull(productDelete);
            Console.WriteLine("Delete OK!");
        }
Example #4
0
        public ActionResult AddProduct(ProductModel model)
        {
            if (ModelState.IsValid)
            {
                DATA.Domains.Product product = new DATA.Domains.Product
                {
                    Availability = model.Availability,
                    BarCode      = model.BarCode,
                    Brand        = model.Brand,
                    Color        = model.Color,
                    Detail       = model.Detail,
                    CreatedOn    = DateTime.Now,
                    CategoryId   = model.CategoryId,
                    ImeNumber    = model.ImeNumber,
                    Name         = model.Name,
                    Price        = model.Price,
                    Size         = model.Size,
                    Cost         = model.Cost
                };
                productprovider.Add(product);
            }
            var category = productprovider.GetCategorybyTrademarkId(1);

            TempData["Categories"] = category;

            return(View());
        }
Example #5
0
 /// <summary>
 /// 新增产品信息
 /// </summary>
 /// <param name="ce"></param>
 /// <returns></returns>
 public int Add(Product_CE ce)
 {
     if (ce != null)
     {
         ProductEntity   entity   = Product_To.To(ce);
         ProductProvider provider = new ProductProvider();
         int             line     = provider.Add(entity);
         return(line);
     }
     return(0);
 }
Example #6
0
        /// <summary>
        /// 新增产品
        /// </summary>
        /// <returns></returns>
        public ActionResult Add()
        {
            string          CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            ProductEntity   entity    = WebUtil.GetFormObject <ProductEntity>("Entity");
            ProductProvider provider  = new ProductProvider(CompanyID);

            entity.CreateTime = DateTime.Now;
            entity.IsDelete   = (int)EIsDelete.NotDelete;
            int        line   = provider.Add(entity);
            DataResult result = new DataResult();

            if (line > 0)
            {
                result.Code    = (int)EResponseCode.Success;
                result.Message = "产品新增成功";
            }
            else
            {
                result.Code    = (int)EResponseCode.Exception;
                result.Message = "产品新增失败";
            }
            return(Content(JsonHelper.SerializeObject(result)));
        }
Example #7
0
 public static bool NewProduct(ProductListEntity product)
 {
     return(ProductProvider.Add(product));
 }