Esempio n. 1
0
        public ActionResult Edit(Enquete enqueteToUpdate, FormCollection formCollection, string[] enqueteUsers, string[] enqueteAdministrators)
        {
            if (ModelState.IsValid)
            {
                unitOfWork.UoWcontext.Entry(enqueteToUpdate).State = EntityState.Modified;
                unitOfWork.Save();
                PopulateAssignedGebruikers(enqueteToUpdate);
                PopulateEnqueteAdministrators(enqueteToUpdate);
                return(RedirectToAction("Index"));
            }
            if (TryUpdateModel(enqueteToUpdate, "", null, new string[] { "enqueteUsers" }))
            {
                try
                {
                    UpdateGebruikersVeld(enqueteUsers, enqueteToUpdate);
                    unitOfWork.UoWcontext.Entry(enqueteToUpdate).State = EntityState.Modified;
                    unitOfWork.Save();


                    return(RedirectToAction("Index"));
                }
                catch (DataException)
                {
                    //Log the error (add a variable name after DataException)
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }


            ViewBag.OwnerID = new SelectList(unitOfWork.GebruikerRepository.GetAll(), "ID", "Voornaam", enqueteToUpdate.OwnerID);

            return(View(enqueteToUpdate));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("ProjetoId,Descricao")] Enquete enquete)
        {
            if (id != enquete.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enquete);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnqueteExists(enquete.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjetoId"] = new SelectList(_context.Projetos, "Id", "Id", enquete.ProjetoId);
            return(View(enquete));
        }
Esempio n. 3
0
        public Envelope <Enquete> Cadastrar(Enquete novaEnquete)
        {
            _daniQuizContext.Enquete.Add(novaEnquete);
            _daniQuizContext.SaveChanges();

            return(new Envelope <Enquete>(novaEnquete));
        }
Esempio n. 4
0
        public List <Enquete> setarObjeto(SqlDataReader dr)
        {
            Enquete        obj        = new Enquete();
            List <Enquete> lstEnquete = new List <Enquete>();

            try
            {
                for (int idx = 0; idx < dr.FieldCount; idx++)
                {
                    dr.GetName(idx).ToString();

                    switch (dr.GetName(idx).ToUpper())
                    {
                    case "ID_ENQUETE":
                        obj.id_enquete = Convert.ToInt32(dr[idx]);
                        break;

                    case "PERGUNTA":
                        obj.pergunta = Convert.ToString(dr[idx]);
                        break;

                    case "DT_INICIO":
                        obj.dtInicio = Convert.ToDateTime(dr[idx]);
                        break;

                    case "DT_FINAL":
                        obj.dtFim = Convert.ToDateTime(dr[idx]);
                        break;

                    case "ID_COND":
                        obj.condominio.id_cond = Convert.ToInt32(dr[idx]);
                        break;

                    case "ID_ENQUETE_ALTERNATIVAS":
                        obj.id_enquete_alt = Convert.ToInt32(dr[idx]);
                        break;

                    case "ID_VOTO":
                        obj.id_voto = Convert.ToInt32(dr[idx]);
                        break;

                    case "ID_PESSOA":
                        obj.pessoa.id_pessoa = Convert.ToInt32(dr[idx]);
                        break;

                    case "TEXTO":
                        obj.textoAlt = Convert.ToString(dr[idx]);
                        break;
                    }
                }
            }

            catch (Exception ex)
            {
                dr.Dispose();
                throw ex;
            }

            return(lstEnquete);
        }
Esempio n. 5
0
    private void CarregarObjetos(Utilitarios.TipoTransacao objTipoTransacao)
    {
        switch (objTipoTransacao)
        {
        //Novo Grupo
        case Utilitarios.TipoTransacao.Limpar:
            codigo = 0;

            txtEnquete.Text = string.Empty;

            break;

        //Carregar Dados do Grupo
        case Utilitarios.TipoTransacao.Salvar:

            if (gobjEnquete == null)
            {
                gobjEnquete = new Enquete();
            }

            gobjEnquete.Descricao = txtEnquete.Text;

            break;
        }
    }
Esempio n. 6
0
        /// <summary>
        /// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public ActionResult CadastraEnquete(Enquete obj)
        {
            EnquetesDAO dao = new EnquetesDAO();

            dao.cadastra(obj);
            return(RedirectToAction("frmBuscaEnquete"));
        }
Esempio n. 7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Poll_Description")] Enquete enquete)
        {
            if (id != enquete.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enquete);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnqueteExists(enquete.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(enquete));
        }
Esempio n. 8
0
        /**
         * Method die het veld van ENQUETEUSERS controleert op aangevinkte en uitgevinkte gebruikers
         *
         **/
        private void UpdateGebruikersVeld(string[] selectedUsers, Enquete enquete)
        {
            if (selectedUsers == null)
            {
                enquete.EnqueteUsers = new List <Gebruiker>();
                return;
            }

            var gebruikersPerEnqueteHS = new HashSet <string>(selectedUsers);
            var gebruikersPerEnquete   = new HashSet <int>(enquete.EnqueteUsers.Select(g => g.ID));

            foreach (var gebruiker in unitOfWork.GebruikerRepository.GetAll())
            {
                //EnqueteUser is aangevinkt, voeg hem toe
                if (gebruikersPerEnqueteHS.Contains(gebruiker.ID.ToString()))
                {
                    if (!gebruikersPerEnquete.Contains(gebruiker.ID))
                    {
                        enquete.EnqueteUsers.Add(gebruiker);
                    }
                }
                //EnqueteUser is terug uitgevinkt, verwijder hem
                else
                {
                    if (gebruikersPerEnquete.Contains(gebruiker.ID))
                    {
                        enquete.EnqueteUsers.Remove(gebruiker);
                    }
                }
            }
        }
Esempio n. 9
0
        public ActionResult AlteraEnquete(Enquete obj)
        {
            EnquetesDAO dao = new EnquetesDAO();

            //dao.altera(obj);
            return(RedirectToAction("frmBuscaEnquete"));
        }
Esempio n. 10
0
        public ActionResult DeleteConfirmed(int id)
        {
            Enquete enquete = unitOfWork.EnqueteRepository.GetById(id);

            unitOfWork.EnqueteRepository.Delete(enquete);
            unitOfWork.Save();
            return(RedirectToAction("Index"));
        }
Esempio n. 11
0
        //
        // GET: /Enquete/Edit/5

        public ActionResult Edit(int id)
        {
            Enquete enquete = unitOfWork.EnqueteRepository.GetById(id);

            ViewBag.OwnerID = new SelectList(unitOfWork.GebruikerRepository.GetAll(), "ID", "Voornaam", enquete.OwnerID);

            return(View(enquete));
        }
Esempio n. 12
0
        public ActionResult Create(Enquete enquete, string[] resposta, string[] correta)
        {
            if (ModelState.IsValid)
            {
                db.Enquete.Add(enquete);
                enquete.dataCadastro = DateTime.Now;

                int suffix = 0;

                do
                {
                    enquete.chave = enquete.pergunta.GenerateSlug() + (suffix > 0 ? suffix.ToString() : "");
                    suffix++;
                } while (db.Enquete.Where(o => o.chave == enquete.chave).Count() > 0);

                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    #region just-debug
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                        //throw;
                    }
                    #endregion
                }

                for (int cont = 0; cont < resposta.Count(); cont++)
                {
                    if (resposta[cont] != null && resposta[cont] != "")
                    {
                        Respostas respostas = new Respostas();

                        respostas.idEnquete = enquete.id;
                        respostas.resposta  = resposta[cont];
                        respostas.votos     = 0;

                        respostas.excluido = false;

                        db.Respostas.Add(respostas);
                        db.SaveChanges();
                    }
                }
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, enquete.id);
                return(RedirectToAction("Index"));
            }

            return(View(enquete));
        }
