Ejemplo n.º 1
0
        public virtual ActionResult Clone(int id)
        {
            LogI("Clone, id=" + id);

            IList <MessageString> messages = null;

            var model = ItemEditViewModel.Clone(Db,
                                                Cache,
                                                BarcodeService,
                                                ActionService,
                                                AutoCreateListingService,
                                                ItemHistoryService,
                                                id,
                                                Time.GetAppNowTime(),
                                                AccessManager.UserId,
                                                null,
                                                out messages);

            return(JsonGet(CallResult <ItemEditViewModel> .Success(model)));
        }
Ejemplo n.º 2
0
        private void RelistSKUsIfNeed(IList <string> relistSkuList)
        {
            using (var db = _dbFactory.GetRWDb())
            {
                var listingsWithIssues =
                    db.Items.GetAllViewActual()
                    .Where(l => relistSkuList.Contains(l.SKU) && l.Market == (int)MarketType.Walmart)
                    .ToList();
                var styleItemIds = listingsWithIssues.Select(l => l.StyleItemId).Distinct().ToList();
                var allListings  =
                    db.Items.GetAllViewActual()
                    .Where(l => styleItemIds.Contains(l.StyleItemId) && l.Market == (int)MarketType.Walmart)
                    .ToList();

                foreach (var issueListing in listingsWithIssues)
                {
                    var styleItemListings = allListings.Where(l => l.StyleItemId == issueListing.StyleItemId).ToList();
                    if (styleItemListings.Count != 1)
                    {
                        _log.Info("Skipped. Style size has more than 1 or 0 market listings = " + styleItemListings.Count);
                        continue;
                    }
                    if (styleItemListings.Sum(l => l.RealQuantity) <= 5)
                    {
                        _log.Info("Skipped. Listing with low qty, qty < 5");
                        continue;
                    }

                    _log.Info("Create clone with our barcodes, for=" + issueListing.SKU);

                    var parentASIN = issueListing.ParentASIN;
                    //Clone it, with comment
                    var parentItem = db.ParentItems.GetByASIN(parentASIN, MarketType.Walmart, null);
                    IList <MessageString> messages;
                    var itemHistoryService = new ItemHistoryService(_log, _time, _dbFactory);
                    var result             = ItemEditViewModel.Clone(db,
                                                                     _cacheService,
                                                                     _barcodeService,
                                                                     _actionService,
                                                                     _autoCreateListingService,
                                                                     itemHistoryService,
                                                                     parentItem.Id,
                                                                     _time.GetAppNowTime(),
                                                                     null,
                                                                     "[system] Copy created due the original barcodes are non-competitive",
                                                                     out messages);

                    if (messages.Any())
                    {
                        _log.Info("ASIN=" + issueListing.ASIN + " has clone issues");
                        foreach (var msg in messages)
                        {
                            _log.Info("ASIN: " + issueListing.ASIN + ", issue: " + msg);
                        }
                    }
                    else
                    {
                        _log.Info("ASIN=" + issueListing.ASIN + " was cloned");
                    }

                    allListings.AddRange(db.Items.GetAllViewActual()
                                         .Where(i => i.ParentASIN == result.ASIN && i.Market == (int)MarketType.Walmart)
                                         .ToList());
                }
            }
        }