Exemplo n.º 1
0
        public async Task <Result <StandardTableResult <CountryResult> > > List([FromBody] StandardTableParam param)
        {
            var query  = _countryRepository.Query();
            var result = await query.Include(x => x.StatesOrProvinces)
                         .ToStandardTableResult(param, c => new CountryResult
            {
                Id                   = c.Id,
                CreatedOn            = c.CreatedOn,
                IsCityEnabled        = c.IsCityEnabled,
                DisplayOrder         = c.DisplayOrder,
                IsBillingEnabled     = c.IsBillingEnabled,
                IsDeleted            = c.IsDeleted,
                IsDistrictEnabled    = c.IsDistrictEnabled,
                IsPublished          = c.IsPublished,
                IsShippingEnabled    = c.IsShippingEnabled,
                Name                 = c.Name,
                NumericIsoCode       = c.NumericIsoCode,
                ThreeLetterIsoCode   = c.ThreeLetterIsoCode,
                TwoLetterIsoCode     = c.TwoLetterIsoCode,
                UpdatedOn            = c.UpdatedOn,
                StateOrProvinceCount = c.StatesOrProvinces.Count
            });

            return(Result.Ok(result));
        }
Exemplo n.º 2
0
        public async Task <Result <StandardTableResult <BrandResult> > > List(StandardTableParam param)
        {
            var query = _brandRepository.Query().Where(x => !x.IsDeleted);

            if (param.Search.PredicateObject != null)
            {
                dynamic search = param.Search.PredicateObject;
                if (search.name != null)
                {
                    string name = search.name;
                    query = query.Where(x => x.Name.Contains(name));
                }
            }

            var gridData = await query.ToStandardTableResult(
                param,
                model => new BrandResult
            {
                Id          = model.Id,
                IsPublished = model.IsPublished,
                Name        = model.Name,
                Slug        = model.Slug,
                Description = model.Description,
                CreatedOn   = model.CreatedOn,
                UpdatedOn   = model.UpdatedOn
            });

            return(Result.Ok(gridData));
        }
Exemplo n.º 3
0
        public async Task <Result <StandardTableResult <CategoryResult> > > List(StandardTableParam param)
        {
            var query = _categoryRepository.Query();

            if (param.Search.PredicateObject != null)
            {
                dynamic search = param.Search.PredicateObject;
                if (search.name != null)
                {
                    string name = search.name;
                    query = query.Where(x => x.Name.Contains(name));
                }
            }

            var all = await GetAllByCache();

            var gridData = await query.ToStandardTableResult(
                param,
                category => new CategoryResult
            {
                Id            = category.Id,
                IsPublished   = category.IsPublished,
                IncludeInMenu = category.IncludeInMenu,
                Name          = IncludeParentName(all.FirstOrDefault(c => c.Id == category.Id)),
                DisplayOrder  = category.DisplayOrder,
                ParentId      = category.ParentId,
                CreatedOn     = category.CreatedOn,
                UpdatedOn     = category.UpdatedOn
            });

            return(Result.Ok(gridData));
        }
Exemplo n.º 4
0
        public async Task <Result <StandardTableResult <UserQueryResult> > > List([FromBody] StandardTableParam <UserQueryParam> param)
        {
            var query  = _userRepository.Query();
            var search = param.Search;

            if (search != null)
            {
                if (!string.IsNullOrWhiteSpace(search.Name))
                {
                    query = query.Where(c => c.UserName.Contains(search.Name.Trim()) || c.FullName.Contains(search.Name.Trim()));
                }
                if (!string.IsNullOrWhiteSpace(search.Email))
                {
                    query = query.Where(c => c.Email.Contains(search.Email.Trim()));
                }
                if (!string.IsNullOrWhiteSpace(search.PhoneNumber))
                {
                    query = query.Where(c => c.PhoneNumber.Contains(search.PhoneNumber.Trim()));
                }
                if (!string.IsNullOrWhiteSpace(search.Contact))
                {
                    query = query.Where(c => c.Email.Contains(search.Contact.Trim()) || c.PhoneNumber.Contains(search.Contact.Trim()));
                }
                if (search.IsActive.HasValue)
                {
                    query = query.Where(c => c.IsActive == search.IsActive.Value);
                }
                if (search.RoleIds.Count > 0)
                {
                    var roleIds = search.RoleIds.Distinct().ToList();
                    query = query.Where(x => x.Roles.Any(r => roleIds.Contains(r.RoleId)));
                }
            }
            var result = await query.Include(x => x.Roles)
                         .ToStandardTableResult(param, user => new UserQueryResult
            {
                Id             = user.Id,
                IsActive       = user.IsActive,
                UserName       = user.UserName,
                AdminRemark    = user.AdminRemark,
                CreatedOn      = user.CreatedOn,
                Email          = user.Email,
                FullName       = user.FullName,
                LastActivityOn = user.LastActivityOn,
                LastIpAddress  = user.LastIpAddress,
                LastLoginOn    = user.LastLoginOn,
                PhoneNumber    = user.PhoneNumber,
                UpdatedOn      = user.UpdatedOn,
                RoleIds        = user.Roles.Select(c => c.RoleId) // .Distinct().OrderBy(c => c).ToList()
            });

            return(Result.Ok(result));
        }
