Пример #1
0
        /// <summary>
        /// 修改品牌
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage UpdateBrand()
        {
            HttpResponseMessage response = null;

            try
            {
                Brand brand  = null;
                var   result = false;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        brand = WebCommom.HttpRequestBodyConvertToObj <Brand>(ms);//获取转换后的Body
                    }
                }

                if (brand != null)
                {
                    result = bll.Value.UpdateBrand(brand);
                }

                response = WebCommom.GetResponse(result);
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Пример #2
0
        /// <summary>
        /// 添加商品到购物车
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage AddProductToShoppingCart()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                Dictionary <string, int> dic = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        dic = WebCommom.HttpRequestBodyConvertToObj <Dictionary <string, int> >(ms);
                    }
                }
                if (dic.Count > 0)
                {
                    var userID    = dic["userID"];
                    var productID = dic["productID"];
                    var number    = dic["number"];
                    result = shoppingCartBll.Value.AddProductToShoppingCart(userID, productID, number);
                }
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Пример #3
0
        /// <summary>
        /// 修改横幅
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage UpdateProduct()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                Product product = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        product = WebCommom.HttpRequestBodyConvertToObj <Product>(ms);//获取转换后的Body
                    }
                }
                if (product != null)
                {
                    result = bll.Value.UpdateProduct(product);
                }
                if (result)//修改成功更新产品索引
                {
                    lucene.Value.IndexPath = indexPath;
                    lucene.Value.UpdateDocument(product, Utilities.GetPropertyName <Product>(f => f.PID), GetIndexField());
                }
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Пример #4
0
        /// <summary>
        /// 添加横幅
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage AddBanner()
        {
            HttpResponseMessage response = null;

            try
            {
                Banner banner = null;
                var    result = false;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        banner = WebCommom.HttpRequestBodyConvertToObj <Banner>(ms);
                    }
                }
                if (banner != null)
                {
                    result = bll.Value.AddBanner(banner);
                }
                response = WebCommom.GetResponse(result);
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Пример #5
0
        /// <summary>
        /// 获取物流信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage QueryLogisticsInfo()
        {
            HttpResponseMessage response = null;

            try
            {
                Dictionary <string, string> dic = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        dic = WebCommom.HttpRequestBodyConvertToObj <Dictionary <string, string> >(ms);//获取Request Body
                    }
                }
                if (dic.Count > 0)
                {
                    var orderCode    = dic["orderCode"];
                    var shipperCode  = dic["shipperCode"];
                    var logisticCode = dic["logisticCode"];
                    logisticsBll.Value.QueryLogisticsInfo(orderCode, shipperCode, logisticCode);
                }
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Пример #6
0
        public HttpResponseMessage GetProductReviewByProductID()
        {
            HttpResponseMessage  response = null;
            List <ProductReview> list     = null;

            try
            {
                var pID = WebCommom.HttpRequestBodyConvertToObj <int>(HttpContext.Current);
                list = reviewBll.Value.GetProductReviewByProductID(pID);
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(list);
            return(response);
        }
Пример #7
0
        /// <summary>
        /// 添加商品评论
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage AddProductReview()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                var review = WebCommom.HttpRequestBodyConvertToObj <ProductReview>(HttpContext.Current);
                result = reviewBll.Value.AddProductReview(review);
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Пример #8
0
        /// <summary>
        /// 获取所有商品
        /// </summary>
        /// <returns>所有商品</returns>
        public HttpResponseMessage SearchProduct()
        {
            HttpResponseMessage  response   = null;
            PageResult <Product> pageResult = new PageResult <Product>();

            try
            {
                var      searchKey = "";
                var      pageIndex = 0;
                var      pageSize  = 0;
                string[] arr       = new string[5];
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        arr = WebCommom.HttpRequestBodyConvertToObj <string[]>(ms);//获取Request Body
                    }
                }
                if (arr.Length > 0)
                {
                    var totalCount = 0;
                    searchKey = Convert.ToString(arr[0]);
                    pageIndex = Convert.ToInt32(arr[1]);
                    pageSize  = Convert.ToInt32(arr[2]);
                    lucene.Value.IndexPath = indexPath;
                    var products = new List <Product>();
                    if (arr.Length == 3)
                    {
                        products = lucene.Value.SearchFromIndexData <Product>(searchKey, pageIndex, pageSize, out totalCount, Utilities.GetPropertyName <Product>(f => f.Name));
                    }
                    pageResult = new PageResult <Product>
                    {
                        ResultList = products,
                        TotalCount = totalCount,
                        PageIndex  = pageSize
                    };
                }
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetJsonResponse(pageResult);
            return(response);
        }
Пример #9
0
        public HttpResponseMessage GetProductByStore()
        {
            HttpResponseMessage response = null;
            List <Product>      list     = null;

            try
            {
                var storeID = WebCommom.HttpRequestBodyConvertToObj <int>(HttpContext.Current);
                if (storeID != 0)
                {
                    list = bll.Value.GetProductByStore(storeID);
                }
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetJsonResponse(list);
            return(response);
        }
Пример #10
0
        /// <summary>
        /// 添加商品
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage AddProduct()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                Product product = null;
                var     id      = 0;//插入后返回的ID
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        product = WebCommom.HttpRequestBodyConvertToObj <Product>(ms);
                    }
                }
                if (product != null)
                {
                    id          = bll.Value.AddProduct(product);
                    product.PID = id;
                }
                if (id != 0)
                {
                    result = true;
                }
                if (result)//更新全文索引
                {
                    lucene.Value.IndexPath = indexPath;
                    lucene.Value.CreateIndexByData <Product>(new List <Product> {
                        product
                    }, GetIndexField(), false);
                }
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Пример #11
0
        public HttpResponseMessage BuyApply()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                BuyApply buyApply = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        buyApply = WebCommom.HttpRequestBodyConvertToObj <BuyApply>(ms);
                    }
                }
                result = buyApplyBll.Value.CreateBuyApply(buyApply);
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }
Пример #12
0
        /// <summary>
        /// 创建发货单
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage CreateInvoice()
        {
            HttpResponseMessage response = null;
            var result = false;

            try
            {
                Invoice invoice = null;
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        invoice = WebCommom.HttpRequestBodyConvertToObj <Invoice>(ms);
                    }
                }
                result = invoiceBll.Value.CreateInvoice(invoice);
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetResponse(result);
            return(response);
        }