예제 #1
0
        // GET: Trabalhoes
        public ActionResult Index()
        {
            TempData["item"]      = null;            //limpa item do trabalho
            TempData["Trabalho"]  = null;            //limpa trabalho aberto
            TempData["Permissao"] = null;            //limpa permissão do trabalho
            var prof = Session["prof"] as Professor; //busca professor logado

            TempData["Prof_Id"] = prof.Prof_Id;      //armazena código do professor logado
            var trabalhos     = new List <Trabalho>();
            var tempTrabalhos = db.Trabalhoes.Where(x => x.Prof_Id.Equals(prof.Prof_Id)).ToList();

            if (tempTrabalhos != null)
            {
                trabalhos.AddRange(tempTrabalhos);
            }
            var Trab_convidado = db.Prof_Convidado.Where(x => x.Prof_Id.Equals(prof.Prof_Id)).ToList();

            if (Trab_convidado != null)
            {
                foreach (var item in Trab_convidado)
                {
                    var trabalho = db.Trabalhoes.Find(item.Trabalho_Id);
                    trabalhos.Add(trabalho);
                }
            }
            foreach (var item2 in trabalhos)
            {
                int alterado = 0;
                if (item2.Status != "Concluído")
                {
                    if (DateTime.Today.Date >= item2.Data_Fim)
                    {
                        item2.Status = "Concluído";
                        alterado     = 1;
                    }
                    else if (DateTime.Today.Date >= item2.Data_Tranca)
                    {
                        item2.Status = "Andamento";
                        alterado     = 1;
                    }
                }
                if (alterado != 0)
                {
                    db.Entry(item2).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            return(View(trabalhos.ToList()));
        }
예제 #2
0
 public ActionResult Edit([Bind(Include = "Objetivo_Id,Descricao,Trabalho_Id")] Objetivo objetivo)
 {
     TempData["item"] = "objetivo";
     if (ModelState.IsValid)
     {
         var prof          = Session["prof"] as Professor;     // Busca os dados do professor que está logado
         var trabalho_temp = TempData["Trabalho"] as Trabalho; // Busca o trabalho que está em aberto
         TempData["Trabalho"] = trabalho_temp;                 // Mantém o trabalho aberto
         objetivo.Prof_Id     = prof.Prof_Id;
         objetivo.Trabalho_Id = trabalho_temp.Trabalho_Id;
         try
         {
             db.Entry(objetivo).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("../Trabalhoes/ViewTrabalho1"));
         }
         catch (Exception)
         {
             ViewData["Message"] = "Não foi possível alterar, tente novamente mais tarde";
             return(View(objetivo));
         }
     }
     ViewData["Message"] = "Não foi possível alterar, tente novamente mais tarde";
     return(View(objetivo));
 }
예제 #3
0
 public ActionResult Edit([Bind(Include = "Avalia_Trabalho_Id,Trabalho_Id,Descricao")] Avaliacao avaliacao)
 {
     TempData["item"] = "avaliacao";//Serve para voltar na mesma posição na pagina do trabalho
     if (ModelState.IsValid)
     {
         var prof          = Session["prof"] as Professor;     // Busca os dados do professor que está logado
         var trabalho_temp = TempData["Trabalho"] as Trabalho; // Busca o trabalho que está em aberto
         TempData["Trabalho"]  = trabalho_temp;                // Mantém o trabalho aberto
         avaliacao.Prof_Id     = prof.Prof_Id;
         avaliacao.Trabalho_Id = trabalho_temp.Trabalho_Id;
         try
         {
             db.Entry(avaliacao).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("../Trabalhoes/ViewTrabalho1"));
         }
         catch (Exception)
         {
             ViewData["Message"] = "Não foi possível alterar, tente novamente mais tarde";
             return(View(avaliacao));
         }
     }
     ViewData["Message"] = "Não foi possível alterar, tente novamente mais tarde";
     return(View(avaliacao));
 }
예제 #4
0
 public ActionResult Edit([Bind(Include = "User_Id,Email,Password")] User user)
 {
     if (ModelState.IsValid)
     {
         user.Paper = Session["Paper"].ToString();
         using (MD5 md5Hash = MD5.Create())
         {
             user.Password = GetMd5Hash(md5Hash, user.Password);
         }
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewData["Message"] = "Não foi possível salvar, tente novamente mais tarde";
     return(View(user));
 }
예제 #5
0
 public ActionResult Edit([Bind(Include = "Experiencia_Id,Prof_Id,Prof_Nome,Descricao,Trabalho_Id")] Avalia_Geral experiencia)
 {
     if (ModelState.IsValid)
     {
         var prof          = Session["prof"] as Professor;     // Busca os dados do professor que está logado
         var trabalho_temp = TempData["Trabalho"] as Trabalho; // Busca o trabalho que está em aberto
         TempData["Trabalho"]    = trabalho_temp;              // Mantém o trabalho aberto
         experiencia.Prof_Id     = prof.Prof_Id;
         experiencia.Trabalho_Id = trabalho_temp.Trabalho_Id;
         experiencia.Prof_Nome   = prof.Nome;
         try
         {
             db.Entry(experiencia).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("../Trabalhoes/ViewTrabalho1"));
         }
         catch (Exception)
         {
             ViewData["Message"] = "Não foi possível alterar, tente novamente mais tarde";
             return(View(experiencia));
         }
     }
     ViewData["Message"] = "Não foi possível alterar, tente novamente mais tarde";
     return(View(experiencia));
 }
