コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("VisitasGuiadasId,GuiaId,Nome,DatadaVisita,Descricao,NMaxPessoas,Completo")] VisitasGuiadas visitasGuiadas)
        {
            if (id != visitasGuiadas.VisitasGuiadasId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(visitasGuiadas);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VisitasGuiadasExists(visitasGuiadas.VisitasGuiadasId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GuiaId"] = new SelectList(_context.Guia, "GuiaId", "Nome", visitasGuiadas.GuiaId);
            return(View(visitasGuiadas));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("VisitasGuiadasId,GuiaId,Nome,DatadaVisita,Descricao,NMaxPessoas,Completo")] VisitasGuiadas visitasGuiadas)
        {
            if (ModelState.IsValid)
            {
                _context.Add(visitasGuiadas);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GuiaId"] = new SelectList(_context.Guia, "GuiaId", "Nome", visitasGuiadas.GuiaId);
            return(View(visitasGuiadas));
        }