Пример #1
0
        public RestfulResult Destroy(FavoriteDestroyRequest request, int? authuid, UserModel authUser)
        {
            request.AuthUid = authuid.Value;
            request.AuthUser = authUser;

            return new RestfulResult { Data = this._favoriteDataService.Destroy(request) };
        }
Пример #2
0
        /// <summary>
        /// 删除收藏
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ExecuteResult Destroy(FavoriteDestroyRequest request)
        {
            var favorEntity = _favoriteRepository.GetItem(request.FavoriteId);
            if (favorEntity == null)
            {
                return new ExecuteResult { StatusCode = StatusCode.ClientError, Message = "没有找到该产品" };
            }

            if (favorEntity.User_Id != request.AuthUid)
            {
                return new ExecuteResult { StatusCode = StatusCode.ClientError, Message = "您没有权限删除他人的收藏" };
            }

            _favoriteRepository.Delete(favorEntity);

            return new ExecuteResult();
        }