public async Task <IActionResult> Create([Bind("Id,CategoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Firstname,Lastname,Addressline1,Addressline2,City,Postcode,Country,Company,Creditcardexpiry,Creditcardnumber,Creditcardtype,Emailaddress,Loginpassword")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Code,Name,Price,Description,CategoryId")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "Id", "CategoryName", product.CategoryId);
            return(View(product));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Amount,Orderdate,ConfirmationNumber,CustomerId")] CustomerOrder customerOrder)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customerOrder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "Addressline1", customerOrder.CustomerId);
            return(View(customerOrder));
        }
 public async Task<IActionResult> Create([Bind("CustomerOrderId,ProductCode,Quantity")] OrderedProduct orderedProduct)
 {
     if (ModelState.IsValid)
     {
         _context.Add(orderedProduct);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     ViewData["CustomerOrderId"] = new SelectList(_context.CustomerOrder, "Id", "Id", orderedProduct.CustomerOrderId);
     ViewData["ProductCode"] = new SelectList(_context.Product, "Code", "Name", orderedProduct.ProductCode);
     return View(orderedProduct);
 }