Esempio n. 1
0
        private async void Sair_Click(object sender, RoutedEventArgs e)
        {
            var result = await ForgeShow.Dialog().For(new Confirmation("Realmente deseja sair?", "SAIR"));

            if (result.Action.ToString() == "positive")
            {
                Process.Start(Application.ResourceAssembly.Location);
                Environment.Exit(0);
            }
        }
Esempio n. 2
0
        private async void Usuario_Click(object sender, RoutedEventArgs e)
        {
            Menu.IsOpen = false;
            if (AppViewModel.Instance.Dialog.IsOpen)
            {
                return;
            }

            var result = await ForgeShow.Dialog().For(new Prompt <string> {
                Title = "SELECIONE O USUARIO", Value = "INSIRA O CPF AQUI"
            });

            if (result.Action == null)
            {
                return;
            }

            if (result.Action.ToString() == "positive")
            {
                var usuarios = AppViewModel.Instance.Db.GetCollection <Usuario>("usuarios").FindAll();
                if (usuarios.Where(p => p.Cpf == result.Model.Value).Count() > 0)
                {
                    var usuario = usuarios.Where(p => p.Cpf == result.Model.Value).First();
                    if (!usuario.Bloqueado)
                    {
                        if (AppViewModel.Instance.EleicaoAtual.Votos.Any(u => u.Usuario.Cpf == usuario.Cpf))
                        {
                            await ForgeShow.Dialog().For(new Alert("Usuario selecionado já votou!", "ERRO"));

                            return;
                        }
                        else
                        {
                            AppViewModel.Instance.UsuarioAtual = usuario;
                            AppViewModel.Instance.Inicio       = Visibility.Hidden;
                            AppViewModel.Instance.Finalizado   = Visibility.Hidden;
                        }
                    }
                    else
                    {
                        await ForgeShow.Dialog().For(new Alert("Usuario bloqueado!", "ERRO"));

                        return;
                    }
                }
                else
                {
                    await ForgeShow.Dialog().For(new Alert("Usuario não encontrado!", "ERRO"));
                }
            }
        }