Пример #1
0
        public virtual FulfillmentCenter ToModel(FulfillmentCenter center)
        {
            center.Id           = Id;
            center.CreatedBy    = CreatedBy;
            center.CreatedDate  = CreatedDate;
            center.ModifiedBy   = ModifiedBy;
            center.ModifiedDate = ModifiedDate;

            center.Address = AbstractTypeFactory <Address> .TryCreateInstance();

            center.Address.City        = City;
            center.Address.CountryCode = CountryCode;
            center.Address.CountryName = CountryName;
            center.Address.Phone       = DaytimePhoneNumber;
            center.Address.Line1       = Line1;
            center.Address.Line2       = Line2;
            center.Address.PostalCode  = PostalCode;
            center.Address.RegionName  = StateProvince;
            center.Address.RegionId    = RegionId;
            center.Address.Email       = Email;

            center.Description = Description;
            center.Name        = Name;
            center.GeoLocation = GeoLocation;

            return(center);
        }
Пример #2
0
        public static FulfillmentCenterDto ToDto(this FulfillmentCenter center)
        {
            var retVal = new FulfillmentCenterDto();

            retVal.InjectFrom(center);
            return(retVal);
        }
Пример #3
0
        public virtual FulfillmentCenterEntity FromModel(FulfillmentCenter center, PrimaryKeyResolvingMap pkMap)
        {
            pkMap.AddPair(center, this);

            Id           = center.Id;
            CreatedBy    = center.CreatedBy;
            CreatedDate  = center.CreatedDate;
            ModifiedBy   = center.ModifiedBy;
            ModifiedDate = center.ModifiedDate;

            if (center.Address != null)
            {
                City               = center.Address.City;
                CountryCode        = center.Address.CountryCode;
                CountryName        = center.Address.CountryName;
                DaytimePhoneNumber = center.Address.Phone;
                Line1              = center.Address.Line1;
                Line2              = center.Address.Line2;
                PostalCode         = center.Address.PostalCode;
                StateProvince      = center.Address.RegionName;
                RegionId           = center.Address.RegionId;
                Email              = center.Address.Email;
            }

            Description = center.Description;
            Name        = center.Name;
            GeoLocation = center.GeoLocation;

            return(this);
        }
Пример #4
0
        public async Task <FulfillmentCenter> GetFulfillmentCenterByIdAsync(string id)
        {
            FulfillmentCenter result = null;
            var centerDto            = await _inventoryApi.GetFulfillmentCenterAsync(id);

            if (centerDto != null)
            {
                result = centerDto.ToFulfillmentCenter();
            }
            return(result);
        }
Пример #5
0
        public static FulfillmentCenter ToFulfillmentCenter(this inventoryDto.FulfillmentCenter centerDto)
        {
            var result = new FulfillmentCenter
            {
                Name        = centerDto.Name,
                Description = centerDto.Description,
                GeoLocation = centerDto.GeoLocation,
                Id          = centerDto.Id
            };

            if (centerDto.Address != null)
            {
                result.Address = centerDto.Address.JsonConvert <AutoRestClients.CoreModuleApi.Models.Address>().ToAddress();
            }
            return(result);
        }
        public static FulfillmentCenter ToShopifyModel(this storefrontModel.FulfillmentCenter center)
        {
            var result = new FulfillmentCenter()
            {
                Description = center.Description,
                GeoLocation = center.GeoLocation,
                Name        = center.Name
            };

            if (center.Address != null)
            {
                result.Address = center.Address.ToShopifyModel();
            }

            return(result);
        }
        private void PopulateInventory(FulfillmentCenter center, IEnumerable <CatalogItem> items)
        {
            if (center == null || items == null || !items.Any())
            {
                return;
            }

            var inventories = _inventoryService.GetProductsInventoryInfos(items.Select(x => x.Id).ToArray()).ToList();

            foreach (var catalogItem in items)
            {
                var productInventory = inventories.FirstOrDefault(x => x.ProductId == catalogItem.Id && x.FulfillmentCenterId == center.Id);
                if (productInventory != null)
                {
                    catalogItem.Inventory = productInventory.ToWebModel();
                }
            }
        }
        public static void CreateFulfillmentCenter(CommerceRepositoryImpl context)
        {
            var center = new FulfillmentCenter
            {
                Id        = "vendor-fulfillment",
                Name      = "Vendor Fulfillment Center",
                PickDelay = 30,
                Line1     = "1232 Wilshire Blvd",
                MaxReleasesPerPickBatch = 20,
                PostalCode         = "90234",
                StateProvince      = "California",
                City               = "Los Angeles",
                CountryName        = "United States",
                CountryCode        = "USA",
                DaytimePhoneNumber = "3232323232"
            };

            context.Add(center);
            context.UnitOfWork.Commit();
        }
