Example #1
0
        public Order CreateOrder(Order order)
        {
            if (order == null)
            {
                throw new ArgumentNullException(nameof(order));
            }

            if (order.Id != default(long))
            {
                throw new ArgumentOutOfRangeException(nameof(order.Id));
            }

            _context.Orders.Add(order);
            _context.SaveChanges();

            return(order);
        }
Example #2
0
        public Supplier CreateSupplier(Supplier supplier)
        {
            if (supplier == null)
            {
                throw new ArgumentNullException(nameof(supplier));
            }

            if (supplier.Id != default(long))
            {
                throw new ArgumentOutOfRangeException(nameof(supplier.Id));
            }

            _context.Suppliers.Add(supplier);
            _context.SaveChanges();

            return(supplier);
        }
Example #3
0
        public Product CreateProduct(Product product)
        {
            if (product == null)
            {
                throw new ArgumentNullException(nameof(product));
            }

            if (product.Id != default(long))
            {
                throw new ArgumentOutOfRangeException(nameof(product.Id));
            }

            _context.Products.Add(product);
            _context.SaveChanges();

            return(product);
        }
Example #4
0
        public Customer CreateCustomer(Customer customer)
        {
            if (customer == null)
            {
                throw new ArgumentNullException(nameof(customer));
            }

            if (customer.Id != default(long))
            {
                throw new ArgumentOutOfRangeException(nameof(customer.Id));
            }

            _context.Customers.Add(customer);
            _context.SaveChanges();

            return(customer);
        }