コード例 #1
0
        public async Task <IEnumerable <string> > GetGoodsCategoryNames(string userId)
        {
            var user = await _userServiceProxy.GetCookAppUser(userId);

            if (user == null || string.IsNullOrEmpty(user.ServicerId))
            {
                return(new List <string>());
            }
            var servicer = await _fancyServiceProxy.GetServicer(user.ServicerId);

            if (servicer == null)
            {
                return(new List <string>());
            }
            var ojs = _onlineGoodsRepository.GetFiltered(o => o.StoreId == servicer.OrganizationId).Select(g => g.GoodsCategoryName).Distinct();

            if (ojs == null)
            {
                return(new List <string>());
            }
            return(ojs.ToList());
        }
コード例 #2
0
        public async Task <IEnumerable <CommentDTO> > Get(string goodsId, int pageIndex, int pageSize)
        {
            var results = new List <CommentDTO>();
            var res     = _commentRepository.GetFiltered(o => o.GoodsId == goodsId).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();

            foreach (var item in res)
            {
                var user = await _userServiceProxy.GetCookAppUser(item.CreatedBy); //await _authServiceProxy.GetUser(item.CreatedBy);

                results.Add(new CommentDTO
                {
                    Content     = item.Content,
                    GoodsId     = item.GoodsId,
                    OrderId     = item.OrderId,
                    ImageIds    = _commentImageRepository.GetFiltered(o => o.CommentId == item.Id).Select(o => o.ImageId).ToList(),
                    TagIds      = _commentTagRepository.GetFiltered(o => o.CommentId == item.Id).Select(g => g.TagId).ToList(),
                    CreateTime  = item.CreatedOn.ToString("yyyy-MM-dd"),
                    NickName    = string.IsNullOrEmpty(user?.UserName)?"匿名用户": ProcessUserName(user?.UserName),
                    PortraitUrl = "https://resources.arcanestars.com/portrait.png"
                });
            }

            return(results);
        }
コード例 #3
0
        public async Task AddService(ServiceDTO service, string operatorId)
        {
            if (string.IsNullOrWhiteSpace(service.IOSVideoUrl) && string.IsNullOrWhiteSpace(service.VideoUrl))
            {
                throw new ArgumentInvalidException("IOSVideoUrl和VideoUrl不能都为空!");
            }

            if (!string.IsNullOrEmpty(service?.Station?.StreetAddress))
            {
                var lonLat = await _amapProxy.Geo(service.Station.StreetAddress);

                service.Station.Longitude = lonLat?.Longitude ?? 0;
                service.Station.Latitude  = lonLat?.Latitude ?? 0;
            }

            var user = await _userServiceProxy.GetCookAppUser(operatorId);

            var orgId = "";

            if (user != null)
            {
                var servicer = _servicerRepository.GetFiltered(o => o.UserName == user.UserName).FirstOrDefault();
                if (servicer != null)
                {
                    orgId = servicer.OrganizationId;
                }
            }

            if (!string.IsNullOrEmpty(orgId))
            {
                var c = _serviceRepository.GetFiltered(o => o.OrganizationId == orgId && o.Title == service.Title).Count();
                if (c > 0)
                {
                    throw new ArgumentInvalidException("您所在的商户下已经存在您所发布的标题,请更改标题!");
                }
            }


            var obj = ServiceFactory.CreateInstance(
                service.Title,
                service.Introduction,
                service.SincerityGold,
                service.ServeScope,
                service.Category,
                service.SubCategory,
                service.Station,
                string.IsNullOrEmpty(orgId) ? service.OrganizationId : orgId,
                operatorId,
                service.VideoUrl,
                service.IOSVideoUrl,
                service.GoodsCategoryName,
                service.ApplicationId);

            _serviceRepository.Add(obj);
            if (service.Images != null && service.Images.Count() > 0)
            {
                foreach (var img in service.Images)
                {
                    _serviceImageRepository.Add(new ServiceImage
                    {
                        CreatedOn = DateTime.Now,
                        ImageId   = img.ImageId,
                        ServiceId = obj.Id
                    });
                }
            }
            _dbUnitOfWork.Commit();
        }