Пример #1
0
        // GET: Estudante/Details/5
        public ActionResult Details(int id)
        {
            EstudanteServiceRemoto.EstudanteServiceClient cliente      = new EstudanteServiceRemoto.EstudanteServiceClient();
            InscricaoServiceRemoto.InscricaoServiceClient inscricoesWS = new InscricaoServiceRemoto.InscricaoServiceClient();
            CursoServiceRemoto.CursoServiceClient         cursoWS      = new CursoServiceRemoto.CursoServiceClient();

            Estudante estudante = Mapper.Map <EstudanteServiceRemoto.EstudanteDTO, Estudante>(cliente.FindEstudante(id));

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

            List <InscricaoServiceRemoto.InscricaoDTO> inscricoes = inscricoesWS.GetAllByEstudante(id);

            estudante.Inscricoes = Mapper.Map <List <Inscricao> >(inscricoes);

            foreach (Inscricao i in estudante.Inscricoes)
            {
                i.Curso = Mapper.Map <CursoServiceRemoto.CursoDTO, Curso>(cursoWS.Find(i.CursoId));
            }



            return(View("Details", estudante));
        }
Пример #2
0
        // GET: Inscricao
        public ActionResult CadastrarEstudante()
        {
            EstudanteServiceRemoto.EstudanteServiceClient clienteWSEstudante = new EstudanteServiceRemoto.EstudanteServiceClient();
            CursoServiceRemoto.CursoServiceClient clienteWSCurso = new CursoServiceRemoto.CursoServiceClient();

            var estudantes = clienteWSEstudante.GetAllEstudantes();
            var cursos = clienteWSCurso.GetAll();

            List<SelectListItem> selectEstudantes = estudantes.Select(e => new SelectListItem()
            {
                Text = string.Format("{0} {1} - Cod. {2}", e.Nome, e.SobreNome, e.Id),
                Value = e.Id.ToString()

            }).ToList();

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

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

            return View();
        }
Пример #3
0
        // GET: Estudante
        public ActionResult Index()
        {
            EstudanteServiceRemoto.EstudanteServiceClient cliente       = new EstudanteServiceRemoto.EstudanteServiceClient();
            List <EstudanteServiceRemoto.EstudanteDTO>    estudantesDTO = cliente.GetAllEstudantes();

            return(View(Mapper.Map <List <Estudante> >(estudantesDTO)));
        }
Пример #4
0
        // GET: Inscricao
        public ActionResult CadastrarEstudante()
        {
            EstudanteServiceRemoto.EstudanteServiceClient clienteWSEstudante = new EstudanteServiceRemoto.EstudanteServiceClient();
            CursoServiceRemoto.CursoServiceClient         clienteWSCurso     = new CursoServiceRemoto.CursoServiceClient();

            var estudantes = clienteWSEstudante.GetAllEstudantes();
            var cursos     = clienteWSCurso.GetAll();

            List <SelectListItem> selectEstudantes = estudantes.Select(e => new SelectListItem()
            {
                Text  = string.Format("{0} {1} - Cod. {2}", e.Nome, e.SobreNome, e.Id),
                Value = e.Id.ToString()
            }).ToList();

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

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

            return(View());
        }
Пример #5
0
        public ActionResult Delete(Estudante estudante)
        {
            EstudanteServiceRemoto.EstudanteServiceClient cliente = new EstudanteServiceRemoto.EstudanteServiceClient();
            estudante = Mapper.Map<EstudanteServiceRemoto.EstudanteDTO, Estudante>(cliente.FindEstudante(estudante.Id));
            cliente.DeleteEstudante(Mapper.Map<Estudante, EstudanteServiceRemoto.EstudanteDTO>(estudante));
            TempData["Mensagem"] = "Estudante excluído com sucesso!";

            return RedirectToAction("Index");
        }
Пример #6
0
        public ActionResult Delete(Estudante estudante)
        {
            EstudanteServiceRemoto.EstudanteServiceClient cliente = new EstudanteServiceRemoto.EstudanteServiceClient();
            estudante = Mapper.Map <EstudanteServiceRemoto.EstudanteDTO, Estudante>(cliente.FindEstudante(estudante.Id));
            cliente.DeleteEstudante(Mapper.Map <Estudante, EstudanteServiceRemoto.EstudanteDTO>(estudante));
            TempData["Mensagem"] = "Estudante excluído com sucesso!";

            return(RedirectToAction("Index"));
        }
