public ActionResult Edit(int id)
        {
            Topico topico = db.Topico.Where(s => s.Id.Equals(id)).FirstOrDefault();

            if (topico != null)
            {
                return(View(topico));
            }
            else
            {
                ResultSet response = new ResultSet();
                response.Code = -1;
                response.Msg  = String.Format("El tópico seleccionado ya no existe");
                return(RedirectToAction("Index", new RouteValueDictionary(response)));
            }
        }
        public ActionResult Details(int id)
        {
            MedicinaEntities db     = new MedicinaEntities();
            Topico           topico = db.Topico.Where(s => s.Id.Equals(id)).FirstOrDefault();

            if (topico != null)
            {
                return(View(topico));
            }
            else
            {
                ResultSet response = new ResultSet();
                response.Code = -1;
                response.Msg  = String.Format("La imagen seleccionada ya no existe");
                return(RedirectToAction("Index", new RouteValueDictionary(response)));
            }
        }
        public ActionResult Details(int id)
        {
            Topico topico = db.Topico.Where(s => s.Id.Equals(id)).FirstOrDefault();

            if (topico != null)
            {
                ViewBag.estado = (topico.visible) ? "Este tópico no se encuentra disponible para su visualización":"Este tópico se encuentra visible";
                return(View(topico));
            }
            else
            {
                ResultSet response = new ResultSet();
                response.Code = -1;
                response.Msg  = String.Format("El tópico seleccionado ya no existe");
                return(RedirectToAction("Index", new RouteValueDictionary(response)));
            }
        }
Exemple #4
0
        public List <Topico> ListarTopicoFilho(Topico topico)
        {
            List <Topico> listTopicos = new List <Topico>();

            listTopicos = daoTopico.ListarTopicoFilho(topico.Id);

            for (int i = 0; i < listTopicos.Count(); i++)
            {
                listTopicos[i].Anexos.id_topico   = listTopicos[i].Id;
                listTopicos[i].Anexos             = arquivoBll.RecuperarArqTopico(listTopicos[i].Anexos);
                listTopicos[i].usuario            = bllUsuario.ConsultaUsuarioInt(listTopicos[i].usuario);
                listTopicos[i].Tema               = daoTema.ListarTemaTopico(listTopicos[i].Tema.Id);
                listTopicos[i].avaliacao.idTopico = listTopicos[i].Id;
                listTopicos[i].avaliacao          = avaliacaobll.consultaAvaliacao(listTopicos[i].avaliacao, topico.avaliacao.idUsuario);
            }

            return(listTopicos);
        }
