Пример #1
0
        /// <summary>
        /// Create a new Listings object.
        /// </summary>
        /// <param name="listingID">Initial value of the ListingID property.</param>
        /// <param name="mPN">Initial value of the MPN property.</param>
        /// <param name="quantity">Initial value of the Quantity property.</param>
        /// <param name="sellingPrice">Initial value of the SellingPrice property.</param>
        /// <param name="isUsed">Initial value of the IsUsed property.</param>
        public static Listings CreateListings(global::System.String listingID, global::System.String mPN, global::System.Int32 quantity, global::System.Decimal sellingPrice, global::System.Boolean isUsed)
        {
            Listings listings = new Listings();

            listings.ListingID    = listingID;
            listings.MPN          = mPN;
            listings.Quantity     = quantity;
            listings.SellingPrice = sellingPrice;
            listings.IsUsed       = isUsed;
            return(listings);
        }
Пример #2
0
        private static void OnTimer()
        {
            using (var context = new EbayDb())
            {
                var items = context.Listings.Where(x => !x.IsUsed);
                if (items.Any())
                {
                    #region
                    foreach (var item in items.ToList())
                    {
                        GetItemCall apiCall = new GetItemCall(apiContext);
                        var         status  = apiCall.GetItem(item.ListingID).SellingStatus.ListingStatus;
                        if (status == ListingStatusCodeType.Active)
                        {
                            item.ApiCallType = ApiCallTypes.Updating;
                            item.Revise(apiContext);
                        }
                        else if (status == ListingStatusCodeType.Completed || status == ListingStatusCodeType.Ended)
                        {
                            item.ApiCallType = ApiCallTypes.Relisting;
                            item.Relist(apiContext);
                        }

                        itemsList.Add(item);
                        if (item.IsApiCallSuccess)
                        {
                            if (item.ApiCallType == ApiCallTypes.Updating)
                            {
                                item.IsUsed = true;
                                context.SaveChanges();
                            }
                            else if (item.ApiCallType == ApiCallTypes.Relisting)
                            {
                                using (TransactionScope scope = new TransactionScope())
                                {
                                    context.DeleteObject(item);
                                    var newItem = new Listings
                                    {
                                        ListingID      = item.RelistedItemID,
                                        RelistedItemID = item.ListingID,
                                        MPN            = item.MPN,
                                        SellingPrice   = item.SellingPrice,
                                        Quantity       = item.Quantity,
                                        IsUsed         = true
                                    };
                                    context.Listings.AddObject(newItem);
                                    context.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave);
                                    scope.Complete();
                                    context.AcceptAllChanges();
                                }
                            }
                        }
                    }
                    #endregion

                    CreateXmlFile(itemsList);
                }
            }

            itemsList.Clear();
            RestartTimer();
        }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Listings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToListings(Listings listings)
 {
     base.AddObject("Listings", listings);
 }