示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Noticiasid,Imagensid")] NI nI)
        {
            if (id != nI.Imagensid)
            {
                return(RedirectToAction("Index"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(nI);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NIExists(nI.Imagensid))
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Imagensid"]  = new SelectList(_context.Imagens, "Id", "Id", nI.Imagensid);
            ViewData["Noticiasid"] = new SelectList(_context.Noticias, "Id", "Corpo", nI.Noticiasid);
            return(View(nI));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Legenda")] Imagens imagens)
        {
            if (id != imagens.Id)
            {
                return(RedirectToAction("Index"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(imagens);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ImagensExists(imagens.Id))
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(imagens));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Email")] Utilizadores utilizadores)
        {
            if (id != utilizadores.Id)
            {
                return(RedirectToAction("Index"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(utilizadores);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UtilizadoresExists(utilizadores.Id))
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(utilizadores));
        }
示例#4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Titulo,Resumo,Corpo,Data_De_Publicacao,Visivel,UtilizadoresidFK")] Noticias noticias)
        {
            if (id != noticias.Id)
            {
                return(RedirectToAction("Index"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(noticias);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NoticiasExists(noticias.Id))
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UtilizadoresidFK"] = new SelectList(_context.Utilizadores, "Id", "Id", noticias.UtilizadoresidFK);
            return(View(noticias));
        }
示例#5
0
        public async Task <IActionResult> Edit(int id, [Bind("Noticiasid,Topicosid")] NT nT)
        {
            if (id != nT.Topicosid)
            {
                return(RedirectToAction("Index"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    db.Update(nT);
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NTExists(nT.Topicosid))
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Noticiasid"] = new SelectList(db.Noticias, "Id", "Id", nT.Noticiasid);
            ViewData["Topicosid"]  = new SelectList(db.Topicos, "Id", "Id", nT.Topicosid);
            return(View(nT));
        }