Exemple #5
0
        public ActionResult AdicionarResposta(Topico post)
        {
            TopicoBLL topicoBll = new TopicoBLL();

            post.Id     = topicoSalva.Id;
            post.Titulo = topicoSalva.Titulo;
            post.Tema   = topicoSalva.Tema;

            post.TopicoFilho.Tema = topicoSalva.Tema;
            post.usuario.Id       = topicoSalva.usuario.Id;

            post.TopicoFilho.DataCria = DateTime.Now;

            post.TopicoFilho.usuario.Id = User.Identity.GetUserId <int>();

            bool retorno = topicoBll.AdicionarPosts(post);

            return(Json(retorno));
        }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            DatabaseHelperClass dbtopicos = new DatabaseHelperClass();

            if (e.Parameter is Subtopico)
            {
                Subtopico          st            = e.Parameter as Subtopico;
                Conteudo_Subtopico SubtopicTitle = dbtopicos.ReadSubtopicTitle(st.Titulo);
                MainPage.instance.change_title(SubtopicTitle.Titulo.ToString());

                Uri targetUri = new Uri(ConfigData.Htmlpath + SubtopicTitle.Documento);
                webviewCont.Navigate(targetUri);
            }
            else if (e.Parameter is Topico)
            {
                Topico t = e.Parameter as Topico;

                if (t.Titulo == "FAQ")
                {
                    if (localSettings.Values["Idioma"].ToString() == "pt")
                    {
                        MainPage.instance.change_title("Perguntas Frequentes");
                    }
                    else
                    {
                        DatabaseHelperClass dbhandle = new DatabaseHelperClass();
                        string s = dbhandle.Translate("Perguntas Frequentes");
                        MainPage.instance.change_title(s);
                    }

                    Uri targetUri = new Uri(ConfigData.Htmlpath + "faq_" + localSettings.Values["Idioma"].ToString() + ".html");
                    webviewCont.Navigate(targetUri);
                }
                else
                {
                    Conteudo_Topico TopicTitle = dbtopicos.ReadTopicTitle(t.Titulo);
                    MainPage.instance.change_title(TopicTitle.Titulo.ToString());

                    Uri targetUri = new Uri(ConfigData.Htmlpath + TopicTitle.Documento);
                    webviewCont.Navigate(targetUri);
                }
            }
        }
        public void CriarPaginasDoTopico()
        {
            Topico.Clear();

            int    pagina = 0;
            string texto  = Conteudo.Conteudo;

            int    posicaoFinalDaLinha;
            string linha = "";

            while (linha != "{fim}")
            {
                List <string> linhasDaPagina = new List <string>();

                while (linha != "{fim}" && linha != "[pula]")
                {
                    if (!linha.Equals(""))
                    {
                        linhasDaPagina.Add(linha);
                        linhasDaPagina.Add("");
                    }

                    posicaoFinalDaLinha = texto.IndexOf('<');
                    linha = texto.Substring(0, posicaoFinalDaLinha);

                    posicaoFinalDaLinha = texto.IndexOf('>');
                    texto = texto.Substring(posicaoFinalDaLinha + 1);
                }

                PaginaOrientacao paginaOrientacao = new PaginaOrientacao(TituloTexto, linhasDaPagina, pagina);

                Topico.Add(paginaOrientacao);

                if (linha.Equals("[pula]"))
                {
                    linha = "";
                }

                pagina++;
            }

            AbrirTopicoOrientacao();
        }
Exemple #8
0
        public ActionResult TopicoSelecionado(string topicoId)
        {
            ViewBag.TopicoId = topicoId;
            ViewBag.Usuario  = User.Identity.GetUserId <int>();
            Topico    topico    = new Topico();
            TopicoBLL topicoBll = new TopicoBLL();

            topico.Id = Convert.ToInt16(topicoId);

            if (topicoBll.ValTopico(topico) == true)
            {
                topico.Id = Convert.ToInt16(topicoId);
                // ViewBag.TopicoId = topicoId;
                return(View(topico));
            }
            else
            {
                return(RedirectToAction("Error", "Home"));
            }
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                Topico topico = new Topico
                {
                    nome = collection["Nome"]
                };

                string jsonEnvio = JsonConvert.SerializeObject(topico);

                WebService.uploadJson("/AtributosNotas/criarTopico", jsonEnvio);
            }

            catch (Exception e)
            {
                Response.Write(e.Message);
            }
            ViewBag.tela = 2;
            return(View());
        }
        public async Task <Topico> Post([FromBody]  TopicoCadastroViewModel model)
        {
            Aprendiz aprendiz = db.Aprendizes.SingleOrDefault(u => u.Id == model.AprendizId);

            if (aprendiz == null)
            {
                throw new HttpException(401, new { Mensagem = "Aprendiz não foi encontrado" });
            }

            Topico topico = new Topico {
                Titulo      = model.Titulo,
                Texto       = model.Texto,
                DataCriacao = DateTime.Now,
                Usuario     = aprendiz
            };

            db.Topicos.Add(topico);
            await db.SaveChangesAsync();

            return(topico);
        }
