Exemplo n.º 1
0
        public ExecuteResult <ShowCustomerInfoResponse> GetShowCustomer(ShowCustomerRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var entity = _customerRepository.GetItem(request.UserId);

            if (entity == null)
            {
                return(new ExecuteResult <ShowCustomerInfoResponse>(null));
            }

            var userModel = MappingManager.UserModelMapping(entity);

            var response = MappingManager.ShowCustomerInfoResponseMapping(userModel);

            if (request.CurrentAuthUser != null)
            {
                //取是否关注当前
                var likeEntity = _likeService.Get(request.CurrentAuthUser.Id, request.UserId);
                response.IsLiked = likeEntity != null;
            }
            return(new ExecuteResult <ShowCustomerInfoResponse>(response));
        }
Exemplo n.º 2
0
        public RestfulResult Daren(ShowCustomerRequest request, [FetchRestfulAuthUser(IsCanMissing = true, KeyName = Define.Token)] UserModel currentAuthUser)
        {
            request.CurrentAuthUser = currentAuthUser;

            var linq = _customerRepo.Get(u => u.Id == request.UserId)
                       .GroupJoin(_resourceRepo.Get(r => r.SourceType == (int)SourceType.CustomerThumbBackground),
                                  o => o.Id,
                                  i => i.SourceId,
                                  (o, i) => new { C = o, RB = i })
                       .GroupJoin(_useraccountRepo.Get(ua => ua.Status != (int)DataStatus.Deleted),
                                  o => o.C.Id,
                                  i => i.User_Id,
                                  (o, i) => new { C = o.C, RB = o.RB, UA = i });
            var response = from l in linq.ToList()
                           select new ShowCustomerInfoResponse().FromEntity <ShowCustomerInfoResponse>(l.C
                                                                                                       , c =>
            {
                var bgThum = l.RB.FirstOrDefault();
                if (bgThum != null)
                {
                    c.BackgroundLogo_r = new ResourceInfoResponse().FromEntity <ResourceInfoResponse>(bgThum);
                }
                c.CountsFromEntity(l.UA);
                c.IsLiked = false;
                if (request.CurrentAuthUser != null)
                {
                    var likeEntity = _likeRepo.Get(like => like.LikeUserId == request.CurrentAuthUser.Id && like.LikedUserId == request.UserId).FirstOrDefault();
                    c.IsLiked      = likeEntity != null;
                }
            });;

            return(new RestfulResult
            {
                Data = new ExecuteResult <ShowCustomerInfoResponse>(response.FirstOrDefault())
            });
        }
Exemplo n.º 3
0
 public RestfulResult Show(ShowCustomerRequest request, [FetchRestfulAuthUser(IsCanMissing = true, KeyName = Define.Token)] UserModel currentAuthUser)
 {
     return(Daren(request, currentAuthUser));
 }