Exemplo n.º 5
0
        public async Task <StandardTableResult <GoodsListResult> > HomeList(StandardTableParam <GoodsListQueryParam> param)
        {
            var query  = _productRepository.Query();
            var search = param.Search;

            if (search != null)
            {
                if (!string.IsNullOrWhiteSpace(search.Name))
                {
                    query = query.Where(c => c.Name.Contains(search.Name.Trim()));
                }
                if (search.CategoryId.HasValue && search.CategoryId.Value > 0)
                {
                    var ids = new List <int>();
                    ids.Add(search.CategoryId.Value);
                    //递归获取子分类
                    var all = await _categoryService.GetAll();

                    ids.AddRange(_categoryService.GetChildrens(search.CategoryId.Value, all).Select(c => c.Id));
                    var subQuery = from c in query
                                   join b in _productCategoryRepository.Query() on c.Id equals b.ProductId
                                   where ids.Distinct().Contains(b.CategoryId)
                                   select c.Id;
                    query = query.Where(c => subQuery.Distinct().Contains(c.Id));
                }
            }
            var gridData = await query
                           .Include(x => x.ThumbnailImage)
                           .Where(c => c.IsPublished && c.IsVisibleIndividually)
                           .ToStandardTableResult(param, x => new GoodsListResult
            {
                Id                = x.Id,
                Name              = x.Name,
                Slug              = x.Slug,
                Price             = x.Price,
                OldPrice          = x.OldPrice,
                SpecialPrice      = x.SpecialPrice,
                SpecialPriceStart = x.SpecialPriceStart,
                SpecialPriceEnd   = x.SpecialPriceEnd,
                IsAllowToOrder    = x.IsAllowToOrder,
                ThumbnailUrl      = x.ThumbnailImage.Url,
                ReviewsCount      = x.ReviewsCount,
                RatingAverage     = x.RatingAverage,
                ShortDescription  = x.ShortDescription,
                IsPublished       = x.IsPublished,
                IsFeatured        = x.IsFeatured
            });

            return(gridData);
        }
Exemplo n.º 6
0
        public async Task <Result <StandardTableResult <GoodsListResult> > > Grid([FromBody] StandardTableParam <GoodsListQueryParam> param)
        {
            var resultKeyword = await GetKeywordAsync();

            if (!string.IsNullOrWhiteSpace(param?.Search?.Name) && !resultKeyword.HistoryKeywords.Any(c => c.Name == param?.Search?.Name))
            {
                resultKeyword.HistoryKeywords.Insert(0, new Keyword()
                {
                    Name = param?.Search?.Name.Trim()
                });
                if (resultKeyword.HistoryKeywords.Count > 10)
                {
                    resultKeyword.HistoryKeywords = resultKeyword.HistoryKeywords.Take(10).ToList();
                }
                var key = ShopKeys.System + "keywords";
                _staticCacheManager.Set(key, resultKeyword, 30);
            }

            var result = await _productService.HomeList(param);

            return(Result.Ok(result));
        }
