public async Task SellTrade(int id) { Trade trade = db.Trades.Where(t => t.Id == id).Single(); var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); Customer customer = db.Customers.Include(c => c.API).Where(c => c.UserId == userId).Single(); API api = customer.API; Cancel cancel = new Cancel(); if (await cancel.TradeAsync(trade) && trade.DisplayType != "BOVC") { trade.Status = false; db.Update(trade); await db.SaveChangesAsync(); Sell sell = new Sell(api); decimal sellPrice = await sell.MarketAsyncTrade(trade); if (sellPrice != 0m) { //Success } } else if (trade.DisplayType == "BOVC") { trade.Status = false; db.Update(trade); await db.SaveChangesAsync(); Sell sell = new Sell(api); decimal sellPrice = await sell.MarketAsyncTrade(trade); if (sellPrice != 0m) { //Success } } }