Пример #7
0
        // GET: Estudante/Delete/5
        public ActionResult Delete(int id)
        {
            EstudanteServiceRemoto.EstudanteServiceClient cliente = new EstudanteServiceRemoto.EstudanteServiceClient();

            Estudante estudante = Mapper.Map<EstudanteServiceRemoto.EstudanteDTO, Estudante>(cliente.FindEstudante(id));

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

            return View("Delete", estudante);
        }
Пример #8
0
        // GET: Estudante/Edit/5
        public ActionResult Edit(int id)
        {
            EstudanteServiceRemoto.EstudanteServiceClient cliente = new EstudanteServiceRemoto.EstudanteServiceClient();

            Estudante estudante = Mapper.Map <EstudanteServiceRemoto.EstudanteDTO, Estudante>(cliente.FindEstudante(id));

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

            return(View(estudante));
        }
Пример #9
0
        public ActionResult Create(Estudante estudante)
        {
            if (ModelState.IsValid)
            {
                EstudanteServiceRemoto.EstudanteServiceClient cliente = new EstudanteServiceRemoto.EstudanteServiceClient();
                estudante.DataMatricula = DateTime.Now;
                cliente.AddEstudante(Mapper.Map<Estudante, EstudanteServiceRemoto.EstudanteDTO>(estudante));

                TempData["Mensagem"] = "Estudante cadastrado com sucesso!";
                TempData["Sucesso"] = true;

                return RedirectToAction("Index");
            }

            return View("Create", estudante);
        }
Пример #10
0
        public ActionResult Edit(Estudante estudante)
        {
            if (ModelState.IsValid)
            {
                EstudanteServiceRemoto.EstudanteServiceClient cliente = new EstudanteServiceRemoto.EstudanteServiceClient();

                cliente.UpdateEstudante(Mapper.Map <Estudante, EstudanteServiceRemoto.EstudanteDTO>(estudante));

                TempData["Mensagem"] = "Estudante atualizado com sucesso!";
                TempData["Sucesso"]  = true;

                return(RedirectToAction("Index"));
            }

            return(View("Edit", estudante));
        }
Пример #11
0
        public ActionResult Create(Estudante estudante)
        {
            if (ModelState.IsValid)
            {
                EstudanteServiceRemoto.EstudanteServiceClient cliente = new EstudanteServiceRemoto.EstudanteServiceClient();
                estudante.DataMatricula = DateTime.Now;
                cliente.AddEstudante(Mapper.Map <Estudante, EstudanteServiceRemoto.EstudanteDTO>(estudante));

                TempData["Mensagem"] = "Estudante cadastrado com sucesso!";
                TempData["Sucesso"]  = true;

                return(RedirectToAction("Index"));
            }

            return(View("Create", estudante));
        }
Пример #12
0
        // GET: Estudante/Details/5
        public ActionResult Details(int id)
        {
            EstudanteServiceRemoto.EstudanteServiceClient cliente = new EstudanteServiceRemoto.EstudanteServiceClient();
            InscricaoServiceRemoto.InscricaoServiceClient inscricoesWS = new InscricaoServiceRemoto.InscricaoServiceClient();
            CursoServiceRemoto.CursoServiceClient cursoWS = new CursoServiceRemoto.CursoServiceClient();

            Estudante estudante = Mapper.Map<EstudanteServiceRemoto.EstudanteDTO, Estudante>(cliente.FindEstudante(id));

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

            List<InscricaoServiceRemoto.InscricaoDTO> inscricoes = inscricoesWS.GetAllByEstudante(id);
            estudante.Inscricoes = Mapper.Map<List<Inscricao>>(inscricoes);

            foreach(Inscricao i in estudante.Inscricoes){
                i.Curso = Mapper.Map<CursoServiceRemoto.CursoDTO, Curso>(cursoWS.Find(i.CursoId));
            }

            return View("Details", estudante);
        }