Esempio n. 13
0
        //
        // GET: /Enquete/CadastraResposta/id
        public ActionResult CadastraResposta(int id)
        {
            Enquete enquete = db.Enquete.Find(id);

            if (enquete == null)
            {
                return(HttpNotFound());
            }
            return(View(enquete));
        }
Esempio n. 14
0
        //
        // GET: /Enquete/Delete/5

        public ActionResult Delete(int id = 0)
        {
            Enquete enquete = db.Enquete.Find(id);

            if (enquete == null)
            {
                return(HttpNotFound());
            }
            return(View(enquete));
        }
Esempio n. 15
0
        private ListaEnquete resultadoEnquete(DataTable dt)
        {
            ListaEnquete oListEnquete = new ListaEnquete();

            ApartamentoModel oApEnquete = new ApartamentoModel();


            foreach (DataRow itemOcorrencia in dt.Rows)
            {
                Enquete oEnquete = new Enquete();

                if (itemOcorrencia.Table.Columns.Contains("idEnquete"))
                {
                    oEnquete.idEnquete = Convert.ToInt32(itemOcorrencia["idEnquete"]);
                }

                if (itemOcorrencia.Table.Columns.Contains("descEnquete"))
                {
                    oEnquete.enqueteDescricao = itemOcorrencia["descEnquete"].ToString();
                }

                if (itemOcorrencia.Table.Columns.Contains("soma"))
                {
                    oEnquete.resultadoEnquete = Convert.ToInt32(itemOcorrencia["soma"]);
                }

                if (itemOcorrencia.Table.Columns.Contains("ap"))
                {
                    oApEnquete.apartamento = Convert.ToInt32(itemOcorrencia["ap"]);
                }


                if (itemOcorrencia.Table.Columns.Contains("bloco"))
                {
                    oApEnquete.bloco = Convert.ToInt32(itemOcorrencia["bloco"]);
                }
                oEnquete.oAP = oApEnquete;


                if (itemOcorrencia.Table.Columns.Contains("votacao"))
                {
                    oEnquete.resultadoEnquete = Convert.ToInt32(itemOcorrencia["votacao"]);
                }

                if (itemOcorrencia.Table.Columns.Contains("dataResposta"))
                {
                    oEnquete.dataResposta = Convert.ToDateTime(itemOcorrencia["dataResposta"]);
                }


                oListEnquete.Add(oEnquete);
            }

            return(oListEnquete);
        }
