/*
         * Create new product
         */
        public async Task <GetProductViewModel> CreateProduct(Product product)
        {
            _context.Products.Add(product);
            await _context.SaveChangesAsync();

            return(GetProductViewModel(product));
        }
Beispiel #2
0
        /*
         * Create a new customer
         */
        public async Task <GetCustomerViewModel> CreateCustomer(Customer customer)
        {
            _context.Customers.Add(customer);
            var basket = new Basket {
                Customer = customer
            };

            _context.Baskets.Add(basket);
            await _context.SaveChangesAsync();

            return(await GetCustomerViewModel(customer));
        }