Пример #9
0
        private void PopulateInventory(FulfillmentCenter center, IEnumerable <CatalogProduct> products)
        {
            if (center == null || products == null || !products.Any())
            {
                return;
            }

            var inventories = _inventoryService.GetProductsInventoryInfos(products.Select(x => x.Id).ToArray()).ToList();

            foreach (var product in products)
            {
                var productInventory = inventories.FirstOrDefault(x => x.ProductId == product.Id && x.FulfillmentCenterId == center.Id);
                if (productInventory != null)
                {
                    product.Inventories = new List <InventoryInfo> {
                        productInventory
                    }
                }
                ;
            }
        }
Пример #10
0
        private async Task SaveProductInventories(IList <CsvProduct> products, FulfillmentCenter defaultFulfilmentCenter)
        {
            //Set productId for dependent objects
            foreach (var product in products)
            {
                if (defaultFulfilmentCenter != null || product.Inventory.FulfillmentCenterId != null)
                {
                    product.Inventory.ProductId           = product.Id;
                    product.Inventory.FulfillmentCenterId = product.Inventory.FulfillmentCenterId ?? defaultFulfilmentCenter?.Id;
                }
                else
                {
                    product.Inventory = null;
                }
            }
            var productIds       = products.Select(x => x.Id).ToArray();
            var existInventories = await _inventoryService.GetProductsInventoryInfosAsync(productIds);

            var inventories = products.Where(x => x.Inventory != null).Select(x => x.Inventory).Where(x => !string.IsNullOrEmpty(x.ProductId)).ToArray();

            foreach (var inventory in inventories)
            {
                var exitsInventory = existInventories.FirstOrDefault(x => x.ProductId == inventory.ProductId && x.FulfillmentCenterId == inventory.FulfillmentCenterId);
                if (exitsInventory != null)
                {
                    inventory.ProductId                 = exitsInventory.ProductId;
                    inventory.FulfillmentCenterId       = exitsInventory.FulfillmentCenterId;
                    inventory.AllowBackorder            = exitsInventory.AllowBackorder;
                    inventory.AllowPreorder             = exitsInventory.AllowPreorder;
                    inventory.BackorderAvailabilityDate = exitsInventory.BackorderAvailabilityDate;
                    inventory.BackorderQuantity         = exitsInventory.BackorderQuantity;
                    inventory.InTransit                 = exitsInventory.InTransit;

                    inventory.InStockQuantity = inventory.InStockQuantity == 0 ? exitsInventory.InStockQuantity : inventory.InStockQuantity;
                }
            }
            await _inventoryService.SaveChangesAsync(inventories);
        }
 public FulfillmentCenter UpsertFulfillmentCenter(FulfillmentCenter fullfilmentCenter)
 {
     return(_commerceService.UpsertFulfillmentCenter(fullfilmentCenter));
 }
 public FulfillmentCenterAddressStepViewModel(IRepositoryFactory <IFulfillmentCenterRepository> repositoryFactory, IRepositoryFactory <ICountryRepository> countryRepositoryFactory,
                                              IStoreEntityFactory entityFactory, FulfillmentCenter item)
     : base(repositoryFactory, countryRepositoryFactory, entityFactory, item)
 {
 }
 private void Start()
 {
     fulfillmentCenter  = FindObjectOfType <FulfillmentCenter>();
     imageIndex         = 0;
     placeholder.sprite = boxImages[imageIndex];
 }
