예제 #1
0
        private void Validate(Item item, BonanzaEntry entry)
        {
            if (string.IsNullOrWhiteSpace(entry.Code))
            {
                if (string.IsNullOrWhiteSpace(entry.FullDescription))
                {
                    entry.Message = "full description required";
                    entry.Status  = StatusCode.Error;
                }

                if (entry.Q < 1)
                {
                    entry.Message = "quantity must be greater than zero";
                    entry.Status  = StatusCode.Error;
                }

                if (string.IsNullOrWhiteSpace(entry.Title))
                {
                    entry.Message = "title required";
                    entry.Status  = StatusCode.Error;
                }
            }

            if (entry.Q > item.QtyAvailable)
            {
                entry.Message = "out of stock";
                entry.Status  = StatusCode.Error;
            }
            if (item.Department == null)
            {
                entry.Message = "department required";
                entry.Status  = StatusCode.Error;
            }
            if (entry.Title != null && entry.Title.Count() > 80)
            {
                entry.Message = "title max characters is 80";
                entry.Status  = StatusCode.Error;
            }
        }
예제 #2
0
        private void UpdateGroup(Item item, IEnumerable <BonanzaEntry> group)
        {
            var active = item.BonanzaListingItems.Where(p => p.Listing.Marketplace.Code.Equals(_marketplaceCode) && !p.Listing.Status.Equals(BonanzaMarketplace.STATUS_ENDED));

            var existingEntries = group.ToList();

            foreach (var listingItem in active)
            {
                BonanzaEntry entry = existingEntries.FirstOrDefault(p => p.IsValid());

                if (entry != null)
                {
                    entry.Code = listingItem.Listing.Code;

                    if (entry.Q.Value == listingItem.Quantity && decimal.Compare(entry.P.Value, listingItem.Price) == 0 && entry.GetUpdateFlags().Count == 0)
                    {
                        entry.Status = StatusCode.Completed;
                    }
                    else
                    {
                        entry.Message = string.Format("({0}|{1})", listingItem.Quantity, Math.Round(listingItem.Price, 2));
                    }

                    existingEntries.Remove(entry);
                }
                else
                {
                    entry = existingEntries.FirstOrDefault(p => !p.IsValid());

                    if (entry != null)
                    {
                        entry.Message = "modified by program";
                        existingEntries.Remove(entry);
                    }
                    else
                    {
                        entry     = new BonanzaEntry();
                        entry.Sku = item.ItemLookupCode;

                        entry.Brand     = item.SubDescription1;
                        entry.ClassName = item.ClassName;
                        entry.Message   = "added by program";

                        _addedEntries.Add(entry);
                    }

                    entry.Format          = "GTC";
                    entry.Code            = listingItem.Listing.Code;
                    entry.P               = listingItem.Price;
                    entry.Q               = listingItem.Quantity;
                    entry.FullDescription = listingItem.Listing.FullDescription;
                    entry.Title           = listingItem.Listing.Title;
                    entry.Status          = StatusCode.Completed;
                }
            }

            foreach (var entry in existingEntries)
            {
                BonanzaListing listing = _dataContext.BonanzaListings.SingleOrDefault(p => p.Sku.Equals(item.ClassName) && !p.Status.Equals(BonanzaMarketplace.STATUS_ENDED));

                if (listing != null)
                {
                    if (!entry.IsValid())
                    {
                        entry.Code            = listing.Code;
                        entry.Title           = listing.Title;
                        entry.FullDescription = listing.FullDescription;
                        entry.Format          = "GTC";
                        entry.Message         = "modified by program";
                    }
                    else if (entry.Format.Equals("GTC"))
                    {
                        entry.Code    = listing.Code;
                        entry.Message = "modified by program";
                    }
                }
            }
        }