Exemplo n.º 7
0
        public async Task <Result <StandardTableResult <ReplyListResult> > > Grid([FromBody] StandardTableParam <ReplyQueryParam> param)
        {
            var search = param?.Search;

            if (search == null)
            {
                throw new ArgumentNullException("参数异常");
            }

            var query = _replyRepository.Query()
                        .Where(c => c.Status == ReplyStatus.Approved && c.ParentId == null && c.ReviewId == search.ReviewId);

            var result = await query
                         .Include(c => c.User)
                         .Include(c => c.Childrens).ThenInclude(c => c.ToUser)
                         .ToStandardTableResult(param, c => new ReplyListResult
            {
                Id           = c.Id,
                Comment      = c.Comment,
                CreatedOn    = c.CreatedOn,
                SupportCount = c.SupportCount,
                Avatar       = c.User.AvatarUrl,
                ReplierName  = c.ReplierName,
                Replies      = c.Childrens.Where(x => x.Status == ReplyStatus.Approved).OrderByDescending(x => x.Id).Select(x => new ReplyListResult()
                {
                    Id           = x.Id,
                    Comment      = x.Comment,
                    ReplierName  = x.ReplierName,
                    CreatedOn    = x.CreatedOn,
                    SupportCount = x.SupportCount,
                    ToUserName   = x.ToUserName
                })
            });

            return(Result.Ok(result));
        }
Exemplo n.º 8
0
        public async Task <Result <StandardTableResult <OrderQueryResult> > > List([FromBody] StandardTableParam <OrderQueryParam> param)
        {
            var query  = _orderRepository.Query();
            var search = param.Search;

            if (search != null)
            {
                if (search.CustomerId.HasValue)
                {
                    query = query.Where(c => c.CustomerId == search.CustomerId.Value);
                }
                if (search.CreatedOnStart.HasValue)
                {
                    query = query.Where(c => c.CreatedOn >= search.CreatedOnStart.Value);
                }
                if (search.CreatedOnEnd.HasValue)
                {
                    query = query.Where(c => c.CreatedOn < search.CreatedOnEnd.Value.AddDays(1));
                }
                if (search.OrderStatus.Count > 0)
                {
                    query = query.Where(c => search.OrderStatus.Contains(c.OrderStatus));
                }
                if (search.ShippingStatus.Count > 0)
                {
                    query = query.Where(c => search.ShippingStatus.Contains(c.ShippingStatus.Value));
                }

                if (!string.IsNullOrWhiteSpace(search.ProductName))
                {
                    query = query.Where(c => c.OrderItems.Any(x => x.Product.Name.Contains(search.ProductName)));
                }
                if (!string.IsNullOrWhiteSpace(search.Sku))
                {
                    query = query.Where(c => c.OrderItems.Any(x => x.Product.Sku.Contains(search.Sku)));
                }
            }

            var result = await query.Include(c => c.Customer)
                         .ToStandardTableResult(param, c => new OrderQueryResult
            {
                Id                = c.Id,
                No                = c.No.ToString(),
                AdminNote         = c.AdminNote,
                BillingAddressId  = c.BillingAddressId,
                CancelOn          = c.CancelOn,
                CancelReason      = c.CancelReason,
                CreatedById       = c.CreatedById,
                CreatedOn         = c.CreatedOn,
                CustomerId        = c.CustomerId,
                CustomerName      = c.Customer.FullName,
                DiscountAmount    = c.DiscountAmount,
                OrderNote         = c.OrderNote,
                OrderStatus       = c.OrderStatus,
                OrderTotal        = c.OrderTotal,
                PaymentFeeAmount  = c.PaymentFeeAmount,
                PaymentMethod     = c.PaymentMethod,
                PaymentOn         = c.PaymentOn,
                PaymentType       = c.PaymentType,
                ShippingAddressId = c.ShippingAddressId,
                ShippingFeeAmount = c.ShippingFeeAmount,
                ShippingMethod    = c.ShippingMethod,
                ShippingStatus    = c.ShippingStatus,
                UpdatedById       = c.UpdatedById,
                UpdatedOn         = c.UpdatedOn
            });

            return(Result.Ok(result));
        }
        public async Task <Result <StandardTableResult <ShipmentQueryResult> > > List([FromBody] StandardTableParam <ShipmentQueryParam> param)
        {
            var query  = _shipmentRepository.Query();
            var search = param?.Search;

            if (search != null)
            {
                if (search.OrderNo.HasValue && search.OrderNo.Value > 0)
                {
                    query = query.Where(c => c.Order.No == search.OrderNo.Value);
                }
                if (!string.IsNullOrWhiteSpace(search.TrackingNumber))
                {
                    query = query.Where(c => c.TrackingNumber.Contains(search.TrackingNumber));
                }
                if (search.ShippedOnStart.HasValue)
                {
                    query = query.Where(c => c.CreatedOn >= search.ShippedOnStart.Value);
                }
                if (search.ShippedOnEnd.HasValue)
                {
                    query = query.Where(c => c.CreatedOn < search.ShippedOnEnd.Value);
                }
            }
            var result = await query
                         .Include(c => c.Order)
                         .Include(c => c.CreatedBy)
                         .Include(c => c.Items).ThenInclude(c => c.OrderItem)
                         .ToStandardTableResult(param, c => new ShipmentQueryResult
            {
                Id             = c.Id,
                AdminComment   = c.AdminComment,
                CreatedBy      = c.CreatedBy.FullName,
                TrackingNumber = c.TrackingNumber,
                DeliveredOn    = c.DeliveredOn,
                OrderId        = c.OrderId,
                OrderNo        = c.Order.No.ToString(),
                OrderStatus    = c.Order.OrderStatus,
                ShippingStatus = c.Order.ShippingStatus,
                ShippedOn      = c.ShippedOn,
                TotalWeight    = c.TotalWeight,
                Items          = c.Items.Select(x => new ShipmentQueryItemResult()
                {
                    Id              = x.Id,
                    CreatedOn       = x.CreatedOn,
                    UpdatedOn       = x.UpdatedOn,
                    Quantity        = x.Quantity,
                    OrderItemId     = x.OrderItemId,
                    ProductId       = x.ProductId,
                    ShipmentId      = x.ShipmentId,
                    OrderedQuantity = x.OrderItem.Quantity,
                    ProductMediaUrl = x.OrderItem.ProductMediaUrl,
                    ProductName     = x.OrderItem.ProductName,
                    ShippedQuantity = x.OrderItem.ShippedQuantity,
                }).ToList()
            });

            return(Result.Ok(result));
        }