Esempio n. 16
0
        public async Task <IActionResult> Create([Bind("Id,Poll_Description")] Enquete enquete)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enquete);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(enquete));
        }
Esempio n. 17
0
        public ActionResult Create(Enquete enquete)
        {
            if (ModelState.IsValid)
            {
                unitOfWork.EnqueteRepository.Add(enquete);
                unitOfWork.Save();
                return(RedirectToAction("Index"));
            }

            ViewBag.OwnerID = new SelectList(unitOfWork.GebruikerRepository.GetAll(), "ID", "Voornaam", enquete.OwnerID);
            return(View(enquete));
        }
Esempio n. 18
0
        public async Task <IActionResult> Create([Bind("ProjetoId,Descricao")] Enquete enquete)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enquete);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjetoId"] = new SelectList(_context.Projetos, "Id", "Id", enquete.ProjetoId);
            return(View(enquete));
        }
Esempio n. 19
0
        public void Vote(int id, [FromBody] VO_Voto voto)
        {
            Enquete  cadEnquete = new Enquete();
            TB_Opcao opcao      = new TB_Opcao();

            opcao.poll_id = id;
            if (voto.option_id > 3 || voto.option_id < 1)
            {
                voto.option_id = 1;
            }
            opcao.option_id = voto.option_id;
            cadEnquete.Votar(opcao);
        }
Esempio n. 20
0
        public ActionResult Edit(Enquete enquete)
        {
            if (ModelState.IsValid)
            {
                db.Entry(enquete).State = EntityState.Modified;

                int suffix = 0;

                do
                {
                    enquete.chave = enquete.pergunta.GenerateSlug() + (suffix > 0 ? suffix.ToString() : "");
                    suffix++;
                } while (db.Enquete.Where(o => o.chave == enquete.chave && o.id != enquete.id).Count() > 0);


                //List<Respostas> resp = db.Respostas.Where(x => x.idEnquete == enquete.id).ToList();
                //foreach (var x in resp)
                //{
                //    db.Respostas.Remove(x);
                //}

                //if (resposta != null)
                //{
                //    for (int cont = 0; cont < resposta.Count(); cont++)
                //    {
                //        if (resposta[cont] != null && resposta[cont] != "")
                //        {
                //            Respostas respostas = new Respostas();

                //            respostas.idEnquete = enquete.id;
                //            respostas.resposta = resposta[cont];
                //            respostas.votos = 0;

                //            respostas.excluido = false;

                //            db.Respostas.Add(respostas);
                //            //db.SaveChanges();

                //        }
                //    }
                //}

                db.SaveChanges();
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, enquete.id);
                return(RedirectToAction("Index"));
            }
            return(View(enquete));
        }
