private IHttpActionResult AddProduct(RequestAddProduct request)
        {
            var tokenResult = IdentityValid.ValidateToken(request.Token);

            if (!tokenResult.IsSuccess)
            {
                return(Json(tokenResult));
            }

            var productbll       = new ProductBLL();
            var productTypebll   = new ProductTypeBLL();
            var productTypeModel = productTypebll.Get(o => o.ProductTypeName == request.ProductTypeName && o.UserName == tokenResult.userName);

            if (productTypeModel == null)
            {
                productTypebll.Save(new ProductType
                {
                    ParentProductTypeId = 0,
                    UserName            = tokenResult.userName,
                    ProductTypeName     = request.ProductTypeName
                });
                productTypeModel = productTypebll.Get(o => o.ProductTypeName == request.ProductTypeName && o.UserName == tokenResult.userName);
            }

            var product = new Product()
            {
                UserName      = tokenResult.userName,
                Introduce     = request.Introduce,
                ProductImgUrl = request.ProductImgUrl,
                ProductName   = request.ProductName,
                ProductTypeId = productTypeModel.ProductTypeId,
                Remark        = request.Remark
            };
            bool isSuccess = productbll.Save(product);

            return(Ok(new ResponseMsg()
            {
                IsSuccess = isSuccess
            }));
        }
        public IHttpActionResult AddProductType(RequestAddProductType request)
        {
            var tokenResult = IdentityValid.ValidateToken(request.Token);

            if (!tokenResult.IsSuccess)
            {
                return(Json(tokenResult));
            }

            var bll         = new ProductTypeBLL();
            var productType = new ProductType()
            {
                UserName            = tokenResult.userName,
                ParentProductTypeId = request.ParentProductTypeId,
                ProductTypeName     = request.ProductTypeName
            };
            bool isSuccess = bll.Save(productType);

            return(Json(new ResponseMsg()
            {
                IsSuccess = isSuccess
            }));
        }
 public ActionResult Add(ProductTypeModel model)
 {
     model.ID = 0;
     return(Json(bll.Save(model), JsonRequestBehavior.AllowGet));
 }