public async Task <IHttpActionResult> UnwatchStock(int id) { var self = await SelfUser(); if (self == null) { return(Unauthorized()); } Stock stock = await Db.Stocks.FirstOrDefaultAsync(s => s.Id == id); if (stock == null) { return(NotFound()); } WatchedStock wStock = await Db.WatchedStocks.FirstOrDefaultAsync(s => s.UserId == self.Id && s.StockId == stock.Id); if (wStock == null) { return(NotFound()); } Db.WatchedStocks.Remove(wStock); await Db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
public async Task TestSqliteWatchList() { var watchedStock = new WatchedStock { Symbol = "TEST" }; await App.Database.SaveWatchListAsync(watchedStock); var watchList = await App.Database.GetWatchListAsync(); var count = watchList.Count; Assert.IsTrue(count > 0); await App.Database.DeleteWatchListAsync(watchedStock); watchList = await App.Database.GetWatchListAsync(); var newCount = watchList.Count; Assert.AreEqual(count - 1, newCount); }
public Task <int> DeleteWatchListAsync(WatchedStock watchStock) { return(_database.DeleteAsync(watchStock)); }
public Task <int> SaveWatchListAsync(WatchedStock watchStock) { return(_database.InsertOrReplaceAsync(watchStock)); }