예제 #1
0
        public ResponseContext <ShareDetailResponse> ShareDetail(Guid momentId, RequestHead head)
        {
            var moment = momentDao.GetMomentByMomentId(momentId);

            if (moment == null)
            {
                return(new ResponseContext <ShareDetailResponse>(ErrCodeEnum.DataIsnotExist));
            }
            var userInfo = uerInfoBiz.GetUserInfoByUid(moment.UId);

            if (userInfo == null)
            {
                return(new ResponseContext <ShareDetailResponse>(ErrCodeEnum.DataIsnotExist));
            }
            var    applyInfo = applyInfoDao.GetByMomentIdAndUId(momentId, head.UId);
            bool   isApply   = applyInfo != null;
            bool   selfFlag  = moment.UId == head.UId;
            bool   overCount = ApplyBuilder.IsOverCount(moment);
            string btnText   = MomentContentBuilder.BtnTextMap(moment.State, moment.StopTime, isApply, selfFlag, overCount);
            string stateDesc = MomentContentBuilder.MomentStateMap(moment.State, moment.StopTime, overCount);

            return(new ResponseContext <ShareDetailResponse>()
            {
                Data = new ShareDetailResponse()
                {
                    MomentId = momentId,
                    ApplyId = isApply ? applyInfo.ApplyId : Guid.Empty,
                    ApplyFlag = isApply,
                    BtnText = btnText,
                    StateDesc = stateDesc,
                    ShareTitle = MomentContentBuilder.GetShareTitle(moment),
                    Address = moment.Address,
                    Latitude = moment.Latitude,
                    Longitude = moment.Longitude,
                    IsOffLine = moment.IsOffLine,
                    AskFlag = string.Equals(btnText, "申请参与"),
                    BtnVisable = !string.IsNullOrEmpty(btnText),
                    TextColor = MomentContentBuilder.TextColorMap(moment.State, moment.StopTime, overCount),
                    UserInfo = UserInfoBuilder.BuildUserInfo(userInfo, head),
                    ContentList = MomentContentBuilder.BuilderContent(moment, true),
                    ApplyList = ApplyBuilder.GetApplyList(momentId, true, head, moment.UId)
                }
            });
        }