Пример #13
0
        public ActionResult CadastrarEstudante(Inscricao inscricao)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    InscricaoServiceRemoto.InscricaoServiceClient inscricaoWS = new InscricaoServiceRemoto.InscricaoServiceClient();
                    CursoServiceRemoto.CursoServiceClient cursoWS = new CursoServiceRemoto.CursoServiceClient();
                    EstudanteServiceRemoto.EstudanteServiceClient estudanteWS = new EstudanteServiceRemoto.EstudanteServiceClient();
                    inscricao.Curso = Mapper.Map<CursoServiceRemoto.CursoDTO, Curso>(cursoWS.Find(inscricao.CursoId));
                    inscricao.Estudante = Mapper.Map<EstudanteServiceRemoto.EstudanteDTO, Estudante>(estudanteWS.FindEstudante(inscricao.EstudanteId));

                    InscricaoDTO inscricaoDTO = new InscricaoDTO();
                    //inscricaoDTO.Curso = Mapper.Map<Curso, CursoDTO>(inscricao.Curso);
                    //inscricaoDTO.Estudante = Mapper.Map<Estudante, EstudanteDTO>(inscricao.Estudante);
                    //inscricaoDTO.Id = inscricao.Id;
                    inscricaoDTO.EstudanteId = inscricao.EstudanteId;
                    inscricaoDTO.CursoId = inscricao.CursoId;
                    inscricaoDTO.DataInscricao = DateTime.Now;

                    bool retorno = inscricaoWS.Add(inscricaoDTO);

                    TempData["Mensagem"] = "Inscrição realizada com sucesso";
                    TempData["Sucesso"] = retorno;

                    return RedirectToAction("CadastrarEstudante");
                }
                catch (Exception e)
                {
                    TempData["Mensagem"] = e.Message;
                    return RedirectToAction("CadastrarEstudante");
                }
            }

            return View(inscricao);
        }
Пример #14
0
        public ActionResult CadastrarEstudante(Inscricao inscricao)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    InscricaoServiceRemoto.InscricaoServiceClient inscricaoWS = new InscricaoServiceRemoto.InscricaoServiceClient();
                    CursoServiceRemoto.CursoServiceClient         cursoWS     = new CursoServiceRemoto.CursoServiceClient();
                    EstudanteServiceRemoto.EstudanteServiceClient estudanteWS = new EstudanteServiceRemoto.EstudanteServiceClient();
                    inscricao.Curso     = Mapper.Map <CursoServiceRemoto.CursoDTO, Curso>(cursoWS.Find(inscricao.CursoId));
                    inscricao.Estudante = Mapper.Map <EstudanteServiceRemoto.EstudanteDTO, Estudante>(estudanteWS.FindEstudante(inscricao.EstudanteId));

                    InscricaoDTO inscricaoDTO = new InscricaoDTO();
                    //inscricaoDTO.Curso = Mapper.Map<Curso, CursoDTO>(inscricao.Curso);
                    //inscricaoDTO.Estudante = Mapper.Map<Estudante, EstudanteDTO>(inscricao.Estudante);
                    //inscricaoDTO.Id = inscricao.Id;
                    inscricaoDTO.EstudanteId   = inscricao.EstudanteId;
                    inscricaoDTO.CursoId       = inscricao.CursoId;
                    inscricaoDTO.DataInscricao = DateTime.Now;

                    bool retorno = inscricaoWS.Add(inscricaoDTO);

                    TempData["Mensagem"] = "Inscrição realizada com sucesso";
                    TempData["Sucesso"]  = retorno;

                    return(RedirectToAction("CadastrarEstudante"));
                }
                catch (Exception e)
                {
                    TempData["Mensagem"] = e.Message;
                    return(RedirectToAction("CadastrarEstudante"));
                }
            }

            return(View(inscricao));
        }
Пример #15
0
 // GET: Estudante
 public ActionResult Index()
 {
     EstudanteServiceRemoto.EstudanteServiceClient cliente = new EstudanteServiceRemoto.EstudanteServiceClient();
     List<EstudanteServiceRemoto.EstudanteDTO> estudantesDTO = cliente.GetAllEstudantes();
     return View(Mapper.Map<List<Estudante>>(estudantesDTO));
 }
Пример #16
0
        public ActionResult Edit(Estudante estudante)
        {
            if (ModelState.IsValid)
            {
                EstudanteServiceRemoto.EstudanteServiceClient cliente = new EstudanteServiceRemoto.EstudanteServiceClient();

                cliente.UpdateEstudante(Mapper.Map<Estudante, EstudanteServiceRemoto.EstudanteDTO>(estudante));

                TempData["Mensagem"] = "Estudante atualizado com sucesso!";
                TempData["Sucesso"] = true;

                return RedirectToAction("Index");
            }

            return View("Edit", estudante);
        }