Exemple #11
0
        public int consultaDeslike(Topico topico, int idUsuarioLogado)
        {
            SqlCommand comando;

            string        querSQL = String.Format("select count(Pontos) as Deslike from Avaliacao where Id_Topico = {0} and Pontos = -1", topico.Id, idUsuarioLogado);
            int           pontos  = 0;
            SqlDataReader reader;

            using (contexto = new Contexto())
            {
                comando = new SqlCommand(querSQL, contexto.forumConexao);

                reader = contexto.ExecutaComandoComRetorno(querSQL);

                while (reader.Read())
                {
                    pontos = Convert.ToInt16(reader["Deslike"].ToString());
                }
            }
            return(pontos);
        }
Exemple #12
0
        public float consultaLikeDeslike(Topico topico, int idUsuarioLogado)
        {
            SqlCommand comando;

            string        querSQL = String.Format("select Pontos from Avaliacao where Id_Topico = {0} and Id_Usuario = {1}", topico.Id, idUsuarioLogado);
            float         pontos  = 0;
            SqlDataReader reader;

            using (contexto = new Contexto())
            {
                comando = new SqlCommand(querSQL, contexto.forumConexao);

                reader = contexto.ExecutaComandoComRetorno(querSQL);

                while (reader.Read())
                {
                    pontos = float.Parse(reader["Pontos"].ToString());
                }
            }
            return(pontos);
        }
Exemple #13
0
        //#region Ordernar Por ultimo Post
        //public List<Topico> ListarTopicoUtimPost()
        //{
        //    var topico = new List<Topico>();
        //    SqlDataReader reader;

        //    using (contexto = new Contexto())
        //    {
        //        var strQuery = " SELECT * FROM Topico WHERE IdTopicoPai IS NOT NULL ORDER BY DataCriacao DESC ";
        //        reader = contexto.ExecutaComandoComRetorno(strQuery);

        //        while (reader.Read())
        //        {
        //            Topico readerTopico = new Topico();
        //            readerTopico.Id = Convert.ToInt32(reader["Id"].ToString());
        //            readerTopico.Titulo = reader["Titulo"].ToString();
        //            readerTopico.DataCria = Convert.ToDateTime(reader["DataCriacao"].ToString());
        //            readerTopico.Descricao = reader["Descricao"].ToString();
        //            readerTopico.usuario.Id = Convert.ToInt32(reader["Id_Usuario"].ToString());
        //            readerTopico.Tema.Id = Convert.ToInt32(reader["Id_Tema"].ToString());
        //            readerTopico.IdTopicoPai = Convert.ToInt32(reader["IdTopicoPai"].ToString());
        //            topico.Add(readerTopico);
        //        }
        //    }
        //    reader.Close();
        //    return topico;
        //}
        //#endregion

        #region ValTopico se Existe

        public Topico ValTopico(Topico topico)
        {
            SqlDataReader reader;

            using (contexto = new Contexto())
            {
                var strQuery = string.Format(" SELECT * FROM Topico WHERE Id ='{0}' AND IdTopicoPai IS NULL", topico.Id);
                reader = contexto.ExecutaComandoComRetorno(strQuery);
                Topico readerTopico = new Topico();
                while (reader.Read())
                {
                    readerTopico.Id         = Convert.ToInt32(reader["Id"].ToString());
                    readerTopico.Titulo     = reader["Titulo"].ToString();
                    readerTopico.DataCria   = Convert.ToDateTime(reader["DataCriacao"].ToString());
                    readerTopico.Descricao  = reader["Descricao"].ToString();
                    readerTopico.usuario.Id = Convert.ToInt32(reader["Id_Usuario"].ToString());
                    readerTopico.Tema.Id    = Convert.ToInt32(reader["Id_Tema"].ToString());
                }
                topico = (readerTopico);
            }
            reader.Close();
            return(topico);
        }
