public async Task Login() { stopwatch.Reset(); try { IsBusy = true; if (HasInternetConnection) { if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(Password)) { MessagingCenter.Send <string, string>(MessagingCenterEvents.Subscriber, MessagingCenterEvents.AlertError, Messages.Login.InvalidCredentials); IsBusy = false; return; } if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password)) { stopwatch.Start(); _userToken = await _apiService.CheckApiCredentialsAsync(UserName, Password); stopwatch.Stop(); if (_userToken != null) { // qua andró a stampare un popup in caso di lavorazione rimaste pendenti. await FinishLoginProcess(); } else { IsBusy = false; return; } } } else { MessagingCenter.Send <string, string>(MessagingCenterEvents.Subscriber, MessagingCenterEvents.AlertError, Messages.NoInternetConnection); } IsBusy = false; } catch (Exception ecc) { Log.Error("AppOfficina", ecc.Message); IsBusy = false; } }