Exemplo n.º 1
0
        async Task SalvarJogo()
        {
            if (IsBusy)
            {
                return;
            }

            if (string.IsNullOrEmpty(JogoNome))
            {
                await Application.Current.MainPage.DisplayAlert("FALTA INFORMAÇÃO OBRIGATÓRIA",
                                                                "Informe o nome do jogo!",
                                                                "Ok");

                return;
            }

            if (string.IsNullOrEmpty(JogoLogin))
            {
                await Application.Current.MainPage.DisplayAlert("FALTA INFORMAÇÃO OBRIGATÓRIA",
                                                                "Informe o Usuário do jogo(Login)!Não cadastre a senha do jogo, somente o usuário usado para logar.",
                                                                "Ok");

                return;
            }

            if (this._Jogo == null)
            {
                if (JogoDAO.GetJogo(JogoNome, JogoLogin) != null)
                {
                    await Application.Current.MainPage.DisplayAlert("ATENÇÃO",
                                                                    "Este Nome de Jogo ja esta cadastrado com esse Usuário do jogo!",
                                                                    "Ok");

                    return;
                }
            }

            IsBusy = true;


            Jogo jogo = new Jogo()
            {
                JOG_ID                  = (_Jogo == null ? 0 : _Jogo.JOG_ID),
                JOG_NOME                = JogoNome,
                JOG_CATEGORIACODIGO     = (CategoriaSelecionada != null ? CategoriaSelecionada.CAT_CODIGO : 0),
                JOG_CATEGORIANOME       = (CategoriaSelecionada != null ? CategoriaSelecionada.CAT_NOME : string.Empty),
                JOG_LOGIN               = JogoLogin,
                JOG_EMAILCADASTRADO     = JogoEmail,
                JOG_PERSONAGEMPRINCIPAL = JogoPersonagem,
                JOG_BUILD               = JogoBuild,
                JOG_NIVEL               = JogoNivel,
                JOG_URLSITE             = JogoURLSite,
                JOG_URLBUILD            = JogoURLBuild
            };

            try
            {
                if (JogoDAO.Atualizar(jogo))
                {
                    await Application.Current.MainPage.DisplayAlert("SUCESSO",
                                                                    "Jogo cadastrado com sucesso!",
                                                                    "Ok");

                    await Shell.Current.Navigation.PopModalAsync();
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("ATENÇÃO",
                                                                    "Não foi possível cadastrar o Jogo!",
                                                                    "Ok");
                }
            }
            catch (Exception e)
            {
                Debug.Write(e);
            }

            IsBusy = false;
        }