private async void Login() { if (string.IsNullOrEmpty(this.Email)) { await dialogoSerices.ShowMensaje("Error", "Tienes que ingresar tu E-mail"); return; } if (string.IsNullOrEmpty(this.Password)) { await dialogoSerices.ShowMensaje("Error", "Tienes que ingresar tu contraseña"); return; } IsRunning = true; IsEnabled = false; var connection = await apiServicio.CheckConnection(); if (!connection.IsSuccess) { IsEnabled = true; IsEnabled = false; await dialogoSerices.ShowMensaje("Error", connection.Message); return; } var Responce = await apiServicio.GetToken("http://mecanicappapi.azurewebsites.net", Email, Password); if (Responce == null || string.IsNullOrEmpty(Responce.Access_token)) { IsEnabled = true; IsRunning = false; await dialogoSerices.ShowMensaje("Error", Responce.ErrorDescription); return; } var mainViewModel = MainViewModel.Getinstancia(); mainViewModel.Token = Responce; // await dialogoSerices.ShowMensaje("taran", "Bienvenido"); MainViewModel.Getinstancia().Escoger = new EscogerViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new EscogerPage()); return; }
async void LoadingEmpresaInicioViewModel() { var connection = await apiServicio.CheckConnection(); if (!connection.IsSuccess) { await dialogoServices.ShowMensaje("Error", connection.Message); return; } var mainViewModel = MainViewModel.Getinstancia(); var Responce = await apiServicio.GetList <CategoryMap>("http://mecanicappapi.azurewebsites.net", "/api", "/Categories", mainViewModel.Token.Token_type, mainViewModel.Token.Access_token); if (!Responce.IsSuccess) { await dialogoServices.ShowMensaje("Error", connection.Message); return; } var categories = (List <CategoryMap>)Responce.Result; CategoryMaps = new ObservableCollection <CategoryMap>(categories.OrderBy(c => c.Descripcion)); }