コード例 #1
0
        public async void AddTerritory(Territories territoryToAdd)
        {
            if (territoryToAdd == null)
            {
                throw new ArgumentNullException(nameof(territoryToAdd));
            }

            await _context.AddAsync(territoryToAdd);
        }
コード例 #2
0
        public async void AddSupplier(Suppliers supplierToAdd)
        {
            if (supplierToAdd == null)
            {
                throw new ArgumentNullException(nameof(supplierToAdd));
            }

            await _context.AddAsync(supplierToAdd);
        }
コード例 #3
0
        public async void AddProduct(Products productToAdd)
        {
            if (productToAdd == null)
            {
                throw new ArgumentNullException(nameof(productToAdd));
            }

            await _context.AddAsync(productToAdd);
        }
コード例 #4
0
        public async void AddEmployee(Employees employeeToAdd)
        {
            if (employeeToAdd == null)
            {
                throw new ArgumentNullException(nameof(employeeToAdd));
            }

            await _context.AddAsync(employeeToAdd);
        }
コード例 #5
0
        public async void AddRegion(Regions regionToAdd)
        {
            if (regionToAdd == null)
            {
                throw new ArgumentNullException(nameof(regionToAdd));
            }

            await _context.AddAsync(regionToAdd);
        }
コード例 #6
0
        public async void AddCustomer(Customers customerToAdd)
        {
            if (customerToAdd == null)
            {
                throw new ArgumentException(nameof(customerToAdd));
            }

            await _context.AddAsync(customerToAdd);
        }
コード例 #7
0
        public async void AddOrder(Orders orderToAdd)
        {
            if (orderToAdd == null)
            {
                throw new ArgumentNullException(nameof(orderToAdd));
            }

            await _context.AddAsync(orderToAdd);
        }
コード例 #8
0
        //C.R.U.D
        //Read

        public async Task CreateProduct(Product product)
        {
            //What happens if the product exists ?
            var foundProduct = _northwindContext.Products.Any(x => x.ProductId == product.ProductId);

            if (!foundProduct)
            {
                await _northwindContext.AddAsync(product);

                await _northwindContext.SaveChangesAsync();
            }
        }
コード例 #9
0
        public async Task Create(T entity)
        {
            await _dbContext.AddAsync(entity);

            await SaveAsync();
        }