Exemple #14
0
        public async Task EnviarEmail(Topico topico)
        {
            List <string> email = new List <string>();

            for (int i = 0; i < topico.Resposta.Count; i++)
            {
                email.Add(topico.Resposta[i].usuario.Email);
            }

            email = email.Distinct().ToList();

            for (int i = 0; i < email.Count; i++)
            {
                using (SmtpClient client = new SmtpClient("smtp.gmail.com", 587)
                {
                    Credentials = new NetworkCredential("*****@*****.**", "UMC@2018"),
                    EnableSsl = true
                })

                {
                    client.Send(email[i], email[i], "Forum UMC", "O Topico http://www.mehelpehml.tk/Topico/TopicoSelecionado?topicoId=" + topico.Id + " Foi Fechado");
                }
            }
        }
        private void Faq_Button_Click(object sender, RoutedEventArgs e)
        {
            Topico t = new Topico(null, "FAQ", null, null, null);

            Frame.Navigate(typeof(Pages.Conteudo), t);
        }
 public IActionResult Cadastra([FromBody] Topico topico)
 {
     forum.CadastrarTopico(topico);
     return(Ok());
 }
 public IActionResult Update([FromBody] Topico topico)
 {
     forum.UpdateTopico(topico);
     return(Ok());
 }
Exemple #18
0
        public static async Task Seed(Db db)
        {
            await ClearDb(db);

            var user1 = new RecursosHumano()
            {
                Nome           = "Patrick",
                Email          = "*****@*****.**",
                Sobrenome      = "Ens",
                DataNascimento = DateTime.Now
            };

            user1.SetPassword("teste1234%");
            db.Usuarios.Add(user1);

            var gestor1 = new Gestor()
            {
                Nome           = "gestor",
                Email          = "*****@*****.**",
                Sobrenome      = "gestão",
                DataNascimento = DateTime.Now,
            };

            gestor1.SetPassword("teste1234%");
            db.Usuarios.Add(gestor1);

            var inst1 = new Instituicao()
            {
                Nome         = "instituicao",
                Email        = "*****@*****.**",
                Sobrenome    = "insti",
                DataFundacao = DateTime.Now,
            };

            inst1.SetPassword("teste1234%");
            db.Usuarios.Add(inst1);

            var aprendiz1 = new Aprendiz(DateTime.Now, DateTime.Now, DateTime.Now.AddDays(90), inst1, gestor1)
            {
                Nome      = "Antonio",
                UserName  = "******",
                Sobrenome = "de Almeida",
                Email     = "*****@*****.**",
                Nivel     = 1
            };

            aprendiz1.SetPassword("teste$132");
            db.Usuarios.Add(aprendiz1);

            var aprendiz2 = new Aprendiz(DateTime.Now, DateTime.Now, DateTime.Now.AddDays(40), inst1, gestor1)
            {
                Nome      = "José",
                UserName  = "******",
                Sobrenome = "Lima Camargo",
                Email     = "*****@*****.**",
                Nivel     = 2
            };

            aprendiz2.SetPassword("novo$132");
            db.Usuarios.Add(aprendiz2);

            var tarefa1 = new Tarefa()
            {
                Active      = true,
                Conteudo    = "Conhecimento da Lingua Inglêsa",
                DataCriacao = DateTime.Now,
                Nivel       = 1,
                Titulo      = "Atividade de Ingles - Tradução",
                Usuario     = user1,
                Questoes    = new List <Questao>()
                {
                    new Questao()
                    {
                        Titulo       = "Selecione a alternativa correta",
                        Ordem        = 1,
                        Conteudo     = "What does business mean?",
                        Alternativas = new List <Alternativa>()
                        {
                            new Alternativa()
                            {
                                TextoAlternativa = "Necogiação",
                                Correta          = false,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Negócio",
                                Correta          = true,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Empresa",
                                Correta          = false,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Nenhuma das anteriores",
                                Correta          = false,
                            },
                        }
                    },
                    new Questao()
                    {
                        Titulo       = "Qual a correta tradução",
                        Ordem        = 2,
                        Conteudo     = "Google bans Chrome extensions",
                        Alternativas = new List <Alternativa>()
                        {
                            new Alternativa()
                            {
                                TextoAlternativa = "Google impede as extensões do Chrome",
                                Correta          = false,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Google impele o Chrome e extensões",
                                Correta          = false,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Google proíbe extensões do Chrome",
                                Correta          = true,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Google maldiz as extensões do Chrome ",
                                Correta          = false,
                            },
                        }
                    }
                }
            };

            db.Tarefas.Add(tarefa1);

            var tarefa2 = new Tarefa()
            {
                Active      = true,
                Conteudo    = "Conhecimento da Lingua Inglêsa",
                DataCriacao = DateTime.Now,
                Nivel       = 2,
                Titulo      = "Atividade de Ingles - Significado",
                Usuario     = user1,
                Questoes    = new List <Questao>()
                {
                    new Questao()
                    {
                        Titulo       = "Sobre o que é discutido",
                        Ordem        = 1,
                        Conteudo     = "As it pushes beyond the tech industry, artiticial intelligence could make workplaces fairer - os more oppressive",
                        Alternativas = new List <Alternativa>()
                        {
                            new Alternativa()
                            {
                                TextoAlternativa = "Como as pessoas trabalham",
                                Correta          = false,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Como funciona as empresas",
                                Correta          = false,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "A influência da IA no trabalho",
                                Correta          = true,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Nenhuma das anteriores",
                                Correta          = false,
                            },
                        }
                    },
                    new Questao()
                    {
                        Titulo       = "Qual o sujeito na frase",
                        Ordem        = 2,
                        Conteudo     = "Accusations against a moderate presidential candidate could hand power to a left-wing populist",
                        Alternativas = new List <Alternativa>()
                        {
                            new Alternativa()
                            {
                                TextoAlternativa = "Presidente Populista",
                                Correta          = false,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Populista de esquerda",
                                Correta          = false,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Moderado Populista",
                                Correta          = false,
                            },
                            new Alternativa()
                            {
                                TextoAlternativa = "Candidato Presidencial",
                                Correta          = true,
                            },
                        }
                    }
                }
            };

            db.Tarefas.Add(tarefa2);

            var topico = new Topico {
                Titulo      = "Qual o melhor database?",
                Texto       = "Qual o melhor database, MongoDB ou Firebase?",
                DataCriacao = DateTime.Now.AddDays(30),
                Usuario     = aprendiz1,
                Replicas    = new List <Replica>()
                {
                    new Replica()
                    {
                        Texto       = "Para Startups com projetos pequenos acredito que Firebase",
                        DataCriacao = DateTime.Now.AddDays(31),
                        Usuario     = aprendiz2
                    },
                    new Replica()
                    {
                        Texto       = "Eu acreditava que seria o Mongo...",
                        DataCriacao = DateTime.Now.AddDays(33),
                        Usuario     = aprendiz1
                    }
                }
            };

            db.Topicos.Add(topico);

            await db.SaveChangesAsync();
        }
Exemple #19
0
 public ItemVerificado(Topico topicoVerificacao)
 {
     TopicoVerificacao = topicoVerificacao;
 }
 public void Delete([FromBody] Topico topico)
 {
     forum.DeletarTopico(topico.Id);
 }
Exemple #21
0
 public bool AdicionarPosts(Topico post)
 {
     daoTopico.UpdateDataTopico(post);
     return(daoTopico.AdicionarPosts(post));
 }
Exemple #22
0
 public bool FechaTopico(Topico topico)
 {
     //  EnviarEmail(topico);
     return(daoTopico.FechaTopico(topico));
 }
Exemple #23
0
 public bool AdicionarTopico(Topico topico)
 {
     topico.Status.Id = 1;
     topico.Tema      = daoTema.ConsultaTema(topico.Tema.Id);
     return(daoTopico.AdicionarTopico(topico));
 }
Exemple #24
0
 public async void EnviaEmailTopicoFechado([FromBody] Topico topico)
 {
     TopicoBLL topicoBll = new TopicoBLL();
     await topicoBll.EnviarEmail(topico);
 }
Exemple #25
0
 public ActionResult RespostaTopico(Topico topico)
 {
     return(View());
 }