Пример #1
0
        public static async Task <bool> ShowAsync(TrainingWeek trainingWeek, BaseViewModel parent = null)
        {
            bool result = false;

            if (trainingWeek != null)
            {
                var viewModel = new TrainingWeekViewModel();
                viewModel.TrainingWeek = trainingWeek;
                result = await ShowModalViewModelAsync(viewModel, parent);
            }
            return(result);
        }
Пример #2
0
        private async Task ViewTrainingWeekActionAsync(BindingTrainingWeek bindingTrainingWeek)
        {
            try
            {
                if (bindingTrainingWeek != null && bindingTrainingWeek.TrainingWeek != null)
                {
                    TrainingWeek trainingWeek         = null;
                    var          trainingWeekScenario = new TrainingWeekScenario()
                    {
                        ManageTrainingDay = true
                    };
                    try
                    {
                        //load server data (only header)
                        trainingWeek = await TrainingWeekWebService.GetTrainingWeekAsync(bindingTrainingWeek.TrainingWeek, false);

                        if (trainingWeek != null)
                        {
                            if (trainingWeek.ModificationDate != bindingTrainingWeek.TrainingWeek.ModificationDate)
                            {
                                //load server data (full)
                                trainingWeek = await TrainingWeekWebService.GetTrainingWeekAsync(bindingTrainingWeek.TrainingWeek, true);

                                if (trainingWeek != null)
                                {
                                    //Save data on local database
                                    _trainingWeekService.UpdateTrainingWeek(trainingWeek, trainingWeekScenario);
                                }
                            }
                            else
                            {
                                trainingWeek = null; // force reload local data
                            }
                        }
                    }
                    catch
                    {
                        // Unable to retreive local data
                        ILogger.Instance.Info("Unable to retreive TrainingWeek on server");
                        trainingWeek = null;
                    }

                    if (trainingWeek == null)
                    { //load local data
                        trainingWeek = _trainingWeekService.GetTrainingWeek(bindingTrainingWeek.TrainingWeek, trainingWeekScenario);
                    }

                    if (trainingWeek != null)
                    {
                        //Display view model
                        if (await TrainingWeekViewModel.ShowAsync(trainingWeek, this))
                        {
                            //Refresh data
                            RetreiveLocalData();
                            SynchronizeData();
                        }
                    }
                }
            }
            catch (Exception except)
            {
                await _userDialog.AlertAsync(except.Message, Translation.Get(TRS.ERROR), Translation.Get(TRS.OK));
            }
        }