Exemplo n.º 10
0
        public async Task <Result <StandardTableResult <StockHistoryQueryResult> > > List([FromBody] StandardTableParam <StockHistoryQueryParam> param)
        {
            var query       = _stockHistoryRepository.Query();
            var warehouseId = param?.Search?.WarehouseId;
            var productId   = param?.Search?.ProductId;

            if (warehouseId.HasValue)
            {
                query = query.Where(c => c.WarehouseId == warehouseId.Value);
            }
            if (productId.HasValue)
            {
                query = query.Where(c => c.ProductId == productId.Value);
            }

            var result = await query.Include(c => c.Warehouse)
                         .ToStandardTableResult(param, c => new StockHistoryQueryResult
            {
                Id               = c.Id,
                WarehouseId      = c.WarehouseId,
                AdjustedQuantity = c.AdjustedQuantity,
                CreatedById      = c.CreatedById,
                CreatedOn        = c.CreatedOn,
                Note             = c.Note,
                ProductId        = c.ProductId,
                StockQuantity    = c.StockQuantity,
                WarehouseName    = c.Warehouse.Name
            });

            return(Result.Ok(result));
        }
Exemplo n.º 11
0
        public async Task <Result <StandardTableResult <PriceAndDestinationQueryResult> > > DataList(int freightTemplateId, [FromBody] StandardTableParam param)
        {
            var query = _priceAndDestinationRepository
                        .Query(c => c.FreightTemplateId == freightTemplateId);
            StateOrProvinceLevel?level = null;
            var result = await query
                         .Include(c => c.Country)
                         .Include(c => c.StateOrProvince)
                         .ToStandardTableResult(param, x => new PriceAndDestinationQueryResult
            {
                Id                   = x.Id,
                CountryId            = x.CountryId,
                FreightTemplateId    = x.FreightTemplateId,
                MinOrderSubtotal     = x.MinOrderSubtotal,
                ShippingPrice        = x.ShippingPrice,
                StateOrProvinceId    = x.StateOrProvinceId,
                Note                 = x.Note,
                CountryName          = x.Country.Name,
                StateOrProvinceName  = x.StateOrProvince != null ? x.StateOrProvince.Name : null,
                StateOrProvinceLevel = x.StateOrProvince != null ? x.StateOrProvince.Level : level,
                CreatedOn            = x.CreatedOn,
                UpdatedOn            = x.UpdatedOn,
                IsEnabled            = x.IsEnabled
            });

            return(Result.Ok(result));
        }
