Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,name")] Country country)
        {
            if (ModelState.IsValid)
            {
                _context.Add(country);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(
            [Bind("Id,email,createdAt,updatedAt")] Client client
            )
        {
            if (ModelState.IsValid)
            {
                _context.Add(client);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(client));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create(
            [Bind(@"Id,sku,name,description,price,msrp,inventory,image,hot,createdAt,
              updatedAt")]
            Product product
            )
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create(
            [Bind(@"Id,paymentMethod,total,ApiOrderId,status,clientForeignKey,
              productForeignKey")]
            Order order
            )
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["clientForeignKey"] = new SelectList(
                _context.Client, "Id", "email", order.clientForeignKey
                );
            ViewData["productForeignKey"] = new SelectList(
                _context.Product, "Id", "description", order.productForeignKey
                );

            return(View(order));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create(
            [Bind(@"Id,type,firstName,lastName,email,line1,line2,city,zipCode,phone,
              createdAt,updatedAt,countryForeignKey,clientForeignKey")]
            Address address
            )
        {
            if (ModelState.IsValid)
            {
                _context.Add(address);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["clientForeignKey"] = new SelectList(
                _context.Client, "Id", "email", address.clientForeignKey
                );
            ViewData["countryForeignKey"] = new SelectList(
                _context.Country, "Id", "name", address.countryForeignKey
                );

            return(View(address));
        }