public void Create(Professor professor)
 {
     using (var db = new AppDBContext())
     {
         db.Professores.Add(professor);
         db.SaveChanges();
     }
 }
 public void Edit(Professor professor)
 {
     using (var db = new AppDBContext())
     {
         db.Entry(professor).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Пример #3
0
        public ActionResult Delete(Professor professor)
        {
            ProfessorServiceRemote.ProfessorServiceClient cliente = new ProfessorServiceRemote.ProfessorServiceClient();
            professor = Mapper.Map<ProfessorDTO, Professor>(cliente.Find(professor.Id));
            bool retorno = cliente.Delete(Mapper.Map<Professor, ProfessorDTO>(professor));
            TempData["Mensagem"] = "Professor excluído com sucesso";

            return RedirectToAction("Index");
        }
Пример #4
0
 public ActionResult Delete(int id, Professor professor)
 {
     try
     {
         client.Delete(professor.Id);
         return RedirectToAction("Index");
     }
     catch(Exception e)
     {
         ViewBag.Message = e.Message;
         return View(professor);
     }
 }
Пример #5
0
        public ActionResult Create(Professor professor)
        {
            if (ModelState.IsValid)
            {
                ProfessorServiceRemote.ProfessorServiceClient cliente = new ProfessorServiceRemote.ProfessorServiceClient();
                bool retorno = cliente.Add(Mapper.Map<Professor, ProfessorDTO>(professor));

                TempData["Mensagem"] = "Professor cadastrado com sucesso";

                return RedirectToAction("Index");
            }

            return View("Create", professor);
        }