Exemplo n.º 12
0
        public async Task <Result <StandardTableResult <AdminReviewListResult> > > Grid([FromBody] StandardTableParam <AdminReviewQueryParam> param)
        {
            var query  = _reviewRepository.Query();
            var search = param?.Search;

            if (search != null)
            {
                if (search.EntityTypeId.HasValue)
                {
                    if (!entityTypeIds.Any(c => c == search.EntityTypeId.Value))
                    {
                        throw new Exception("参数不支持");
                    }
                    query = query.Where(c => c.EntityTypeId == (int)search.EntityTypeId.Value);
                }

                if (search.EntityId.HasValue)
                {
                    query = query.Where(c => c.EntityId == search.EntityId.Value);
                }

                if (search.Status.HasValue)
                {
                    query = query.Where(c => c.Status == search.Status.Value);
                }

                if (search.Rating.HasValue)
                {
                    query = query.Where(c => c.Rating == search.Rating.Value);
                }

                if (search.IsMedia.HasValue)
                {
                    if (search.IsMedia.Value)
                    {
                        query = query.Where(c => c.Medias.Any());
                    }
                    else
                    {
                        query = query.Where(c => !c.Medias.Any());
                    }
                }
            }

            var result = await query
                         .Include(c => c.Medias).ThenInclude(c => c.Media)
                         .ToStandardTableResult(param, c => new AdminReviewListResult
            {
                Id           = c.Id,
                Comment      = c.Comment,
                CreatedOn    = c.CreatedOn,
                Rating       = c.Rating,
                Title        = c.Title,
                ReviewerName = c.ReviewerName,
                SupportCount = c.SupportCount,
                EntityId     = c.EntityId,
                EntityTypeId = c.EntityTypeId,
                IsAnonymous  = c.IsAnonymous,
                Status       = c.Status,
                UserId       = c.UserId,
                MediaUrls    = c.Medias.OrderBy(x => x.DisplayOrder).Select(x => x.Media.Url)
            });

            return(Result.Ok(result));
        }
Exemplo n.º 13
0
        public async Task <Result <StandardTableResult <CustomerOrderQueryResult> > > List([FromBody] StandardTableParam <CustomerOrderQueryParam> param)
        {
            var user = await _workContext.GetCurrentUserAsync();

            var query = _orderRepository.Query()
                        .Include(c => c.OrderItems)
                        .Include(c => c.Customer)
                        .Where(c => c.CustomerId == user.Id);
            var search = param.Search;

            if (search != null)
            {
                if (search.OrderStatus != null && search.OrderStatus.Count > 0)
                {
                    query = query.Where(c => search.OrderStatus.Contains(c.OrderStatus));
                }

                if (search.ShippingStatus.HasValue)
                {
                    query = query.Where(c => c.ShippingStatus == search.ShippingStatus.Value);
                }
            }

            var result = await query.ToStandardTableResult(param,
                                                           c => new CustomerOrderQueryResult
            {
                Id = c.Id,
                No = c.No.ToString(),
                BillingAddressId  = c.BillingAddressId,
                CancelOn          = c.CancelOn,
                CancelReason      = c.CancelReason,
                CreatedOn         = c.CreatedOn,
                CustomerId        = c.CustomerId,
                CustomerName      = c.Customer.FullName,
                DiscountAmount    = c.DiscountAmount,
                OrderNote         = c.OrderNote,
                OrderStatus       = c.OrderStatus,
                OrderTotal        = c.OrderTotal,
                PaymentFeeAmount  = c.PaymentFeeAmount,
                PaymentMethod     = c.PaymentMethod,
                PaymentOn         = c.PaymentOn,
                PaymentType       = c.PaymentType,
                ShippingAddressId = c.ShippingAddressId,
                ShippingFeeAmount = c.ShippingFeeAmount,
                ShippingMethod    = c.ShippingMethod,
                ShippingStatus    = c.ShippingStatus,
                UpdatedOn         = c.UpdatedOn,
                Items             = c.OrderItems.Select(x => new CustomerOrderItemQueryResult
                {
                    OrderId         = x.OrderId,
                    DiscountAmount  = x.DiscountAmount,
                    ItemAmount      = x.ItemAmount,
                    ItemWeight      = x.ItemWeight,
                    Note            = x.Note,
                    Id              = x.Id,
                    ProductId       = x.ProductId,
                    ProductMediaUrl = x.ProductMediaUrl,
                    ProductName     = x.ProductName,
                    ProductPrice    = x.ProductPrice,
                    Quantity        = x.Quantity,
                    ShippedQuantity = x.ShippedQuantity
                }),    // EF CORE 子查询列表 top bug, 不允许此操作.Take(2), // 列表中最多显示2个商品
                ItemsTotal     = c.OrderItems.Sum(x => x.Quantity),
                ItemsCount     = c.OrderItems.Count,
                PaymentEndOn   = c.PaymentEndOn,
                DeliveredEndOn = c.DeliveredEndOn
            });

            if (result.List?.Count() > 0)
            {
                result.List.ToList().ForEach(c =>
                {
                    if (c.Items?.Count() > 2)
                    {
                        c.Items = c.Items.Take(2).ToList();
                    }
                });
            }
            return(Result.Ok(result));
        }
