/// <summary>
        /// get the operations available to current user for this promotion.
        /// operations includes:
        /// 1. if can get coupon
        /// 2. if favored
        /// </summary>
        /// <param name="authUser"></param>
        /// <returns></returns>
        public ActionResult AvailOperations(GetPromotionInfoRequest request, [FetchRestfulAuthUserAttribute(IsCanMissing = true, KeyName = Define.Token)] UserModel authUser)
        {
            
            bool isFavored = false;
            bool ifCanCoupon = false;
            var withUserId = (authUser != null && authUser.Id > 0);
            if (withUserId)
            {
                isFavored = Context.Set<FavoriteEntity>().Where(f => f.User_Id == authUser.Id && f.FavoriteSourceType == (int)SourceType.Promotion && f.FavoriteSourceId == request.Promotionid && f.Status != (int)DataStatus.Deleted).Any();
            }

            var linq = Context.Set<PromotionEntity>().Where(p => p.Status == (int)DataStatus.Normal && p.Id == request.Promotionid).FirstOrDefault();
            if (linq == null)
                return this.RenderSuccess<GetAvailOperationsResponse>(r => r.Data = new GetAvailOperationsResponse()
                {
                    IsFavored = false,
                    IfCanCoupon = false
                });

            bool hadGetCoupon = false;
            if (withUserId)
            {
                hadGetCoupon = Context.Set<CouponHistoryEntity>().Where(c => c.User_Id == authUser.Id && c.FromPromotion == linq.Id).Any();

            }
            if (linq.PublicationLimit == null || linq.PublicationLimit == -1)
            {
                ifCanCoupon = (!hadGetCoupon) ||
                               (hadGetCoupon && (!linq.IsLimitPerUser.HasValue || linq.IsLimitPerUser.Value == false));
            }
            else
            {
                ifCanCoupon = linq.InvolvedCount < linq.PublicationLimit &&
                             (!hadGetCoupon || (hadGetCoupon && (!linq.IsLimitPerUser.HasValue || linq.IsLimitPerUser.Value == false)));
            }
            ifCanCoupon = ifCanCoupon && linq.EndDate > DateTime.Now && linq.StartDate <= DateTime.Now;
            return this.RenderSuccess<GetAvailOperationsResponse>(r => r.Data = new GetAvailOperationsResponse()
                {
                    IsFavored = isFavored,
                    IfCanCoupon = ifCanCoupon
                });
          

        }
        public RestfulResult Detail(GetPromotionInfoRequest request, [FetchRestfulAuthUser(IsCanMissing = true, KeyName = Define.Token)]UserModel currentAuthUser)
        {
            request.CurrentAuthUser = currentAuthUser;

            return new RestfulResult { Data = this._promotionDataService.GetPromotionInfo(request) };
        }
        /// <summary>
        /// 获取促销详情信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ExecuteResult<PromotionInfoResponse> GetPromotionInfo(GetPromotionInfoRequest request)
        {

            var entity = _promotionRepository.GetItem(request.Promotionid);
            var response = MappingManager.PromotionResponseMapping(entity, request.CoordinateInfo);



            if (request.CurrentAuthUser != null && response != null)
            {
                //是否收藏
                response = IsR(response, request.CurrentAuthUser, response.Id);
            }

            var result = new ExecuteResult<PromotionInfoResponse>(response);

            return result;
        }