コード例 #1
0
            public async Task <List <PortfolioItem> > UpdateSoldToDb(StockXAccount login)
            {
                List <PortfolioItem> ListedItems = await login.GetAllPending();

                if (ListedItems == null)
                {
                    Db.UpdateOnly(() => new StockXAccount()
                    {
                        AccountThread = "", NextAccountInteraction = DateTime.Now.AddMinutes(1)
                    }, A => A.Id == login.Id);

                    return(null);
                }

                foreach (var A in ListedItems)
                {
                    if (UpdateToSold(login, A))
                    {
                        ListingExtensions.CreateStockXListingEvent("Sold", A.ChainId, A.SkuUuid, (int)A.LocalAmount, login.UserId, "Sold");

                        Db.UpdateAdd(() => new Inventory()
                        {
                            TotalSold = 1
                        }, Db.From <Inventory>().Where(Ab => Ab.UserId == login.UserId && Ab.Sku == A.SkuUuid));

                        await StockxListingEvent.Sold(A, login);
                    }
                }

                return(ListedItems);
            }
コード例 #2
0
            private async Task <bool> ProcessNewBid(StockXAccount login, PortfolioItem Item, Inventory Invntory)
            {
                var Bids = Db.Select(Db.From <StockXBid>().Where(I => I.Sku == Item.SkuUuid && I.Bid >= Invntory.MinSell && I.Bid < Invntory.StartingAsk).OrderByDescending(A => A.Bid));
                var Bid  = Bids.FirstOrDefault();

                if (Bid != null && Bid.Bid != Item.Amount)
                {
                    var Result = await login.UpdateListing(Item.ChainId, Invntory.Sku, Item.ExpiresAt, (int)Bid.Bid);

                    string actionTaken = $"Update Because Bid ({Item.Amount}) -> ({Bid.Bid})";
                    AuditExtensions.CreateAudit(Db, login.Id, "StockxListingGetter", actionTaken, JsonConvert.SerializeObject(Result));
                    ListingExtensions.CreateStockXListingEvent("Bid", Item.ChainId, Invntory.Sku, (int)Bid.Bid, login.UserId, actionTaken);
                    if ((int)Result.Code > 399 && (int)Result.Code < 500)
                    {
                        throw new NeedsVerificaitonException(login);
                    }
                    if (Result.Code == System.Net.HttpStatusCode.OK)
                    {
                        return(true);
                    }
                }
                return(false);
            }
コード例 #3
0
            private async Task <bool> ProcessNewAsk(StockXAccount login, PortfolioItem Item, Inventory Invntory)
            {
                var Asks = Db.Select(Db.From <StockXAsk>().Where(I => I.Sku == Item.SkuUuid && I.Ask >= Invntory.MinSell + 1 && I.Ask < Item.Amount).OrderBy(A => A.Ask));
                var Ask  = Asks.FirstOrDefault();

                if (Ask != null)
                {
                    var Result = await login.UpdateListing(Item.ChainId, Invntory.Sku, Item.ExpiresAt, (int)Ask.Ask - 1);

                    if ((int)Result.Code > 399 && (int)Result.Code < 500)
                    {
                        throw new NeedsVerificaitonException(login);
                    }
                    if (Result.Code == System.Net.HttpStatusCode.OK)
                    {
                        string actionTaken = $"Update Because Ask ({Item.Amount}) -> ({Ask.Ask})";
                        AuditExtensions.CreateAudit(Db, login.Id, "StockxListingGetter", actionTaken, Item.ChainId);
                        ListingExtensions.CreateStockXListingEvent("Bid", Item.ChainId, Invntory.Sku, (int)Ask.Ask, login.UserId, actionTaken);
                        return(true);
                    }
                    return(true);
                }
                return(false);
            }