public async Task <IActionResult> Create([Bind("JogoID,Titulo,Quantidade,Foto")] Jogo jogo, List <IFormFile> files)
        {
            if (ModelState.IsValid)
            {
                _context.Add(jogo);
                await _context.SaveChangesAsync();

                jogo.Foto = await RealizarUploadImagens(files, jogo.JogoID);

                _context.Update(jogo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(jogo));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("AmigoID,Nome,Telefone,Email")] Amigo amigo)
        {
            if (id != amigo.AmigoID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(amigo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AmigoExists(amigo.AmigoID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(amigo));
        }
        public async Task <IActionResult> Devolver([Bind("EmprestimoID,DataDevolucao")] Emprestimo emprestimo)
        {
            var emprestimo_tmp = await _context.Emprestimo
                                 .SingleOrDefaultAsync(m => m.EmprestimoID == emprestimo.EmprestimoID);

            emprestimo_tmp.DataDevolucao = emprestimo.DataDevolucao;

            _context.Update(emprestimo_tmp);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Home"));
        }