예제 #6
0
        public ActionResult Edit([Bind(Include = "Prof_Id,Nome,Email,Password,Curso_Id")] Professor professor)
        {
            Curso curso = db.Cursoes.Where(x => x.Curso_Id == professor.Curso_Id).FirstOrDefault();

            professor.Curso_Nome = curso.Nome;


            var trabalhos = db.Trabalhoes.Where(x => x.Prof_Id == professor.Prof_Id).ToList();

            foreach (var item in trabalhos)
            {
                item.Prof_Curso = curso.Nome;
            }

            var User = Session["User"] as User;

            if (User != null)
            {
                using (MD5 md5Hash = MD5.Create())
                {
                    User.Email           = professor.Email;
                    User.Password        = GetMd5Hash(md5Hash, professor.Password);
                    db.Entry(User).State = EntityState.Modified;
                    db.SaveChanges();
                }
                try
                {
                    db.Entry(professor).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["Message"] = "Alterado com sucesso";
                    return(RedirectToAction("Details"));
                }
                catch (Exception)
                {
                    ViewData["Message"] = "Não foi possível salvar, tente novamente mais tarde";
                    ViewBag.Curso_Id    = new SelectList(db.Cursoes, "Curso_Id", "Nome", professor.Curso_Id);
                    return(View(professor));
                }
            }


            ViewData["Message"] = "Entrada inválida";
            ViewBag.Curso_Id    = new SelectList(db.Cursoes, "Curso_Id", "Nome", professor.Curso_Id);
            return(View(professor));
        }
예제 #7
0
 public ActionResult Edit([Bind(Include = "Curso_Id,Nome")] Curso curso)
 {
     if (ModelState.IsValid)
     {
         try
         {
             db.Entry(curso).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (Exception)
         {
             ViewData["Message"] = "Não foi possível alterar, tente novamente mais tarde";
             return(View(curso));
         }
     }
     ViewData["Message"] = "Não foi possível alterar, tente novamente mais tarde";
     return(View(curso));
 }
        public ActionResult Edit([Bind(Include = "Prof_Conv_Id,Prof_Id,Permissao,Trabalho_Id")] Prof_Convidado prof_Convidado)
        {
            TempData["item"] = "convidado";                //Serve para voltar na mesma posição na pagina ViewTrabalho1
            Professor prof = Session["User"] as Professor; //busca professor logado

            if (ModelState.IsValid)
            {
                var trabalho_temp = TempData["Trabalho"] as Trabalho; // Busca o trabalho que está em aberto
                TempData["Trabalho"]       = trabalho_temp;           // Mantém o trabalho aberto
                prof_Convidado.Trabalho_Id = trabalho_temp.Trabalho_Id;
                try
                {
                    db.Entry(prof_Convidado).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("../Trabalhoes/ViewTrabalho1"));
                }
                catch (Exception)
                {
                    ViewData["Message"] = "Não foi possível salvar, tente novamente mais tarde";
                    if (prof_Convidado.Permissao.Equals("Visualizar"))
                    {
                        ViewBag.Permissao = new SelectList(
                            new List <SelectListItem>
                        {
                            new SelectListItem {
                                Selected = true, Text = prof_Convidado.Permissao, Value = prof_Convidado.Permissao
                            },
                            new SelectListItem {
                                Selected = false, Text = "Editar", Value = "Editar"
                            },
                        }, "Value", "Text");
                    }
                    else if (prof_Convidado.Permissao.Equals("Editar"))
                    {
                        ViewBag.Permissao = new SelectList(
                            new List <SelectListItem>
                        {
                            new SelectListItem {
                                Selected = true, Text = prof_Convidado.Permissao, Value = prof_Convidado.Permissao
                            },
                            new SelectListItem {
                                Selected = false, Text = "Visualizar", Value = "Visualizar"
                            },
                        }, "Value", "Text");
                    }
                    ViewBag.Prof_Id = new SelectList((from p in db.Professors
                                                      where p.Prof_Id == prof_Convidado.Prof_Id
                                                      select p

                                                      ), "Prof_Id", "Nome");
                    return(View(prof_Convidado));
                }
            }
            ViewData["Message"] = "Não foi possível salvar, tente novamente mais tarde";
            if (prof_Convidado.Permissao.Equals("Visualizar"))
            {
                ViewBag.Permissao = new SelectList(
                    new List <SelectListItem>
                {
                    new SelectListItem {
                        Selected = true, Text = prof_Convidado.Permissao, Value = prof_Convidado.Permissao
                    },
                    new SelectListItem {
                        Selected = false, Text = "Editar", Value = "Editar"
                    },
                }, "Value", "Text");
            }
            else if (prof_Convidado.Permissao.Equals("Editar"))
            {
                ViewBag.Permissao = new SelectList(
                    new List <SelectListItem>
                {
                    new SelectListItem {
                        Selected = true, Text = prof_Convidado.Permissao, Value = prof_Convidado.Permissao
                    },
                    new SelectListItem {
                        Selected = false, Text = "Visualizar", Value = "Visualizar"
                    },
                }, "Value", "Text");
            }
            ViewBag.Prof_Id = new SelectList((from p in db.Professors
                                              where p.Prof_Id == prof_Convidado.Prof_Id
                                              select p

                                              ), "Prof_Id", "Nome");
            return(View(prof_Convidado));
        }