async Task OnSubmit() { Login login = new Login { email = this.Email, senha = this.Senha }; var respostaHttp = await ClientHttp.PostAsync("sessions", login); if (respostaHttp.statuscode.Equals(HttpStatusCode.Created)) { try { var loginResponse = ClientHttp.ObterObjeto <LoginResponse>(respostaHttp.content); ClientHttp.AplicarToken(loginResponse.token); App.Current.MainPage = new Home(); } catch (Exception) { throw; } } else { this.response = respostaHttp.message; ReturnMessage(); } }
async Task Register() { if (!senha.Equals(confirmarsenha)) { message = "Senhas divergentes!"; ReturnMessage(); return; } user = new User { username = this.Nome, password = this.Email, email = this.Senha }; var respostaHttp = await ClientHttp.PostAsync("users", user); if (respostaHttp.statuscode.Equals(HttpStatusCode.Created)) { try { message = "Usuário criado com sucesso!"; ReturnMessage(); App.Current.MainPage = new Home(); } catch (Exception ex) { message = ex.Message; ReturnMessage(); return; } } else { message = respostaHttp.message; ReturnMessage(); return; } }