Exemplo n.º 1
0
        private void SendVotation(object type)
        {
            Proposal proposalM = new Proposal();
            bool     res       = false;
            ObservableCollection <Option> lstOpt = new ObservableCollection <Option>();
            Proposal prop = lstProposals.Where(x => x.Checked == true).FirstOrDefault();

            switch (Int32.Parse(type.ToString()))
            {
            case 1:

                foreach (Option item in lstProposalsOptions.Where(x => x.Checked == true))
                {
                    lstOpt.Add(item);
                }

                res = proposalM.ToVoted(User.GetInstance().Email, prop.ContracEthereumProposal, lstOpt);

                if (res)
                {
                    //UserDialogs.Instance.Alert("Voto Registrado Correctamente", "Mensaje", "Aceptar");

                    if (prop.AdvancedSearch == 1)
                    {
                        lstResults = proposalM.PartialResult(prop.ContracEthereumProposal);

                        ((MasterDetailPage)App.Current.MainPage).Detail.Navigation.PushAsync(new ResultPage());
                    }
                    else
                    {
                        UserDialogs.Instance.Alert("Voto Registrado", "Mensaje", "Aceptar");
                    }
                }
                else
                {
                    UserDialogs.Instance.Alert("ERROR al votar!", "Mensaje", "Aceptar");
                }

                break;

            case 2:

                if (RefSelected == "SI")
                {
                    lstProposalsOptions.Where(x => x.Description == "SI").FirstOrDefault().Checked = true;
                }
                else
                {
                    lstProposalsOptions.Where(x => x.Description == "NO").FirstOrDefault().Checked = true;
                }


                foreach (Option item in lstProposalsOptions.Where(x => x.Checked == true))
                {
                    lstOpt.Add(item);
                }


                res = proposalM.ToVoted(User.GetInstance().Email, prop.ContracEthereumProposal, lstOpt);

                if (res)
                {
                    if (prop.AdvancedSearch == 1)
                    {
                        lstResults = proposalM.PartialResult(prop.ContracEthereumProposal);

                        ((MasterDetailPage)App.Current.MainPage).Detail.Navigation.PushAsync(new ResultPage());
                    }
                    else
                    {
                        UserDialogs.Instance.Alert("Voto Registrado", "Mensaje", "Aceptar");
                    }
                }
                else
                {
                    UserDialogs.Instance.Alert("ERROR al votar!", "Mensaje", "Aceptar");
                }


                break;

            case 3:

                foreach (Option item in lstProposalsOptions.Where(x => x.Checked == true))
                {
                    lstOpt.Add(item);
                }

                res = proposalM.ToVoted(User.GetInstance().Email, prop.ContracEthereumProposal, lstOpt);

                if (res)
                {
                    if (prop.AdvancedSearch == 1)
                    {
                        lstResults = proposalM.PartialResult(prop.ContracEthereumProposal);

                        ((MasterDetailPage)App.Current.MainPage).Detail.Navigation.PushAsync(new ResultPage());
                    }
                    else
                    {
                        UserDialogs.Instance.Alert("Voto Registrado", "Mensaje", "Aceptar");
                    }
                }
                else
                {
                    UserDialogs.Instance.Alert("ERROR al votar!", "Mensaje", "Aceptar");
                }

                break;

            default:
                break;
            }
        }