Exemplo n.º 14
0
        public async Task <Result <StandardTableResult <ProductAttributeDataQueryResult> > > DataList(int attributeId, [FromBody] StandardTableParam <ValueParam> param)
        {
            var query = _productAttrDataRepository.Query(c => c.AttributeId == attributeId);

            if (param.Search != null)
            {
                var value = param.Search.Value;
                if (!string.IsNullOrWhiteSpace(value))
                {
                    query = query.Where(x => x.Value.Contains(value.Trim()));
                }
            }
            var result = await query.Include(c => c.Attribute)
                         .ToStandardTableResult(param, c => new ProductAttributeDataQueryResult
            {
                Id            = c.Id,
                Value         = c.Value,
                Description   = c.Description,
                AttributeId   = c.AttributeId,
                AttributeName = c.Attribute.Name,
                CreatedOn     = c.CreatedOn,
                UpdatedOn     = c.UpdatedOn,
                IsPublished   = c.IsPublished
            });

            return(Result.Ok(result));
        }
Exemplo n.º 15
0
        public async Task <Result <StandardTableResult <ProvinceQueryResult> > > ListProvince(int countryId, [FromBody] StandardTableParam <ProvinceQueryParam> param)
        {
            var query  = _provinceRepository.Query().Where(c => c.CountryId == countryId);
            var search = param.Search;

            if (search != null)
            {
                if (!string.IsNullOrWhiteSpace(search.Name))
                {
                    query = query.Where(c => c.Name.Contains(search.Name.Trim()));
                }
                if (!string.IsNullOrWhiteSpace(search.Code))
                {
                    query = query.Where(c => c.Code.Contains(search.Code.Trim()));
                }
                if (search.ParentId.HasValue)
                {
                    query = query.Where(c => c.ParentId == search.ParentId);
                }
                if (search.Level.Count > 0)
                {
                    query = query.Where(c => search.Level.Contains(c.Level));
                }
            }
            var result = await query.Include(x => x.Parent)
                         .ToStandardTableResult(param, province => new ProvinceQueryResult
            {
                Code         = province.Code,
                CountryId    = province.CountryId,
                CreatedOn    = province.CreatedOn,
                DisplayOrder = province.DisplayOrder,
                Id           = province.Id,
                IsPublished  = province.IsPublished,
                Level        = province.Level,
                Name         = province.Name,
                ParentId     = province.ParentId,
                ParentName   = province.Parent == null ? "" : province.Parent.Name,
                UpdatedOn    = province.UpdatedOn
            });

            return(Result.Ok(result));
        }
        public async Task <Result <StandardTableResult <AdminReplyListResult> > > Grid([FromBody] StandardTableParam <AdminReplyQueryParam> param)
        {
            var query  = _replyRepository.Query();
            var search = param?.Search;

            if (search != null)
            {
                if (search.Status.HasValue)
                {
                    query = query.Where(c => c.Status == search.Status.Value);
                }

                if (!string.IsNullOrWhiteSpace(search.ReplierName))
                {
                    query = query.Where(c => c.ReplierName.Contains(search.ReplierName));
                }
            }
            var result = await query
                         .ToStandardTableResult(param, c => new AdminReplyListResult
            {
                Id           = c.Id,
                Comment      = c.Comment,
                CreatedOn    = c.CreatedOn,
                SupportCount = c.SupportCount,
                ReplierName  = c.ReplierName,
                IsAnonymous  = c.IsAnonymous,
                ParentId     = c.ParentId,
                ReviewId     = c.ReviewId,
                Status       = c.Status,
                ToUserId     = c.ToUserId,
                ToUserName   = c.ToUserName,
                UpdatedOn    = c.UpdatedOn,
                UserId       = c.UserId
            });

            return(Result.Ok(result));
        }
