public void Edit(Estudante estudante)
 {
     using (var db = new AppDBContext())
     {
         db.Entry(estudante).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
 public void Create(Estudante estudante)
 {
     using (var db = new AppDBContext())
     {
         db.Estudantes.Add(estudante);
         db.SaveChanges();
     }
 }
Ejemplo n.º 3
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");
        }
        public ActionResult Create(Estudante estudante)
        {
            if (ModelState.IsValid)
            {
                db.Estudantes.Add(estudante);
                db.SaveChanges();

                return RedirectToAction("index");
            }
            return View(estudante);
        }
Ejemplo n.º 5
0
 public ActionResult Create(Estudante estudante)
 {
     if(ModelState.IsValid)
     {
         client.Save(estudante);
         return RedirectToAction("Index");
     }
     else
     {
         return View(estudante);
     }
 }
Ejemplo n.º 6
0
        public ActionResult Delete(int id, Estudante estudante)
        {
            try
            {
                client.Delete(id);

                return RedirectToAction("Index");
            }
            catch
            {
                return View(estudante);
            }
        }
        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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
        public ActionResult Edit(Estudante estudante)
        {
            if (ModelState.IsValid)
            {
                // db.Entry(estudante).State = System.Data.Entity.EntityState.Modified;
                // db.SaveChanges();

                return RedirectToAction("Index");
            }

            return View(estudante);
        }