Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public Task <int> DeleteWatchListAsync(WatchedStock watchStock)
 {
     return(_database.DeleteAsync(watchStock));
 }
Exemplo n.º 4
0
 public Task <int> SaveWatchListAsync(WatchedStock watchStock)
 {
     return(_database.InsertOrReplaceAsync(watchStock));
 }