Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("AutoId,FirstName,LastName,EmailId")] TableMvc1 tableMvc1)
        {
            if (id != tableMvc1.AutoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tableMvc1);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TableMvc1Exists(tableMvc1.AutoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AutoId"] = new SelectList(_context.Set <TableMvc2>(), "AutoId", "AutoId", tableMvc1.AutoId);
            return(View(tableMvc1));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("AutoId,FirstName,LastName,EmailId")] TableMvc1 tableMvc1)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tableMvc1);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AutoId"] = new SelectList(_context.Set <TableMvc2>(), "AutoId", "AutoId", tableMvc1.AutoId);
            return(View(tableMvc1));
        }