Ejemplo n.º 1
0
        private void PopularProfessoresAssociados(ICollection <Professor> professoresCurso = null)
        {
            professoresCurso = professoresCurso ?? new List <Professor>();

            List <Professor> professores;

            using (var client = new ProfessorService.ProfessorServiceClient())
            {
                professores = client.GetAll().MapTo <List <Professor> >();
            }

            var model = new List <SelectListItem>();

            foreach (var p in professores)
            {
                model.Add(new SelectListItem
                {
                    Text     = string.Format("{0} {1}", p.Nome, p.Sobrenome),
                    Value    = p.Id.ToString(),
                    Selected = professoresCurso.Any(pc => pc.Id == p.Id)
                });
            }

            ViewBag.Professores = model;
        }
        public ActionResult DeleteConfirmed(int id)
        {
            using (var client = new ProfessorService.ProfessorServiceClient())
            {
                client.Delete(id);
            }

            return RedirectToAction("Index");
        }
Ejemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            using (var client = new ProfessorService.ProfessorServiceClient())
            {
                client.Delete(id);
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        // GET: Professor
        public ActionResult Index()
        {
            List <Professor> professores;

            using (var client = new ProfessorService.ProfessorServiceClient())
            {
                professores = client.GetAll().MapTo <List <Professor> >();
            }

            return(View(professores));
        }
Ejemplo n.º 5
0
        public ActionResult Edit([Bind(Include = "Id,Nome,Sobrenome,Titulacao")] Professor professor)
        {
            if (ModelState.IsValid)
            {
                using (var client = new ProfessorService.ProfessorServiceClient())
                {
                    client.Edit(professor.MapTo <ProfessorService.Professor>());
                }

                return(RedirectToAction("Index"));
            }
            return(View(professor));
        }
        public ActionResult Create([Bind(Include = "Id,Nome,Sobrenome,Titulacao")] Professor professor)
        {
            if (ModelState.IsValid)
            {
                using (var client = new ProfessorService.ProfessorServiceClient())
                {
                    client.Create(professor.MapTo<ProfessorService.Professor>());
                }

                return RedirectToAction("Index");
            }

            return View(professor);
        }
        // GET: Professor/Details/5
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            Professor professor;
            using (var client = new ProfessorService.ProfessorServiceClient())
            {
                professor = client.GetByIdWithCursos(id.Value).MapTo<Professor>();
            }

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

            return View(professor);
        }
Ejemplo n.º 8
0
        // GET: Professor/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Professor professor;

            using (var client = new ProfessorService.ProfessorServiceClient())
            {
                professor = client.GetById(id.Value).MapTo <Professor>();
            }

            if (professor == null)
            {
                return(HttpNotFound());
            }
            return(View(professor));
        }
        // GET: Professor
        public ActionResult Index()
        {
            List<Professor> professores;
            using (var client = new ProfessorService.ProfessorServiceClient())
            {
                professores = client.GetAll().MapTo<List<Professor>>();
            }

            return View(professores);
        }
Ejemplo n.º 10
0
        private void PopularProfessoresAssociados(ICollection<Professor> professoresCurso = null)
        {
            professoresCurso = professoresCurso ?? new List<Professor>();

            List<Professor> professores;
            using (var client = new ProfessorService.ProfessorServiceClient())
            {
                professores = client.GetAll().MapTo<List<Professor>>();
            }

            var model = new List<SelectListItem>();
            foreach (var p in professores)
            {
                model.Add(new SelectListItem
                {
                    Text = string.Format("{0} {1}", p.Nome, p.Sobrenome),
                    Value = p.Id.ToString(),
                    Selected = professoresCurso.Any(pc => pc.Id == p.Id)
                });
            }

            ViewBag.Professores = model;
        }