Esempio n. 21
0
        public ActionResult Index(Enquete enquete, int idEnquete, int Pontuacao)
        {
            try
            {
                enquete.Resposta.Pontuacao  = Pontuacao;
                enquete.Resposta.Id_Enquete = idEnquete;

                enquete.Resposta.Submit();

                return(RedirectToAction("Index", "Enquetes"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("index", "Erro"));
            }
        }
Esempio n. 22
0
        public ActionResult CadastraRespostaOk(int id, string resposta)
        {
            Enquete enquete = db.Enquete.Find(id);
            var     resp    = new Respostas
            {
                votos     = 0,
                idEnquete = enquete.id,
                excluido  = false,
                Enquete   = enquete,
                resposta  = resposta
            };

            db.Respostas.Add(resp);
            db.SaveChanges();
            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM2, TipoAcesso.Insercao, resp.id);
            return(RedirectToAction("Edit/" + enquete.id));
        }
    public static List <Enquete> ListarEnquete()
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_L_ENQUETE");

        objComando.Connection  = objConexao;
        objComando.CommandType = CommandType.StoredProcedure;


        try
        {
            //Abre Conexao
            objConexao.Open();

            //Declara variavel de retorno
            List <Enquete> objList = new List <Enquete>();
            Enquete        obj     = default(Enquete);

            IDataReader idrReader = default(IDataReader);

            idrReader = objComando.ExecuteReader();

            while ((idrReader.Read()))
            {
                obj = new Enquete();
                obj.FromIDataReader(idrReader);
                objList.Add(obj);
            }

            return(objList);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            //Fecha a conexao se aberta
            if (objConexao.State != ConnectionState.Closed)
            {
                objConexao.Close();
            }
        }
    }
Esempio n. 24
0
        public ActionResult Details(int id = 0)
        {
            //Busco a enquete
            Enquete enquete = db.Enquete.Find(id);

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

            //Crio as list com as respostas e as cores do grafico
            var listLabel = new List <JsonLabels>();
            var listCor   = new List <string>();
            var verifica  = 0;
            var random    = new Random();


            //Preencho com os valores das cores e respostas
            foreach (var i in enquete.Respostas)
            {
                JsonLabels labels = new JsonLabels
                {
                    label = i.resposta,
                    value = i.votos
                };
                //caso nenhum voto "verifica" fica com 0
                verifica += i.votos;
                listLabel.Add(labels);
                var color = String.Format("#{0:X6}", random.Next(0x1000000));
                listCor.Add(color);
            }

            //Coloco na classe enquete
            var Jenquete = new JsonEnquete()
            {
                element   = "sales-chart",
                resize    = true,
                colors    = listCor,
                data      = listLabel,
                hideHover = "auto"
            };

            ViewData["json"] = JsonConvert.SerializeObject(Jenquete);
            ViewBag.verifica = verifica;
            return(View(enquete));
        }
Esempio n. 25
0
        /**
         * Bevolk enqueteADMINISTRATORS veld
         **/
        private void PopulateEnqueteAdministrators(Enquete enquete)
        {
            var allusers = unitOfWork.GebruikerRepository.GetAll();
            var enqueteAdministrators = new HashSet <int>(enquete.EnqueteAdministrators.Select(c => c.ID));
            var viewModel             = new List <EnqueteAdministrator>();

            foreach (var gebruiker in allusers)
            {
                viewModel.Add(new EnqueteAdministrator
                {
                    ID       = gebruiker.ID,
                    Naam     = gebruiker.Voornaam,
                    Assigned = enqueteAdministrators.Contains(gebruiker.ID)
                });
            }
            ViewBag.EnqueteAdministrators = viewModel;
        }
