Exemple #1
0
        public async Task DeleteShelf(string symbol)
        {
            var shelfToDelete = Shelves.FirstOrDefault(x => x.Symbol == symbol);

            shelfToDelete.QuantityInStock = 0;
            await UpdateShelf(shelfToDelete);
        }
        public async Task UpdateShelf(Shelf shelf)
        {
            var shelfToUpdate = Shelves.FirstOrDefault(x => x.Symbol == shelf.Symbol);

            shelfToUpdate.QuantityInStock = shelf.QuantityInStock;
            shelfToUpdate.Price           = shelf.Price;
            shelfToUpdate.Name            = shelf.Name;

            context.Shelf.Update(shelfToUpdate);
            await context.SaveChangesAsync();
        }
 public async Task DeleteShelf(string symbol)
 {
     try
     {
         var shelfToDelete = Shelves.FirstOrDefault(x => x.Symbol == symbol);
         context.Shelf.Remove(shelfToDelete);
         await context.SaveChangesAsync();
     }
     catch (Microsoft.EntityFrameworkCore.DbUpdateException)
     {
         return;
     }
 }
Exemple #4
0
 public Shelf GetShelf(string symbol)
 {
     return(Shelves.FirstOrDefault(x => x.Symbol == symbol));
 }