public async Task <IActionResult> EditarExercicio([Bind("IdPlano,IdExercicio,NumRepeticoes,PeriodoDescanso,QuantidadeSeries")] Contem contem) { if (ModelState.IsValid) { try { _context.Update(contem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContemExists(contem.IdPlano)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(VerExerciciosSocio), new { contem.IdPlano })); } return(View(contem)); }
public IActionResult AdicionarExercicioSocio(IFormCollection data) { if (ModelState.IsValid) { PlanoTreino plano = _context.PlanosTreino.Include(x => x.Contem).Include(p => p.NumSocioNavigation).Include(p => p.NumProfessorNavigation).SingleOrDefault(p => p.IdPlano == Convert.ToInt32(data["PlanoId"])); Exercicio exercicio = _context.Exercicios.SingleOrDefault(e => e.IdExercicio == Convert.ToInt32(data["ExercicioEscolhido"])); Contem c = new Contem() { IdExercicio = Convert.ToInt32(data["ExercicioEscolhido"]), IdPlano = Convert.ToInt32(data["PlanoId"]), NumRepeticoes = Convert.ToInt32(data["NumRepeticoes"]), PeriodoDescanso = Convert.ToInt32(data["PeriodoDescanso"]), QuantidadeSeries = Convert.ToInt32(data["QuantidadeSeries"]) }; plano.Contem.Add(c); _context.PlanosTreino.Update(plano); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } List <Exercicio> Lista = _context.Exercicios.ToList(); ViewBag.Exercicios = Lista.Select(e => new SelectListItem() { Text = e.Nome, Value = e.IdExercicio.ToString() }); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> ApagarExercicio(int id) { Contem contem = _context.Contem.SingleOrDefault(c => c.IdPlano == id); _context.Contem.Remove(contem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(VerExerciciosSocio), new { contem.IdPlano })); }
public IActionResult EditarExercicio(int IdExercicio, int IdPlano) { ViewBag.PlanoId = IdPlano; Contem contem = _context.Contem.SingleOrDefault(x => x.IdPlano == IdPlano && x.IdExercicio == IdExercicio); if (contem == null) { return(NotFound()); } return(View(contem)); }
public async Task <IActionResult> ApagarExercicio(int?id) { if (id == null) { return(NotFound()); } Contem contem = await _context.Contem .Include(c => c.IdExercicioNavigation) .Include(c => c.IdPlanoNavigation) .FirstOrDefaultAsync(m => m.IdPlano == id); if (contem == null) { return(NotFound()); } return(View(contem)); }