Exemple #1
0
        public FollowAsset FollowUnfollowAsset(int assetId, FollowActionType followActionType)
        {
            var user = GetValidUser();

            var asset = AssetBusiness.GetById(assetId);

            if (!asset.Enabled)
            {
                throw new BusinessException("Invalid asset.");
            }

            var followAsset = FollowAssetBusiness.Create(user.Id, assetId, followActionType);

            if (user.FollowedAssets != null)
            {
                if (followActionType == FollowActionType.Follow)
                {
                    user.FollowedAssets.Add(assetId);
                }
                else
                {
                    user.FollowedAssets.Remove(assetId);
                }

                SetUserToCache(user);
            }
            return(followAsset);
        }