Esempio n. 1
0
        private ProductBagModel GetData(ProductCommandDescriptor descriptor)
        {
            IQueryable <Litium.Domain.Entities.ProductCatalog.Product> products = null;
            var bagModel = new ProductBagModel();

            if (descriptor is CategoryCommandDescriptor)
            {
                products             = GetDataByCategory(descriptor);
                bagModel.TypeRequest = RequestType.Category;
            }

            if (descriptor is ProductSetCommandDescriptor)
            {
                products = GetDataByProductSet(descriptor);
            }

            if (descriptor is SearchCommandDescriptor)
            {
                products             = GetDataByKeyWord((SearchCommandDescriptor)descriptor);
                bagModel.TypeRequest = RequestType.Search;
            }

            if (descriptor is BrandCommandDescriptor)
            {
                products             = FilterByBrand(products, (BrandCommandDescriptor)descriptor);
                bagModel.TypeRequest = RequestType.Category;
            }

            IList <ProductModel> productModels = products.ToList().ConvertAll(ConvertFrom);

            productModels = productModels.ApplyCampaigns();
            productModels = productModels.OrderByDescending(x => x.IsInCampaign).ThenBy(x => x.CampaignPrice).ToList();
            productModels = productModels.ApplyPaging(descriptor.Page, descriptor.PageSize);


            bagModel.Id       = descriptor.EnityId;
            bagModel.Products = productModels;

            if (descriptor.EnityId != Guid.Empty)
            {
                bagModel.Name = Repository.Data.Get <Category>(descriptor.EnityId).Name;
            }

            return(bagModel);
        }
Esempio n. 2
0
        private ProductBagModel GetData(ProductCommandDescriptor descriptor)
        {
            IQueryable<Litium.Domain.Entities.ProductCatalog.Product> products = null;
            var bagModel = new ProductBagModel();

            if (descriptor is CategoryCommandDescriptor)
            {
                products = GetDataByCategory(descriptor);
                bagModel.TypeRequest = RequestType.Category;
            }

            if (descriptor is ProductSetCommandDescriptor)
                products = GetDataByProductSet(descriptor);

            if (descriptor is SearchCommandDescriptor)
            {
                products = GetDataByKeyWord((SearchCommandDescriptor)descriptor);
                bagModel.TypeRequest = RequestType.Search;
            }

            if (descriptor is BrandCommandDescriptor)
            {
                products = FilterByBrand(products, (BrandCommandDescriptor)descriptor);
                bagModel.TypeRequest = RequestType.Category;
            }

            IList<ProductModel> productModels = products.ToList().ConvertAll(ConvertFrom);
            productModels = productModels.ApplyCampaigns();
            productModels = productModels.OrderByDescending(x => x.IsInCampaign).ThenBy(x => x.CampaignPrice).ToList();
            productModels = productModels.ApplyPaging(descriptor.Page, descriptor.PageSize);

            bagModel.Id = descriptor.EnityId;
            bagModel.Products = productModels;

            if (descriptor.EnityId != Guid.Empty)
                bagModel.Name = Repository.Data.Get<Category>(descriptor.EnityId).Name;

            return bagModel;
        }