public async Task <IActionResult> Create([Bind("Id,ReceberNumero,Resposta")] Exec1 exec1) { ModelState.Clear(); int x = exec1.ReceberNumero; if (x % 2 == 0) { ViewBag._comValor = "Funcionando"; exec1.Resposta = "Seu número é *** PAR ***"; } else { ViewBag._comValor = "Funcionando"; exec1.Resposta = "Seu número é *** IMPAR ***"; } if (ModelState.IsValid) { _context.Add(exec1); await _context.SaveChangesAsync(); //Comunicação com a Modal TempData["mssgC"] = "Sucesso!"; return(RedirectToAction(nameof(Index))); } return(View(exec1)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ReceberNumero,Resposta")] Exec1 exec1) { if (id != exec1.Id) { return(NotFound()); } ModelState.Clear(); int x = exec1.ReceberNumero; if (x % 2 == 0) { exec1.Resposta = "Seu número é *** PAR ***"; } else { exec1.Resposta = "Seu número é *** IMPAR ***"; } if (ModelState.IsValid) { try { _context.Update(exec1); //Comunicação com a Modal TempData["mssgE"] = "Editado!"; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exec1Exists(exec1.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(exec1)); }