Пример #14
0
        private void SaveProduct(coreModel.Catalog catalog, FulfillmentCenter defaultFulfillmentCenter, CsvProduct csvProduct)
        {
            var defaultLanguge = catalog.DefaultLanguage != null ? catalog.DefaultLanguage.LanguageCode : "EN-US";

            coreModel.CatalogProduct alreadyExistProduct = null;
            //For new product try to find them by code
            if (csvProduct.IsTransient() && !String.IsNullOrEmpty(csvProduct.Code))
            {
                var criteria = new SearchCriteria
                {
                    CatalogId     = catalog.Id,
                    CategoryId    = csvProduct.CategoryId,
                    Code          = csvProduct.Code,
                    ResponseGroup = SearchResponseGroup.WithProducts | SearchResponseGroup.WithVariations
                };
                var result = _searchService.Search(criteria);
                alreadyExistProduct = result.Products.FirstOrDefault();
                csvProduct.Id       = alreadyExistProduct != null ? alreadyExistProduct.Id : csvProduct.Id;
            }
            else if (!csvProduct.IsTransient())
            {
                //If id specified need check that product really exist
                alreadyExistProduct = _productService.GetById(csvProduct.Id, ItemResponseGroup.ItemInfo);
            }
            var isNewProduct = alreadyExistProduct == null;

            csvProduct.CatalogId = catalog.Id;

            if (String.IsNullOrEmpty(csvProduct.Code))
            {
                csvProduct.Code = _skuGenerator.GenerateSku(csvProduct);
            }
            //Set a parent relations
            if (csvProduct.MainProductId == null && csvProduct.MainProduct != null)
            {
                csvProduct.MainProductId = csvProduct.MainProduct.Id;
            }
            csvProduct.EditorialReview.LanguageCode = defaultLanguge;
            csvProduct.SeoInfo.LanguageCode         = defaultLanguge;
            csvProduct.SeoInfo.SemanticUrl          = String.IsNullOrEmpty(csvProduct.SeoInfo.SemanticUrl) ? csvProduct.Code : csvProduct.SeoInfo.SemanticUrl;

            var properties = !String.IsNullOrEmpty(csvProduct.CategoryId) ? _categoryService.GetById(csvProduct.CategoryId, CategoryResponseGroup.WithProperties).Properties : _catalogService.GetById(csvProduct.CatalogId).Properties;

            if (csvProduct.PropertyValues != null)
            {
                //Try to fill properties meta information for values
                foreach (var propertyValue in csvProduct.PropertyValues)
                {
                    if (propertyValue.Value != null)
                    {
                        var property = properties.FirstOrDefault(x => String.Equals(x.Name, propertyValue.PropertyName));
                        if (property != null)
                        {
                            propertyValue.ValueType = property.ValueType;
                            if (property.Dictionary)
                            {
                                property = _propertyService.GetById(property.Id);
                                var dicValue = property.DictionaryValues.FirstOrDefault(x => String.Equals(x.Value, propertyValue.Value));
                                propertyValue.ValueId = dicValue != null ? dicValue.Id : null;
                            }
                        }
                    }
                }
            }

            if (!isNewProduct)
            {
                _productService.Update(new coreModel.CatalogProduct[] { csvProduct });
            }
            else
            {
                var newProduct = _productService.Create(csvProduct);
                csvProduct.Id = newProduct.Id;
            }

            //Create price in default price list

            if (csvProduct.Price.EffectiveValue > 0)
            {
                csvProduct.Price.ProductId = csvProduct.Id;

                if (csvProduct.Price.IsTransient() || _pricingService.GetPriceById(csvProduct.Price.Id) == null)
                {
                    _pricingService.CreatePrice(csvProduct.Price);
                }
                else
                {
                    _pricingService.UpdatePrices(new Price[] { csvProduct.Price });
                }
            }

            //Create inventory
            csvProduct.Inventory.ProductId           = csvProduct.Id;
            csvProduct.Inventory.FulfillmentCenterId = csvProduct.Inventory.FulfillmentCenterId ?? defaultFulfillmentCenter.Id;
            _inventoryService.UpsertInventory(csvProduct.Inventory);
        }
Пример #15
0
        public async Task <IActionResult> SaveFulfillmentCenter([FromBody] FulfillmentCenter center)
        {
            await _fulfillmentCenterService.SaveChangesAsync(new[] { center });

            return(Ok(center));
        }
Пример #16
0
 public FulfillmentCenter UpsertFulfillmentCenter(FulfillmentCenter fullfilmentCenter)
 {
     return(fullfilmentCenter);
 }
 public CreateFulfillmentCenterViewModel(IViewModelsFactory <IFulfillmentCenterOverviewStepViewModel> overviewVmFactory, IViewModelsFactory <IFulfillmentCenterAddressStepViewModel> addressVmFactory, FulfillmentCenter item)
 {
     RegisterStep(overviewVmFactory.GetViewModelInstance(new KeyValuePair <string, object>("item", item), new KeyValuePair <string, object>("isWizardMode", true)));
     RegisterStep(addressVmFactory.GetViewModelInstance(new KeyValuePair <string, object>("item", item), new KeyValuePair <string, object>("isWizardMode", true)));
 }
Пример #18
0
 public IHttpActionResult SaveFulfillmentCenter(FulfillmentCenter center)
 {
     _fulfillmentCenterService.SaveChanges(new[] { center });
     return(Ok(center));
 }