Esempio n. 26
0
        public bool cadastraAlternativas(Enquete enquete)
        {
            query = null;
            try
            {
                query = "INSERT INTO ENQUETE_ALTERNATIVAS (TEXTO, ID_ENQUETE, STS_ATIVO) VALUES ('"
                        + enquete.textoAlt + "', " + (enquete.id_enquete).ToString() + ", 1;";
                banco.MetodoNaoQuery(query);
                return(true);
            }

            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
        public async Task <IActionResult> CloturerEnquete()
        {
            CloturerEnquetePolicyContext context = new CloturerEnquetePolicyContext
            {
                Utilisateur = Utilisateur.CreateAdmin(),
                Enquete     = Enquete.Create()
            };

            IPolicyResult <ICloturerEnquete> result = await this.cloturerEnqueteChecker.CheckPoliciesAsync(context).ConfigureAwait(false);

            if (result.Allowed)
            {
                result.Action.Execute(context.Enquete, context.Utilisateur);
                return(this.View(context.Enquete));
            }

            return(this.View("Unauthorized"));
        }
Esempio n. 28
0
        public ActionResult DeleteConfirmed(int id)
        {
            Enquete enquete = db.Enquete.Find(id);
            //db.Entry(enquete).Collection("Resposta").Load();
            List <Respostas> resposta = db.Respostas.Where(x => x.idEnquete == id).ToList();

            foreach (var resp in resposta)
            {
                db.Respostas.Remove(resp);
            }
            //db.Enquete.Remove(enquete);
            enquete.excluido        = true;
            db.Entry(enquete).State = EntityState.Modified;
            db.SaveChanges();

            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Exclusao, enquete.id);
            return(RedirectToAction("Index"));
        }
