public JsonResult Favorite(string spaceKey, long itemId, long userId)
        {
            bool isFavorited = favoriteService.IsFavorited(itemId, userId);

            bool result = false;

            if (isFavorited)
            {
                result = favoriteService.CancelFavorite(itemId, userId);
            }
            else
            {
                result = favoriteService.Favorite(itemId, userId);
            }

            //reply:已修改

            if (result)
            {
                return(Json(new { ok = true, msg = "操作成功" }));
            }
            else
            {
                return(Json(new { msg = "操作失败" }));
            }
        }
        public JsonResult _FavoriteCancel(long giftId)
        {
            if (UserContext.CurrentUser == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "必须先登录,才能继续操作")));
            }

            long userId = UserContext.CurrentUser.UserId;

            if (!favoriteService.IsFavorited(giftId, userId))
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "您没有收藏过该商品")));
            }

            PointGift pointGift = pointMallService.GetGift(giftId);

            if (pointGift == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "找不到要被收藏的商品")));
            }

            favoriteService.CancelFavorite(giftId, userId);

            return(Json(new StatusMessageData(StatusMessageType.Success, "取消关注操作成功")));
        }
示例#3
0
 public ActionResult _CancelFavorite(long objectId)
 {
     if (favoriteService.CancelFavorite(objectId, UserContext.CurrentUser.UserId))
     {
         return(Json(new StatusMessageData(StatusMessageType.Success, "取消成功!")));
     }
     return(Json(new StatusMessageData(StatusMessageType.Error, "取消失败!")));
 }
示例#4
0
        public JsonResult _CancelFollowedTopic(string spaceKey, long tagId = 0)
        {
            IUser CurrentUser = UserContext.CurrentUser;
            if (CurrentUser == null)
            {
                return Json(new StatusMessageData(StatusMessageType.Error, "请先登录!"), JsonRequestBehavior.AllowGet);
            }

            FavoriteService FavoriteService = new FavoriteService(TenantTypeIds.Instance().Tag());
            if (FavoriteService.IsFavorited(tagId, CurrentUser.UserId))
            {
                FavoriteService.CancelFavorite(tagId, CurrentUser.UserId);
            }

            return Json(new StatusMessageData(StatusMessageType.Success, "取消关注成功!"), JsonRequestBehavior.AllowGet);
        }