Exemplo n.º 1
0
        /// <summary>
        /// 获取产品的分页信息
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task <ResponseResult> GetProductInfoPageResultAsync(ProductSearchDto dto)
        {
            var result = new ResponseResult(0, "获取成功");
            Expression <Func <ProductInfo, bool> > filter = p => true;

            filter = filter.And(p => !p.IsDeleted);

            if (!string.IsNullOrEmpty(dto.Code))
            {
                filter = filter.And(p => p.Code.Contains(dto.Code));
            }
            if (!string.IsNullOrEmpty(dto.ProductName))
            {
                filter = filter.And(p => p.ProductName.Contains(dto.ProductName));
            }

            var pageResult = await this.productInfoRepository.QueryPageAsync(filter, p => p.Id, dto.PageSize, dto.PageIndex);

            var list = pageResult.List.MapTo <List <ProductInfoItem> >();

            var data = new
            {
                pageResult.PageIndex,
                pageResult.PageSize,
                pageResult.RecordCount,
                pageResult.PageCount,
                List = list
            };

            result.Data = data;
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 商品分页列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <AppSrvResult <PageModelDto <ProductDto> > > GetPaged(ProductSearchDto search)
        {
            Expression <Func <Product, bool> > whereCondition = x => true;

            if (search.Id > 0)
            {
                whereCondition = whereCondition.And(x => x.ID == search.Id);
            }
            var pagedEntity = _productRepo.PagedAsync(search.PageIndex, search.PageSize, whereCondition, x => x.CreateTime);

            var pagedDto = _mapper.Map <PageModelDto <ProductDto> >(pagedEntity);

            if (pagedDto.Data.Count > 0)
            {
                //调用maint微服务获取字典,组合商品状态信息
                var rpcReuslt = await _maintRpcSrv.GetDictAsync(10000);

                if (rpcReuslt.IsSuccessStatusCode && rpcReuslt.Content.Children.Count > 0)
                {
                    var dicts = rpcReuslt.Content.Children;
                    pagedDto.Data.ForEach(x =>
                    {
                        x.StatusName = dicts.FirstOrDefault(d => d.Name == x.Status.ToSafeString())?.Name;
                    });
                }
            }
            return(pagedDto);
        }
Exemplo n.º 3
0
        public async Task <PageList <ProductDto> > GetAll(ProductSearchDto productSearchDto)
        {
            PageList <ProductDto> pageList            = new PageList <ProductDto>();
            Expression <Func <Product, bool> > filter = e => string.IsNullOrWhiteSpace(e.Name) || e.Name.Contains(productSearchDto.Name);
            List <Product> products = new List <Product>();

            products = productSearchDto.SortingModel.SortingExpression switch
            {
                "Name" => await _unitOfWork.Product.GetPageAsync(productSearchDto.PageNumber, productSearchDto.PageSize, filter, p => p.Name, productSearchDto.SortingModel.SortingDirection),
                _ => await _unitOfWork.Product.GetPageAsync(productSearchDto.PageNumber, productSearchDto.PageSize, filter, p => p.CreationDate, SortDirectionEnum.Descending),
            };
            if (products?.Any() ?? default)
            {
                pageList = new PageList <ProductDto>
                {
                    DataList = products.Select(p => new ProductDto
                    {
                        Id          = p.Id,
                        Name        = p.Name,
                        Photo       = p.Photo,
                        Price       = p.Price,
                        LastUpdated = p.LastUpdated
                    }).ToList(),
                    TotalCount = await _unitOfWork.Product.GetCountAsync(filter)
                };
            }
            return(pageList);
        }
Exemplo n.º 4
0
        public List <ProductOutputModel> GetAllProductsByOrderId(int orderId)
        {
            var searchDto = new ProductSearchDto {
                OrderId = orderId
            };

            var products = _productRepository.SearchProduct(searchDto);
            var output   = _mapper.Map <List <ProductOutputModel> >(products);

            return(output);
        }
Exemplo n.º 5
0
        public async Task <ActionResult <PageList <ProductDto> > > GetAll(ProductSearchDto productSearchDto)
        {
            PageList <ProductDto> pageList = await _productService.GetAll(productSearchDto);

            if (pageList != null)
            {
                return(Ok(pageList));
            }
            else
            {
                return(BadRequest());
            }
        }
Exemplo n.º 6
0
        public PaginationDto <ProductDto> GetProducts(ProductSearchDto dto)
        {
            var query = _dbContext.Products
                        .Include(c => c.Category)
                        .AsQueryable();

            if (!string.IsNullOrEmpty(dto.Title))
            {
                query = query.Where(c => c.Title.Contains(dto.Title));
            }

            IOrderedQueryable <Product> orderedQery =
                query.OrderByDescending(c => c.Id);

            return(orderedQery.ToPaginated(dto).ToDto());
        }
Exemplo n.º 7
0
        public async Task <IActionResult> GetAll([FromQuery] ProductSearchDto model, CancellationToken cancellationToken)
        {
            EntityPagedResult <ProductReadDto> returnResponse = new EntityPagedResult <ProductReadDto>();

            try
            {
                var query  = new EntityPagedModelQuery <ProductSearchDto, ProductReadDto>(model);
                var result = await Mediator.Send(query, cancellationToken).ConfigureAwait(false);

                if (result.ReturnStatus == false)
                {
                    return(BadRequest(result));
                }
                return(Ok(result));
            }
            catch (Exception ex)
            {
                returnResponse.ReturnStatus = false;
                returnResponse.ReturnMessage.Add(ex.Message);
                return(BadRequest(returnResponse));
            }
        }
Exemplo n.º 8
0
        public List <ProductDto> SearchProduct(ProductSearchDto searchDto)
        {
            try
            {
                var list = new Dictionary <long, ProductDto>();
                DbConnection.Query <ProductDto, CityProductDto, ProductDto>(
                    "Search_Product",
                    (product, cityProduct) =>
                {
                    ProductDto dto;
                    if (!list.TryGetValue(product.Id.Value, out dto))
                    {
                        dto = product;
                        dto.CityProducts = new List <CityProductDto>()
                        {
                            cityProduct
                        };
                        list.Add(product.Id.Value, dto);
                    }
                    else
                    {
                        dto.CityProducts.Add(cityProduct);
                    }
                    return(dto);
                },
                    searchDto,
                    splitOn: "Id",
                    commandType: CommandType.StoredProcedure
                    ).ToList();

                return(list.Values.AsList());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
        public DataAgent <List <ProductDto> > FindProducts(ProductSearchDto input)
        {
            var result = new DataAgent <List <ProductDto> >();

            try
            {
                result.Data = DbConnection.Query <ProductDto>(
                    StoredProcedures.ProductSearch,
                    new
                {
                    input.Id,
                    input.Name,
                    input.PriceStart,
                    input.PriceEnd,
                    input.Manufacturer,
                    input.ManufacturingYearStart,
                    input.ManufacturingYearEnd,
                    input.Depth,
                    input.Width,
                    input.Height,
                    input.Weight,
                    input.WattageStart,
                    input.WattageEnd,
                    input.VoltageStart,
                    input.VoltageEnd,
                    input.RemovableBasket,
                    input.EspressoType,
                    input.SteamNozzle,
                    input.IntegratedTimer,
                    input.BarsOfPressure,
                    input.DetachableBlades,
                    input.PivotingHead,
                    input.ProtectiveBumpers,
                    input.AppControlled,
                    input.RoomByRoomNavigation,
                    input.CombinationNozzle,
                    input.DustCupCapacity,
                    input.AdjustableSuction,
                    input.WetCleaning,
                    input.RetractableCord,
                    input.NonStickSoleplate,
                    input.AntiDripSystem,
                    input.SpeedSetting,
                    input.CoolShotButton,
                    input.RemovableEndCap,
                    input.DiffuserNozzle,
                    input.BleachDispenser,
                    input.Defrost,
                    input.Grill,
                    input.ThirdRack,
                    input.CupClips,
                    input.SilverwareBasket,
                    input.StemwareHolders,
                    input.UtensilSeparator,
                    input.VibrationReduction,
                    input.QuickWashCycle,
                    input.CylinderCapacity,
                    input.IceMaker,
                    input.TemperatureAlarm,
                    input.Freezer,
                    input.RemovableTeaInfuser,
                    input.WaterLevelWindow,
                    input.FullCircleConnectorOnThePowerbase,
                    input.TravelBag,
                    input.Programmable
                },
                    commandType: CommandType.StoredProcedure
                    ).ToList();
            }
            catch (Exception ex)
            {
                result.ResponseMessage = ex.Message;
            }
            return(result);
        }
Exemplo n.º 10
0
        public async Task <ResponseResult> GetProductInfoPageResultAsync(ProductSearchDto dto)
        {
            var result = await this.productInfoServices.GetProductInfoPageResultAsync(dto);

            return(result);
        }