public ActionResult CadastrarEstudante()
        {
            List<Estudante> estudantes;
            using (var client = new EstudanteService.EstudanteServiceClient())
            {
                estudantes = client.GetAll().MapTo<List<Estudante>>();
            }

            List<Curso> cursos;
            using (var client = new CursoService.CursoServiceClient())
            {
                cursos = client.GetAll().MapTo<List<Curso>>();
            }

            var selectEstudantes = estudantes.Select(e => new SelectListItem()
            {
                Text = string.Format("{0} {1}", e.Nome, e.Sobrenome),
                Value = e.Id.ToString()
            }).ToList();

            var selectCursos = cursos.Select(c => new SelectListItem()
            {
                Text = c.Nome,
                Value = c.Id.ToString()
            }).ToList();

            ViewBag.CursoId = selectCursos;
            ViewBag.EstudanteId = selectEstudantes;

            return View();
        }
Exemple #2
0
        public ActionResult CadastrarEstudante()
        {
            List <Estudante> estudantes;

            using (var client = new EstudanteService.EstudanteServiceClient())
            {
                estudantes = client.GetAll().MapTo <List <Estudante> >();
            }

            List <Curso> cursos;

            using (var client = new CursoService.CursoServiceClient())
            {
                cursos = client.GetAll().MapTo <List <Curso> >();
            }

            var selectEstudantes = estudantes.Select(e => new SelectListItem()
            {
                Text  = string.Format("{0} {1}", e.Nome, e.Sobrenome),
                Value = e.Id.ToString()
            }).ToList();

            var selectCursos = cursos.Select(c => new SelectListItem()
            {
                Text  = c.Nome,
                Value = c.Id.ToString()
            }).ToList();

            ViewBag.CursoId     = selectCursos;
            ViewBag.EstudanteId = selectEstudantes;

            return(View());
        }
        public ActionResult Delete(int id)
        {
            using (var client = new EstudanteService.EstudanteServiceClient())
            {
                client.Delete(id);
            }

            return RedirectToAction("Index");
        }
        public ActionResult Delete(int id)
        {
            using (var client = new EstudanteService.EstudanteServiceClient())
            {
                client.Delete(id);
            }

            return(RedirectToAction("Index"));
        }
        // GET: Estudante
        public ActionResult Index()
        {
            List <Estudante> estudantes;

            using (var client = new EstudanteService.EstudanteServiceClient())
            {
                estudantes = client.GetAll().MapTo <List <Estudante> >();
            }

            return(View(estudantes));
        }
        public ActionResult Create(Estudante estudante)
        {
            if (ModelState.IsValid)
            {
                using (var client = new EstudanteService.EstudanteServiceClient())
                {
                    client.Create(estudante.MapTo<EstudanteService.Estudante>());
                }

                return RedirectToAction("Index");
            }

            return View(estudante);
        }
        public ActionResult Edit(Estudante estudante)
        {
            if (ModelState.IsValid)
            {
                using (var client = new EstudanteService.EstudanteServiceClient())
                {
                    client.Edit(estudante.MapTo <EstudanteService.Estudante>());
                }

                return(RedirectToAction("Index"));
            }

            return(View(estudante));
        }
        public ActionResult Details(int? id)
        {
            if (!id.HasValue)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            Estudante estudante;
            using (var client = new EstudanteService.EstudanteServiceClient())
            {
                estudante = client.GetByIdWithInscricoes(id.Value).MapTo<Estudante>();
            }

            if (estudante == null)
            {
                return HttpNotFound();
            }

            return View(estudante);
        }
        public ActionResult Details(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Estudante estudante;

            using (var client = new EstudanteService.EstudanteServiceClient())
            {
                estudante = client.GetByIdWithInscricoes(id.Value).MapTo <Estudante>();
            }

            if (estudante == null)
            {
                return(HttpNotFound());
            }

            return(View(estudante));
        }
        // GET: Estudante
        public ActionResult Index()
        {
            List<Estudante> estudantes;
            using (var client = new EstudanteService.EstudanteServiceClient())
            {
                estudantes = client.GetAll().MapTo<List<Estudante>>();
            }

            return View(estudantes);
        }