예제 #1
0
        public RestfulResult Share(FormCollection formCollection, PromotionShareCreateRequest request, int? authuid, UserModel authUser)
        {
            request.AuthUid = authuid.Value;
            request.AuthUser = authUser;
            request.Description = UrlDecode(request.Description);
            request.Name = UrlDecode(request.Name);

            return new RestfulResult
            {
                Data = this._promotionDataService.CreateShare(request)
            };
        }
        /// <summary>
        /// 创建分享
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ExecuteResult<PromotionInfoResponse> CreateShare(PromotionShareCreateRequest request)
        {
            var promotionEntity = _promotionRepository.GetItem(request.Promotionid);

            if (promotionEntity == null)
            {
                return new ExecuteResult<PromotionInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "活动不存在" };
            }

            using (var ts = new TransactionScope())
            {
                _shareService.Create(new ShareHistoryEntity
                    {
                        CreatedDate = DateTime.Now,
                        CreatedUser = request.AuthUid,
                        Description = request.Description,
                        Name = request.Name,
                        ShareTo = request.OutSiteType,
                        SourceId = request.Promotionid,
                        SourceType = (int)SourceType.Promotion,
                        Stauts = 1,
                        User_Id = request.AuthUid,
                        UpdatedDate = DateTime.Now,
                        UpdatedUser = request.AuthUid
                    });


                //TODO
                promotionEntity = _promotionRepository.SetCount(PromotionCountType.ShareCount, promotionEntity.Id, 1);

                ts.Complete();
            }
            var re = MappingManager.PromotionResponseMapping(promotionEntity, request.CoordinateInfo);

            re = IsR(re, request.AuthUser, request.AuthUser.Id);

            return new ExecuteResult<PromotionInfoResponse> { Data = re };
        }