Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        // currently only doing main store
        private async System.Threading.Tasks.Task UnmapFromStoreAsync(Product product, ProductAbcDescription pad)
        {
            var mainStore = (await _storeService.GetAllStoresAsync())
                            .Where(s => !s.Name.ToLower().Contains("clearance"))
                            .First();
            var mainStoreMapping = (await _storeMappingService.GetStoreMappingsAsync(product))
                                   .Where(sm => sm.StoreId == mainStore.Id)
                                   .FirstOrDefault();

            if (mainStoreMapping != null)
            {
                await _storeMappingService.DeleteStoreMappingAsync(mainStoreMapping);
            }
        }
Ejemplo n.º 3
0
 public bool ProductIsAbc(int productId)
 {
     return(_staticCacheManager.Get(new CacheKey(string.Format(PRODUCTISABC_KEY, productId), "Abc."),
                                    () => { return ProductAbcDescription.GetByProductIdFunc(EngineContext.Current.Resolve <IRepository <ProductAbcDescription> >(), productId)() != null; }));
 }
Ejemplo n.º 4
0
 public ProductAbcDescription GetProductAbcDescriptionByProductId(int productId)
 {
     return(_staticCacheManager.Get(new CacheKey(string.Format(ProductAbcDescription.PRODUCTABCDESCRIPTION_BY_PRODID_KEY, productId), "Abc."),
                                    ProductAbcDescription.GetByProductIdFunc(EngineContext.Current.Resolve <IRepository <ProductAbcDescription> >(), productId)));
 }