Esempio n. 29
0
        public bool cadastraVoto(Enquete enquete)
        {
            query = null;
            try
            {
                query = "INSERT INTO VOTO (ID_ENQUETE, ID_ENQUETE_ALTERNATIVAS, ID_PESSOA, STS_ATIVO) VALUES ("
                        + (enquete.id_enquete).ToString() + ", " + (enquete.voto).ToString() + ", "
                        + (enquete.pessoa.id_pessoa).ToString() + ", 1);";
                banco.MetodoNaoQuery(query);
                return(true);
            }

            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
Esempio n. 30
0
        public bool alteraEnquete(Enquete enquete)
        {
            query = null;
            try
            {
                query = "UPDATE ENQUETE SET DT_FINAL = '"
                        + (enquete.dtFim).ToShortDateString() + "' WHERE ID_ENQUETE = "
                        + (enquete.id_enquete).ToString() + ";";
                banco.MetodoNaoQuery(query);
                return(true);
            }

            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
        public void cadastraVotacao(Enquete oEnquete)
        {
            string clausulaSQL = "SP_VOTACAO_ENQUETE";

            try
            {
                SqlCommand comandoSQL = new SqlCommand(clausulaSQL);
                comandoSQL.Parameters.AddWithValue("@ID_ENQUETE", oEnquete.idEnquete);
                comandoSQL.Parameters.AddWithValue("@DESCRICAO_ENQUETE", oEnquete.enqueteDescricao);
                comandoSQL.Parameters.AddWithValue("@VOTACAO", oEnquete.resultadoEnquete);
                comandoSQL.Parameters.AddWithValue("@BLOCO", oEnquete.oAP.bloco);
                comandoSQL.Parameters.AddWithValue("@AP", oEnquete.oAP.apartamento);

                ExecutaComando(comandoSQL);

            }
            catch (Exception)
            {

                throw;
            }
        }
        private ListaEnquete resultadoEnquete(DataTable dt)
        {
            ListaEnquete oListEnquete = new ListaEnquete();

            ApartamentoModel oApEnquete = new ApartamentoModel();

            foreach (DataRow itemOcorrencia in dt.Rows)
            {
                Enquete oEnquete = new Enquete();

                if (itemOcorrencia.Table.Columns.Contains("idEnquete"))
                    oEnquete.idEnquete = Convert.ToInt32(itemOcorrencia["idEnquete"]);

                if (itemOcorrencia.Table.Columns.Contains("descEnquete"))
                    oEnquete.enqueteDescricao = itemOcorrencia["descEnquete"].ToString();

                if (itemOcorrencia.Table.Columns.Contains("soma"))
                    oEnquete.resultadoEnquete = Convert.ToInt32(itemOcorrencia["soma"]);

                if (itemOcorrencia.Table.Columns.Contains("ap"))
                    oApEnquete.apartamento = Convert.ToInt32(itemOcorrencia["ap"]);

                if (itemOcorrencia.Table.Columns.Contains("bloco"))
                    oApEnquete.bloco = Convert.ToInt32(itemOcorrencia["bloco"]);
                oEnquete.oAP = oApEnquete;

                if (itemOcorrencia.Table.Columns.Contains("votacao"))
                    oEnquete.resultadoEnquete = Convert.ToInt32(itemOcorrencia["votacao"]);

                if (itemOcorrencia.Table.Columns.Contains("dataResposta"))
                    oEnquete.dataResposta = Convert.ToDateTime(itemOcorrencia["dataResposta"]);

                oListEnquete.Add(oEnquete);
            }

            return oListEnquete;
        }
        public EnqueteMensagemView(Enquete enquete)
        {
            this.BindingContext = enquete;
            this.model = new EnquetePublicaViewModel(this.Navigation);

//            var imgQuote = new Image
//            {
//                HorizontalOptions = LayoutOptions.StartAndExpand,
//                IsVisible = true,
//                Aspect = Aspect.Fill,
//                InputTransparent = true
//            };
//            imgQuote.SetBinding(Image.SourceProperty, "ImageSource");
//            
//            var imgSetaDireita = new Image
//            {
//                Source = ImageSource.FromResource(RetornaCaminhoImagem.GetImagemCaminho("setaDireita.png")),
//                InputTransparent = true
//            };

            var lblTitulo = new Label
            {
                Style = Estilos._estiloFonteEnquete,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                YAlign = TextAlignment.Start,
                InputTransparent = true
            };
            lblTitulo.SetBinding(Label.TextProperty, "Titulo", BindingMode.Default,
                new TituloCompridoConverter(), null);

            var contanierLayout = new AbsoluteLayout
            {
                //WidthRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth - 50,
                InputTransparent = true,
                VerticalOptions = LayoutOptions.FillAndExpand,
            };

            var overlay = new Image
            {
                /*BackgroundColor = Colors._defaultColorFromHex,*/ 
                InputTransparent = true,
                Aspect = Aspect.AspectFit
            };
            overlay.SetBinding(Image.SourceProperty, "ImageSource");

            var cView = new ContentView
            {
                Content = overlay,
                VerticalOptions = LayoutOptions.FillAndExpand,
                WidthRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth,
                InputTransparent = true
            };

//            AbsoluteLayout.SetLayoutFlags(cView, AbsoluteLayoutFlags.PositionProportional);
//            AbsoluteLayout.SetLayoutBounds(cView, new Rectangle(1, 0, 1, 1));
//
//
//            AbsoluteLayout.SetLayoutFlags(imgQuote, AbsoluteLayoutFlags.PositionProportional);
//            AbsoluteLayout.SetLayoutBounds(imgQuote, new Rectangle(0, 0.45, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
//
//            AbsoluteLayout.SetLayoutFlags(lblTitulo, AbsoluteLayoutFlags.PositionProportional);
//            AbsoluteLayout.SetLayoutBounds(lblTitulo, new Rectangle(0.50, 0.35, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
//
//            contanierLayout.Children.Add(cView);
//            contanierLayout.Children.Add(imgQuote);

            var frame_Click_Android = new TapGestureRecognizer();
            var frame_Click_iOS = new TapGestureRecognizer();

            if (Device.OS == TargetPlatform.iOS)
                frame_Click_iOS.Tapped += (sender, e) => MessagingCenter.Send<EnqueteMensagemView,int>(this, "CarregarMensagem", enquete.Id);
            else
                frame_Click_Android.Tapped += async (sender, e) => await this.model.CarregarMensagem(enquete.Id);

//            if (Device.OS == TargetPlatform.Android)
//            {
//                contanierLayout.GestureRecognizers.Add(frame_Click_Android);
//            }

//            var frame = new Frame
//            { 
//                OutlineColor = Color.Transparent,
//                BackgroundColor = Color.Red,
//                Content = cView,
//                //HeightRequest = 10,
//                HasShadow = false,
//                InputTransparent = true
//            };

//            if (Device.OS == TargetPlatform.Android)
//                frame.GestureRecognizers.Add(frame_Click_Android);
//            else
//                frame.GestureRecognizers.Add(frame_Click_iOS);

//            var frameSeta = new Frame
//            {
//                OutlineColor = Color.Transparent,
//                BackgroundColor = Color.FromHex("#1e3d63"),
//                HasShadow = false,
//                HeightRequest = 10,
//                WidthRequest = 0.01,
//                InputTransparent = true
//            };

//            if (Device.OS == TargetPlatform.Android)
//                frameSeta.GestureRecognizers.Add(frame_Click_Android);
//            else
//                frameSeta.GestureRecognizers.Add(frame_Click_iOS);

            var absLayout = new AbsoluteLayout();

            AbsoluteLayout.SetLayoutFlags(cView, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(cView, new Rectangle(1, 0, 1, 1));

//            AbsoluteLayout.SetLayoutFlags(frameSeta, AbsoluteLayoutFlags.PositionProportional);
//            AbsoluteLayout.SetLayoutBounds(frameSeta, new Rectangle(1, 1, AbsoluteLayout.AutoSize, 1));

            AbsoluteLayout.SetLayoutFlags(lblTitulo, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(lblTitulo, new Rectangle(0.50, 0.35, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

//            AbsoluteLayout.SetLayoutFlags(imgSetaDireita, AbsoluteLayoutFlags.PositionProportional);
//            AbsoluteLayout.SetLayoutBounds(imgSetaDireita, new Rectangle(0.97, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            absLayout.Children.Add(cView);
            absLayout.Children.Add(lblTitulo);
            //absLayout.Children.Add(frameSeta);
            //absLayout.Children.Add(imgSetaDireita);
            absLayout.InputTransparent = false;

            if (Device.OS == TargetPlatform.iOS)
                absLayout.GestureRecognizers.Add(frame_Click_iOS);
            else
                absLayout.GestureRecognizers.Add(frame_Click_Android);

            Content = absLayout;
        }
Esempio n. 34
0
        protected async override void OnAppearing()
        {
            try
            {
                base.OnAppearing();
                this.model = App.Container.Resolve<PerguntaViewModel>();
                this.BindingContext = model;
				
                model.AdicionaMensagem(await model.GetMensagem(enqueteID));
                this.enquete = model.Mensagem;
                this.model.ConfigurarNavigation(this.Navigation);
				
                var lblTitulo = new Label
                {
                    FontSize = 28,
                    FontFamily = Device.OnPlatform(
                        iOS: "Helvetica",
                        Android: "Roboto",
                        WinPhone: "Segoe"
                    ),
                    FontAttributes = FontAttributes.Bold,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions = LayoutOptions.Center,
                    YAlign = TextAlignment.Center,
                    XAlign = TextAlignment.Center,
                    LineBreakMode = LineBreakMode.WordWrap
                };
                lblTitulo.SetBinding<PerguntaViewModel>(Label.TextProperty, x => x.Mensagem.Titulo);
				
                var lblDescricao = new Label
                {
                    FontSize = 22,
                    FontFamily = Device.OnPlatform(
                        iOS: "Helvetica",
                        Android: "Roboto",
                        WinPhone: "Segoe"
                    ),
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions = LayoutOptions.Center,
                    YAlign = TextAlignment.Center,
                    XAlign = TextAlignment.Center,
                    LineBreakMode = LineBreakMode.WordWrap
                };
                lblDescricao.SetBinding<PerguntaViewModel>(Label.TextProperty, x => x.Mensagem.Descricao);
				
                var Imagem = new Image
                {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center,
                    Aspect = Aspect.AspectFit,
                };
				
                if (!String.IsNullOrEmpty(this.imagem))
                    Imagem.Source = ImageSource.FromFile(DependencyService.Get<ISaveAndLoadFile>().GetImage(this.imagem));
				
                if (!String.IsNullOrEmpty(this.urlVideo))
                {
                    if (Device.OS == TargetPlatform.iOS)
                    {
                        webView = new WebView();
                        var htmlSource = new HtmlWebViewSource();
                        htmlSource.Html = BuildEmbedUrl(this.urlVideo);
                        webView.Source = htmlSource;
                        webView.HeightRequest = 320;
                        webView.WidthRequest = 270;
                        webView.VerticalOptions = LayoutOptions.Center;
                        webView.HorizontalOptions = LayoutOptions.Center;
                    }
                    else
                    {
                        str = new Uri(this.urlVideo).Segments;
                        App.UrlVideo = this.urlVideo;
				
                        imgThumbVideo = new Image
                        {
                            Source = ImageSource.FromFile(DependencyService.Get<ISaveAndLoadFile>().GetImage(String.Concat(str[2], ".jpg"))),
                            HeightRequest = 200,
                            WidthRequest = 100
                        };
				
                        var imgThumbVideo_Click = new TapGestureRecognizer();
                        imgThumbVideo_Click.Tapped += (object sender, EventArgs e) => this.Navigation.PushModalAsync(new VideoPage());
                        imgThumbVideo.GestureRecognizers.Add(imgThumbVideo_Click);
                    }
                }
				
                var btnCompartilhar = new Button
                {
                    Text = "Compartilhar",
                    Style = Estilos._estiloPadraoButton
                };
                btnCompartilhar.Clicked += async (sender, e) =>
                {
                    try
                    {
                        string link = string.Empty;

                        if (Device.OS == TargetPlatform.Android)
                            link = "https://play.google.com/store/apps/details?id=com.aplicativo.mais&hl=pt_BR";
                        else
                            link = "https://itunes.apple.com/us/app/mais-app/id1028918789?ls=1&mt=8";

                        DependencyService.Get<IShare>().ShareLink(this.enquete.Titulo, string.Empty, link);
                    }
                    catch (Exception ex)
                    {
                        Insights.Report(ex);
                    }
                };

                if (App.Current.Properties.ContainsKey("UsuarioLogado"))
                {
                    var u = App.Current.Properties["UsuarioLogado"] as Usuario;
                    var dbFacebook = new Repositorio<FacebookInfos>();
                    var dadosFacebook = await dbFacebook.ExisteRegistroFacebook();

                    if (dadosFacebook == null || String.IsNullOrEmpty(dadosFacebook.access_token))
                        btnCompartilhar.IsVisible = false;
                }

                StackLayout perguntaLayout;
				
                if (!String.IsNullOrEmpty(this.urlVideo))
                {
                    if (Device.OS == TargetPlatform.Android)
                    {
                        perguntaLayout = new StackLayout
                        {
                            HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2,
                            HorizontalOptions = LayoutOptions.Center,
                            Children = { imgThumbVideo, btnCompartilhar },
                            Padding = 20
                        };
                    }
                    else
                        perguntaLayout = new StackLayout
                        {
                            HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2,
                            HorizontalOptions = LayoutOptions.Center,
                            Children = { webView, btnCompartilhar },
                            Padding = 20
                        };
						
                }
                else if (!String.IsNullOrEmpty(this.imagem))
                {
                    perguntaLayout = new StackLayout
                    {
                        HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2,
                        HorizontalOptions = LayoutOptions.Center,
                        Children = { Imagem, btnCompartilhar },
                        Padding = 20
                    };
                }
                else
                {
                    perguntaLayout = new StackLayout
                    {
                        HeightRequest = Acr.DeviceInfo.DeviceInfo.Hardware.ScreenWidth * 2,
                        HorizontalOptions = LayoutOptions.Center,
                        Children = { btnCompartilhar },
                        Padding = 20
                    };
                }
				
                btnResponder.SetBinding(Button.CommandProperty, "btnGravar_Click");
                                				
                this.mainLayout.Children.Add(lblTitulo);
                this.mainLayout.Children.Add(lblDescricao);
                this.mainLayout.Children.Add(perguntaLayout);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 35
0
 public void AdicionaMensagem(Enquete enquete)
 {
     this.Mensagem = enquete;
 }
Esempio n. 36
0
        public async Task<RetornoGravacaoEnquete> CadastrarNovaEnquete(Enquete enquete)
        {
            using (var client = CallAPI.RetornaClientHttp())
            {
                var enqueteJSON = JsonConvert.SerializeObject(enquete);
                response = await client.PostAsJsonAsync(Constants.uriNovaEnquete, enqueteJSON);

                if (response.IsSuccessStatusCode)
                {
                    var srt = await response.Content.ReadAsStringAsync();
                    var json = JsonConvert.DeserializeObject<RetornoGravacaoEnquete>(srt);
                    return json;
                }
            }

            return null;
        }