예제 #1
0
        public async Task <Guid> CreateBeerStockItem(BeerStockItemEntity item)
        {
            var newBeerStockItem = await _context.StockItem.AddAsync(item);

            await _context.SaveChangesAsync();

            return(newBeerStockItem.Entity.Id);
        }
 public static BeerStockItem ToModel(this BeerStockItemEntity entity)
 {
     return(new BeerStockItem
     {
         Id = entity.Id,
         Beer = entity.Beer.ToModel(),
         Quantity = entity.Quantity,
         UnitPrice = entity.UnitPrice,
         Wholesaler = entity.Wholesaler.ToModel()
     });
 }
예제 #3
0
        public async Task <Guid> UpdateStockItem(BeerStockItemEntity beerStockItem)
        {
            var beerStockItemToUpdate = await _context.StockItem.FirstOrDefaultAsync(item => item.Id.Equals(beerStockItem.Id));

            beerStockItemToUpdate.Quantity     = beerStockItem.Quantity;
            beerStockItemToUpdate.UnitPrice    = beerStockItem.UnitPrice;
            beerStockItemToUpdate.WholesalerId = beerStockItem.WholesalerId;
            beerStockItemToUpdate.BeerId       = beerStockItem.BeerId;

            await _context.SaveChangesAsync();

            return(beerStockItem.Id);
        }