public ActionResult Edit([Bind(Include = "Id,Nome,BlocosId")] CursoViewModel cursoViewModel) { if (ModelState.IsValid) { var curso = new Curso(); curso.Id = cursoViewModel.Id; curso.Nome = cursoViewModel.Nome; if (cursoViewModel.BlocosId.Count > 0) { curso.Blocos = new List <Bloco>(); foreach (int blocoId in cursoViewModel.BlocosId) { var bloco = db.Blocos.Find(blocoId); if (bloco != null) { curso.Blocos.Add(bloco); } } } db.Entry(curso).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } var blocos = db.Blocos.ToList(); ViewBag.ListaBlocos = new MultiSelectList(blocos, "Id", "Nome", null); return(View(cursoViewModel)); }
public ActionResult Edit([Bind(Include = "Id,Nome,Email")] Professor professor) { if (ModelState.IsValid) { db.Entry(professor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(professor)); }
public ActionResult Edit([Bind(Include = "Id,Nome")] Modulo modulo) { if (ModelState.IsValid) { db.Entry(modulo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(modulo)); }
public ActionResult Edit([Bind(Include = "Id,Codigo")] Turma turma) { if (ModelState.IsValid) { db.Entry(turma).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(turma)); }
public ActionResult Edit([Bind(Include = "Id,Descricao")] TopicoAvaliacao topicoavaliacao) { if (ModelState.IsValid) { db.Entry(topicoavaliacao).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(topicoavaliacao)); }
public ActionResult Edit(Bloco bloco) { if (ModelState.IsValid) { db.Entry(bloco).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bloco)); }
public ActionResult Edit([Bind(Include = "Id,Texto,TopicoAvaliacaoId")] Questao questao) { if (ModelState.IsValid) { db.Entry(questao).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TopicoAvaliacaoId = new SelectList(db.Topicos, "Id", "Descricao", questao.TopicoAvaliacaoId); return(View(questao)); }
public ActionResult Edit([Bind(Include = "Id,QuestaoId,OpcaoEscolhida,AlunoId,AvaliacaoId")] Resposta resposta) { if (ModelState.IsValid) { db.Entry(resposta).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AlunoId = new SelectList(db.Users, "Id", "Name", resposta.AlunoId); ViewBag.AvaliacaoId = new SelectList(db.Avaliacoes, "Id", "Objetivo", resposta.AvaliacaoId); ViewBag.QuestaoId = new SelectList(db.Questoes, "Id", "Texto", resposta.QuestaoId); return(View(resposta)); }
public ActionResult Edit(AvaliacaoViewModel avaliacaoViewModel) { if (ModelState.IsValid) { var avaliacao = new Avaliacao(); avaliacao.Id = avaliacaoViewModel.Id; avaliacao.Objetivo = avaliacaoViewModel.Objetivo; avaliacao.DataInicio = avaliacaoViewModel.DataInicio; avaliacao.DataFim = avaliacaoViewModel.DataFim; foreach (var moduloID in avaliacaoViewModel.ModulosID) { var modulo = db.Modulos.Find(moduloID); if (modulo != null) { //if (avaliacao.Modulos == null) //{ // avaliacao.Modulos = new List<Modulo> { modulo }; //} //else //{ // avaliacao.Modulos.Add(modulo); //} } } foreach (var questaoID in avaliacaoViewModel.QuestoesID) { var questao = db.Questoes.Find(questaoID); if (questao != null) { if (avaliacao.Questoes == null) { avaliacao.Questoes = new List <Questao> { questao }; } else { avaliacao.Questoes.Add(questao); } } } db.Entry(avaliacao).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(avaliacaoViewModel)); }
public void GravarRespostas(IEnumerable<Resposta> respostas) { using (var db = new AvaliacoesDbContext()) { var enumerable = respostas as IList<Resposta> ?? respostas.ToList(); for (var index = 0; index < enumerable.Count; index++) { var resposta = enumerable[index]; var jaResposdido = db.Respostas.FirstOrDefault( resp => resp.AlunoId == resposta.AlunoId && resp.QuestaoId == resposta.QuestaoId && resposta.AvaliacaoId == resp.AvaliacaoId); if (jaResposdido == null) { db.Respostas.Add(resposta); } else { jaResposdido.OpcaoEscolhida = resposta.OpcaoEscolhida; db.Entry(jaResposdido).State = EntityState.Modified; } } db.SaveChanges(); } }