public async Task <IActionResult> Create([Bind("CustomerId,CustomerName,CustomerLastName,CustomerPhone,CustomerEmail,CustomerStatus,CustomerCreated")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("ProductId,ProductName,Description,Stock,ProductCreated,ProductStatus")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("CustomerOrderId,ProductId,CustomerId,OrderCreated,OrderStatus")] CustomerOrder customerOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customerOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerEmail", customerOrder.CustomerId);
            ViewData["ProductId"]  = new SelectList(_context.Products, "ProductId", "Description", customerOrder.ProductId);
            return(RedirectToAction("Index", "Customers"));
        }
 public void Add(T entity)
 {
     _db.Add(entity);
 }