Exemplo n.º 17
0
        public async Task <Result <StandardTableResult <BrandResult> > > List([FromBody] StandardTableParam param)
        {
            var result = await _brandService.List(param);

            return(result);
        }
Exemplo n.º 18
0
        public async Task <Result <StandardTableResult <FreightTemplateQueryResult> > > DataList([FromBody] StandardTableParam param)
        {
            var query  = _freightTemplateRepository.Query();
            var result = await query
                         .ToStandardTableResult(param, x => new FreightTemplateQueryResult
            {
                Id        = x.Id,
                Name      = x.Name,
                Note      = x.Note,
                CreatedOn = x.CreatedOn,
                UpdatedOn = x.UpdatedOn
            });

            return(Result.Ok(result));
        }
Exemplo n.º 19
0
        public async Task <Result <StandardTableResult <WarehouseQueryResult> > > DataList([FromBody] StandardTableParam param)
        {
            var query  = _warehouseRepository.Query();
            var result = await query.Include(w => w.Address)
                         .ToStandardTableResult(param, warehouse => new WarehouseQueryResult
            {
                Id                = warehouse.Id,
                Name              = warehouse.Name,
                AddressId         = warehouse.Address.Id,
                ContactName       = warehouse.Address.ContactName,
                AddressLine1      = warehouse.Address.AddressLine1,
                AddressLine2      = warehouse.Address.AddressLine2,
                Phone             = warehouse.Address.Phone,
                StateOrProvinceId = warehouse.Address.StateOrProvinceId,
                CountryId         = warehouse.Address.CountryId,
                City              = warehouse.Address.City,
                ZipCode           = warehouse.Address.ZipCode,
                AdminRemark       = warehouse.AdminRemark
            });

            return(Result.Ok(result));
        }
Exemplo n.º 20
0
        public async Task <Result <StandardTableResult <ReviewListResult> > > Grid([FromBody] StandardTableParam <ReviewQueryParam> param)
        {
            var search = param?.Search;

            if (search == null)
            {
                throw new ArgumentNullException("参数异常");
            }

            var any = entityTypeIds.Any(c => c == search.EntityTypeId);

            if (!any)
            {
                throw new Exception("参数不支持");
            }

            var query = _reviewRepository.Query()
                        .Where(c => c.Status == ReviewStatus.Approved && c.EntityId == search.EntityId && c.EntityTypeId == (int)search.EntityTypeId);

            if (search.IsMedia.HasValue && search.IsMedia.Value)
            {
                query = query.Where(c => c.Medias.Any());
            }
            if (search.RatingLevel.HasValue)
            {
                switch (search.RatingLevel.Value)
                {
                case RatingLevel.Bad:
                    query = query.Where(c => c.Rating == 1);
                    break;

                case RatingLevel.Medium:
                    query = query.Where(c => c.Rating > 1 && c.Rating < 5);
                    break;

                case RatingLevel.Positive:
                default:
                    query = query.Where(c => c.Rating == 5);
                    break;
                }
            }

            var result = await query
                         .Include(c => c.Medias).ThenInclude(c => c.Media)
                         .Include(c => c.Replies)
                         .Include(c => c.User)
                         .ToStandardTableResult(param, c => new ReviewListResult
            {
                Id           = c.Id,
                Comment      = c.Comment,
                CreatedOn    = c.CreatedOn,
                Rating       = c.Rating,
                Title        = c.Title,
                ReviewerName = c.ReviewerName,
                SupportCount = c.SupportCount,
                Avatar       = c.User.AvatarUrl,
                ReplieCount  = c.Replies.Where(x => x.Status == ReplyStatus.Approved).Count(),
                MediaUrls    = c.Medias.OrderBy(x => x.DisplayOrder).Select(x => x.Media.Url),
                Replies      = c.Replies.Where(x => x.Status == ReplyStatus.Approved && x.ParentId == null)
                               .OrderByDescending(x => x.SupportCount).ThenByDescending(x => x.Id)
                               .Take(2).Select(x => new ReplyListResult()
                {
                    Id           = x.Id,
                    Comment      = x.Comment,
                    ReplierName  = x.ReplierName,
                    CreatedOn    = x.CreatedOn,
                    SupportCount = x.SupportCount
                })
            });

            return(Result.Ok(result));
        }
