Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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;
        }