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); }
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); }