Exemplo n.º 21
0
        public async Task <Result <StandardTableResult <ProductAttributeResult> > > DataList([FromBody] StandardTableParam param)
        {
            var query  = _productAttrRepository.Query();
            var result = await query.Include(c => c.Group)
                         .ToStandardTableResult(param, x => new ProductAttributeResult
            {
                Id        = x.Id,
                Name      = x.Name,
                GroupName = x.Group.Name,
                GroupId   = x.GroupId
            });

            return(Result.Ok(result));
        }
Exemplo n.º 22
0
        public async Task <Result <StandardTableResult <ProductOptionDataListResult> > > DataList(int optionId, [FromBody] StandardTableParam <ValueParam> param)
        {
            var query = _productOptionDataRepository.Query().Include(c => c.Option).Where(c => c.OptionId == optionId);

            if (param.Search != null)
            {
                var value = param.Search.Value;
                if (!string.IsNullOrWhiteSpace(value))
                {
                    query = query.Where(x => x.Value.Contains(value.Trim()));
                }
            }
            var result = await query.Include(c => c.Option)
                         .ToStandardTableResult(param, c => new ProductOptionDataListResult
            {
                Id                = c.Id,
                Value             = c.Value,
                Description       = c.Description,
                OptionId          = c.OptionId,
                OptionName        = c.Option.Name,
                CreatedOn         = c.CreatedOn,
                UpdatedOn         = c.UpdatedOn,
                IsPublished       = c.IsPublished,
                Display           = c.Display,
                OptionDisplayType = c.Option.DisplayType
            });

            return(Result.Ok(result));
        }
Exemplo n.º 23
0
        public async Task <Result <StandardTableResult <ProductOptionResult> > > DataList([FromBody] StandardTableParam param)
        {
            var query  = _productOptionRepository.Query();
            var result = await query
                         .ToStandardTableResult(param, x => new ProductOptionResult
            {
                Id          = x.Id,
                Name        = x.Name,
                DisplayType = x.DisplayType
            });

            return(Result.Ok(result));
        }
        public async Task <Result <StandardTableResult <CategoryResult> > > List([FromBody] StandardTableParam param)
        {
            var result = await _categoryService.List(param);

            return(result);
        }
        public async Task <Result <StandardTableResult <ProductAttributeTemplateResult> > > DataList([FromBody] StandardTableParam param)
        {
            var query = _productAttrTempRepo.Query()
                        .Include(c => c.ProductAttributes)
                        .ThenInclude(c => c.Attribute)
                        .ThenInclude(c => c.Group);
            var result = await query
                         .ToStandardTableResult(param, x => new ProductAttributeTemplateResult
            {
                Id         = x.Id,
                Name       = x.Name,
                Attributes = x.ProductAttributes.Select(c => new ProductAttributeResult
                {
                    Id        = c.AttributeId,
                    Name      = c.Attribute.Name,
                    GroupId   = c.Attribute.GroupId,
                    GroupName = c.Attribute.Group.Name,
                }).ToList()
            });

            return(Result.Ok(result));
        }