コード例 #1
0
        public IList <AbcMattressBase> GetAbcMattressBasesByModelId(int modelId)
        {
            var entries  = _abcMattressEntryService.GetAbcMattressEntriesByModelId(modelId);
            var packages = _abcMattressPackageService.GetAbcMattressPackagesByEntryIds(entries.Select(e => e.Id));
            var baseIds  = packages.Select(p => p.AbcMattressBaseId);

            return(_abcMattressBaseRepository.Table
                   .Where(amb => baseIds.Contains(amb.Id) &&
                          !(amb.Name == null || amb.Name.Trim() == string.Empty))
                   .ToList());
        }
コード例 #2
0
ファイル: YahooService.cs プロジェクト: abcwarehouse/nop
        private (string, decimal) GetCodeAndPrice(
            OrderItem orderItem,
            Product product,
            ProductAbcDescription productAbcDescription
            )
        {
            var mattressSize = orderItem.GetMattressSize();

            if (mattressSize != null)
            {
                var model = _abcMattressModelService.GetAbcMattressModelByProductId(product.Id);
                if (model == null)
                {
                    throw new Exception($"Unable to find model for productId {product.Id}, size {mattressSize}");
                }

                var entry = _abcMattressEntryService.GetAbcMattressEntriesByModelId(model.Id)
                            .Where(e => e.Size == mattressSize)
                            .FirstOrDefault();
                if (entry == null)
                {
                    throw new Exception($"Unable to find entry for model {model.Name}, size {mattressSize}");
                }

                var baseName = orderItem.GetBase();
                if (baseName != null)
                {
                    var abcMattressBase = _abcMattressBaseService.GetAbcMattressBasesByEntryId(entry.Id)
                                          .Where(b => b.Name == baseName)
                                          .FirstOrDefault();
                    if (abcMattressBase == null)
                    {
                        throw new Exception($"Unable to find base for model {model.Name}, size {entry.Size}, base {baseName}");
                    }
                    var package = _abcMattressPackageService.GetAbcMattressPackagesByEntryIds(new int[] { entry.Id })
                                  .Where(p => p.AbcMattressBaseId == abcMattressBase.Id)
                                  .FirstOrDefault();
                    if (package == null)
                    {
                        throw new Exception($"Unable to find base for model {model.Name}, size {entry.Size}, base {baseName}");
                    }

                    return(package.ItemNo, package.Price);
                }


                return(entry.ItemNo, entry.Price);
            }

            return(productAbcDescription != null ?
                   productAbcDescription.AbcItemNumber : product.Sku,
                   orderItem.UnitPriceExclTax);
        }
コード例 #3
0
        private async Task SyncSynchronyPaymentsDataAsync(Product product, AbcMattressModel model)
        {
            var entries  = _abcMattressEntryService.GetAbcMattressEntriesByModelId(model.Id);
            var packages = _abcMattressPackageService.GetAbcMattressPackagesByEntryIds(entries.Select(e => e.Id));

            var itemNos = entries.Select(e => e.ItemNo).Union(packages.Select(p => p.ItemNo));

            int?     months           = null;
            bool?    isMinimumPayment = null;
            DateTime?startDate        = null;
            DateTime?endDate          = null;

            foreach (var itemNo in itemNos)
            {
                var productAbcFinance = await _productAbcFinanceService.GetProductAbcFinanceByAbcItemNumberAsync(itemNo);

                if (productAbcFinance == null)
                {
                    continue;
                }

                months           = productAbcFinance.Months;
                isMinimumPayment = productAbcFinance.IsDeferredPricing;
                startDate        = productAbcFinance.StartDate.Value;
                endDate          = productAbcFinance.EndDate.Value;
            }

            await _genericAttributeService.SaveAttributeAsync <int?>(
                product,
                "SynchronyPaymentMonths",
                months
                );

            await _genericAttributeService.SaveAttributeAsync <bool?>(
                product,
                "SynchronyPaymentIsMinimum",
                isMinimumPayment
                );

            await _genericAttributeService.SaveAttributeAsync <DateTime?>(
                product,
                "SynchronyPaymentOfferValidFrom",
                startDate
                );

            await _genericAttributeService.SaveAttributeAsync <DateTime?>(
                product,
                "SynchronyPaymentOfferValidTo",
                endDate
                );
        }