public async Task <bool> RemoveOrderAsync(int orderId)
        {
            var order = await _context.Orders.FindAsync(orderId);

            _context.Orders.Remove(order);
            return(await _context.SaveChangesAsync() > 0);
        }
Exemplo n.º 2
0
 public async Task <OrderDetail> AddOrderDetailAsync(OrderDetail orderDetail)
 {
     _context.OrderDetails.Add(orderDetail);
     if (await _context.SaveChangesAsync() > 0)
     {
         return(orderDetail);
     }
     return(null);
 }
        public async Task <Product> AddProductAsync(Product product)
        {
            await _context.Products.AddAsync(product);

            var recEffected = await _context.SaveChangesAsync();

            if (recEffected == 1)
            {
                _logger.LogInformation($"***EFProductRepository.AddProductAsync, New Product: {product.ProductName}, added Successfully***");
                return(product);
            }
            return(null);
        }
Exemplo n.º 4
0
 public async Task CreateAsync(Product product)
 {
     try
     {
         _context.Products.Add(product);
         await _context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, $"Error in ProductRepository.CreateAsync(product={product})");
         throw;
     }
 }
Exemplo n.º 5
0
        public async Task CreateAsync(Product product)
        {
            try
            {
                _context.Products.Add(product);
                await _context.SaveChangesAsync();

                LogInfo("ProductRepository.CreateAsync");
            }
            catch (Exception ex)
            {
                LogError($"ProductRepository.CreateAsync - {ex.Message}");
                throw;
            }
        }