示例#1
0
        public JsonResult GetCollcetData(int pageIndex, int pageSize, string search)
        {
            var userID = this.GetUserID();
            var condition = "[UserID] = " + userID + " and " +
                            (string.IsNullOrEmpty(search) ? "1=1" : "productName like '%" + search + "%'");
            var paging = new Paging("[view_User_Collect]", null, "ID", condition, pageIndex, pageSize, "CreateTime", 1);
            int pageCount, rowCount;
            var list = new UserCollectRecordService().Paging(paging, out pageCount, out rowCount);
            if (list != null)
            {
                foreach (var userCollectRecord in list)
                {
                    userCollectRecord.Path = Utils.GetProductImage(userCollectRecord.Path, "1");
                }
            }

            return this.Json(new { data = list, rowsCount = rowCount });
        }
示例#2
0
        /// <summary>
        /// 添加会员商品收藏.
        /// </summary>
        /// <param name="productId">
        /// The product id.
        /// </param>
        /// <returns>
        /// The <see cref="JsonResult"/>.
        /// </returns>
        public JsonResult AddCollect(string productId)
        {
            try
            {
                var userID = this.GetUserID();
                if (userID == 0)
                {
                    return this.Json(new AjaxResponse(3, "未登录"));
                }

                var userCollectRecordService = new UserCollectRecordService();
                var userCollectRecord = userCollectRecordService.QueryRow(userID, int.Parse(productId));
                if (userCollectRecord != null)
                {
                    return this.Json(new AjaxResponse(2, "已收藏过"));
                }

                userCollectRecord = new User_CollectRecord { UserID = userID, ProductID = int.Parse(productId) };
                userCollectRecordService.Add(userCollectRecord);
                return this.Json(new AjaxResponse(1, "收藏成功"));
            }
            catch (Exception exception)
            {
                return this.Json(new AjaxResponse(0, "收藏失败!:" + exception.Message));
            }
        }
示例#3
0
 /// <summary>
 /// 批量删除收藏.
 /// </summary>
 /// <param name="id">
 /// The id.
 /// </param>
 /// <returns>
 /// The <see cref="JsonResult"/>.
 /// </returns>
 public JsonResult DeleteCollcet(string id)
 {
     try
     {
         var userCollect = new UserCollectRecordService();
         userCollect.RemoveBatch(id);
         return this.Json(new AjaxResponse(1, "删除成功!"));
     }
     catch (Exception exception)
     {
         return this.Json(new AjaxResponse(0, "删除失败!" + exception.Message));
     }
 }