Exemple #1
0
        /// <summary>
        /// 获取热销商品
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage GetHotProduct()
        {
            HttpResponseMessage response = null;

            try
            {
                var count = 0;
                var list  = new List <Product>();
                var str   = "";
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        str = WebCommom.HttpRequestBodyConvertToStr(ms);//获取Request Body
                    }
                }
                if (!string.IsNullOrWhiteSpace(str))
                {
                    count = Convert.ToInt32(str);
                    list  = bll.Value.GetHotProduct(count);
                }
                else
                {
                    list = bll.Value.GetHotProduct();
                }

                response = WebCommom.GetJsonResponse(list);
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Exemple #2
0
        /// <summary>
        /// 根据商品ID获取商品
        /// </summary>
        /// <param name="pID">商品ID</param>
        /// <returns></returns>
        public HttpResponseMessage GetProductByID()
        {
            HttpResponseMessage response = null;
            var product = new Product();

            try
            {
                var str = "";
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        str = WebCommom.HttpRequestBodyConvertToStr(ms);//获取Request Body
                    }
                }
                if (!string.IsNullOrWhiteSpace(str))
                {
                    var id = Convert.ToInt32(str);
                    product = bll.Value.GetProductByID(id);
                }
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetJsonResponse(product);
            return(response);
        }
Exemple #3
0
        public HttpResponseMessage ReplyMessage()
        {
            HttpResponseMessage result = null;

            try
            {
                string str = "";
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        str = WebCommom.HttpRequestBodyConvertToStr(ms);//获取Request Body
                    }
                }

                var Item = JsonConvert.DeserializeObject <MessageTb>(str);

                MessageTb_BLL bll = new MessageTb_BLL();
                return(WebCommom.GetJsonResponse(bll.ReplyMessage(Item)));
            }
            catch (Exception)
            {
            }
            return(result);
        }
Exemple #4
0
        public HttpResponseMessage GetMessageByReceiveUid()
        {
            HttpResponseMessage result = null;

            try
            {
                string str = "";
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        str = WebCommom.HttpRequestBodyConvertToStr(ms);//获取Request Body
                    }
                }
                var ResponseArray = JsonConvert.DeserializeObject <string>(str);

                var Uid = Convert.ToInt32(ResponseArray);

                MessageTb_BLL bll = new MessageTb_BLL();


                return(WebCommom.GetJsonResponse(bll.GetMessageByReceiveUid(Uid)));
            }
            catch (Exception)
            {
            }
            return(result);
        }
        public HttpResponseMessage GetUserProductConsultList()
        {
            HttpResponseMessage result = null;

            try
            {
                string str = "";
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        str = WebCommom.HttpRequestBodyConvertToStr(ms);//获取Request Body
                    }
                }
                var Item               = JsonConvert.DeserializeObject <string[]>(str);
                int uid                = Convert.ToInt32(Item[0]);
                int pageSize           = Convert.ToInt32(Item[1]);
                int pageNumber         = Convert.ToInt32(Item[2]);
                ProductConsult_BLL bll = new ProductConsult_BLL();

                var Res = bll.GetProductConsultListByUid(uid, 0, pageSize, pageNumber);

                return(WebCommom.GetJsonResponse(Res));
            }
            catch (Exception)
            {
            }
            return(result);
        }
Exemple #6
0
        /// <summary>
        /// 根据商品ID获取商品
        /// </summary>
        /// <param name="pID">商品ID</param>
        /// <returns></returns>
        public HttpResponseMessage GetProduct()
        {
            HttpResponseMessage response = null;
            var products = new List <Product>();

            try
            {
                products = bll.Value.GetProduct();
            }
            catch (Exception ex)
            {
            }
            response = WebCommom.GetJsonResponse(products);
            return(response);
        }
Exemple #7
0
        /// <summary>
        /// 根据用户ID获取购物车商品
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage GetShoppingCartByUserID()
        {
            HttpResponseMessage response = null;

            try
            {
                var userID = 0;
                var list   = shoppingCartBll.Value.GetShoppingCartByUserID(userID);
                var result = JsonConvert.SerializeObject(list);
                response = WebCommom.GetJsonResponse(result);
            }
            catch (Exception ex)
            {
            }
            return(response);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #10
0
        /// <summary>
        /// 根据类目获取产品
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage GetProductByCategory()
        {
            HttpResponseMessage response = null;

            try
            {
                var            count = 0;
                List <Product> list  = new List <Product>();
                var            str   = "";
                using (var ms = new MemoryStream())
                {
                    HttpContext.Current.Request.GetBufferlessInputStream().CopyTo(ms);
                    if (ms.Length != 0)
                    {
                        str = WebCommom.HttpRequestBodyConvertToStr(ms);//获取Request Body
                    }
                }
                if (!string.IsNullOrWhiteSpace(str))
                {
                    var arr    = str.Split(',');
                    var cateID = Convert.ToInt32(arr[0]);
                    if (arr.Length > 1)//Index 0是cateID,1是count
                    {
                        count = Convert.ToInt32(arr[1]);
                    }
                    var cateIDList = cateBll.Value.GetCategoryChildren(cateID);//获取cate子ID
                    if (count != 0)
                    {
                        list = bll.Value.GetProductByCate(cateIDList, count);
                    }
                    else
                    {
                        list = bll.Value.GetProductByCate(cateIDList);
                    }
                }
                response = WebCommom.GetJsonResponse(list);
            }
            catch (Exception ex)
            {
            }
            return(response);
        }