Exemplo n.º 1
0
        public void Delete(int id)
        {
            var portfolioEntries = dbContext.Portfolios.Where(p => p.StockId == id);

            foreach (var entry in portfolioEntries)
            {
                var userId = entry.UserId;
                var symbol = entry.StockSymbol;
                dbContext.Entry(entry).State = System.Data.Entity.EntityState.Deleted;
            }
            var transactionLogs = dbContext.TransactionLogs.Where(t => t.StockId == id);

            foreach (var log in transactionLogs)
            {
                dbContext.Entry(log).State = System.Data.Entity.EntityState.Deleted;
            }
            var stockHistories = dbContext.StockHistories.Where(h => h.StockId == id);

            foreach (var history in stockHistories)
            {
                dbContext.Entry(history).State = System.Data.Entity.EntityState.Deleted;
            }
            var stock = dbContext.Stocks.Where(s => s.ID == id).FirstOrDefault();

            dbContext.Entry(stock).State = System.Data.Entity.EntityState.Deleted;
            dbContext.SaveChanges();
        }
Exemplo n.º 2
0
        public void Delete(int id)
        {
            var user = dbContext.Users.Where(s => s.ID == id).FirstOrDefault();

            dbContext.Entry(user).State = System.Data.Entity.EntityState.Deleted;
            dbContext.SaveChanges();
        }
Exemplo n.º 3
0
        public void Delete(int userId, string stockSymbol)
        {
            var stock = dbContext.Portfolios.Where(s => s.UserId == userId && s.StockSymbol == stockSymbol).FirstOrDefault();

            dbContext.Entry(stock).State = System.Data.Entity.EntityState.Deleted;
            dbContext.SaveChanges();
        }
Exemplo n.º 4
0
        public void Delete(int id)
        {
            var log = dbContext.TransactionLogs.Where(s => s.Id == id).FirstOrDefault();

            dbContext.Entry(log).State = System.Data.Entity.EntityState.Deleted;
            dbContext.SaveChanges();
        }
        public void Delete(int id)
        {
            var stockhistory = dbContext.StockHistories.Where(s => s.Id == id).FirstOrDefault();

            dbContext.Entry(stockhistory).State = System.Data.Entity.EntityState.Deleted;
            dbContext.SaveChanges();
        }