private async void SyncCommandExecuteAsync() { IsBusy = true; //Envía las encuestas var allSurveys = await localDbService.GetAllSurveysAsync(); if (allSurveys != null && allSurveys.Any()) { await webApiService.SaveSurveysAsync(allSurveys); await localDbService.DeleteAllSurveysAsync(); } //Consulta los equipos var allTeams = await webApiService.GetTeamsAsync(); if (allTeams != null && allTeams.Any()) { await localDbService.DeleteAllTeamsAsync(); await localDbService.InsertTeamsAsync(allTeams); } Application.Current.Properties["lastSync"] = DateTime.Now; await Application.Current.SavePropertiesAsync(); Status = $"Se enviarón {allSurveys.Count()} encuestas y se obtuvierón {allTeams.Count()} equipos"; IsBusy = false; }
private async Task LoadSurveysAsync() { var allTeams = await localDbService.GetAllTeamsAsync(); var allSurveys = await localDbService.GetAllSurveysAsync(); if (allSurveys != null) { Surveys = new ObservableCollection <SurveyViewModel>(allSurveys.Select(s => SurveyViewModel.GetViewModelFromEntity(s, allTeams))); } RaisePropertyChanged(nameof(IsEmpty)); }
private async void SyncCommandExecute() { IsBusy = true; int teamsCount = 0; int surveysCount = 0; /* Envía las encuestas */ var allSurveys = await localDbService.GetAllSurveysAsync(); if (allSurveys != null && allSurveys.Any()) { surveysCount = allSurveys.Count(); await webApiService.SaveSurveysAsync(allSurveys); await localDbService.DeleteAllSurveysAsync(); } /* Consulta los equipos */ var allTeams = await webApiService.GetTeamsAsync(); if (allTeams != null && allTeams.Any()) { teamsCount = allTeams.Count(); await localDbService.DeleteAllTeamsAsync(); await localDbService.InsertTeamsAsync(allTeams); } Application.Current.Properties["lastSync"] = DateTime.Now; await Application.Current.SavePropertiesAsync(); if (allSurveys != null && allTeams != null) { Status = $"Se enviaron {surveysCount} encuestas y se obtuvieron {teamsCount} equipos"; } else { Status = $"Error en la sincronización"; } IsBusy = false; }