private async void OnOkTapped(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrEmpty(edtObs.Text))
            {
                await App.AppCurrent.MainPage.DisplayAlert(AppResource.alertInvalidFields, AppResource.txtFillNameMessage, AppResource.textOk);

                return;
            }

            Acr.UserDialogs.UserDialogs.Instance.ShowLoading(AppResource.alertLoading);
            ApiService service = new ApiService();

            try
            {
                ContatoCommand contato = new ContatoCommand();
                contato.UsuarioId = Helpers.Settings.DisplayUserId;
                contato.Message   = edtObs.Text;

                var json   = JsonConvert.SerializeObject(contato);
                var result = await service.PostAsync(json, "info/contato");

                Acr.UserDialogs.UserDialogs.Instance.Toast(AppResource.alertMEessageSentSucess);


                edtObs.Text = "";
            }
            catch (Exception ex)
            {
                this.DisplayAlert(MocoApp.Resources.AppResource.alertAlert, ex.Message, AppResource.textOk);
            }
            finally
            {
                Acr.UserDialogs.UserDialogs.Instance.HideLoading();
            }
        }
Exemple #2
0
        public bool EnviarContatoPorEmail(ContatoCommand contato)
        {
            try
            {
                EmailHelper.EnviarEmail(
                    EmailHelper.FormatarTemplateDeContato(contato.Nome, contato.Email, contato.Celular, contato.Mensagem),
                    true);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public Task <HttpResponseMessage> Post([FromBody] dynamic body)
        {
            var command = new ContatoCommand(
                nome: (string)body.nome,
                email: (string)body.email,
                celular: (string)body.celular,
                mensagem: (string)body.mensagem
                );

            var FoiEnviado = !_usuarioApp.EnviarContatoPorEmail(command);

            if (!FoiEnviado)
            {
                return(CreateResponse(HttpStatusCode.InternalServerError, FoiEnviado));
            }

            return(CreateResponse(HttpStatusCode.OK, FoiEnviado));
        }