Esempio n. 1
0
 public TeacherListViewModel(IDialogService dialogService, ITeacherService teacherService) : base(dialogService)
 {
     TeacherService             = teacherService;
     TeacherEvaluationViewModel = new TeacherEvaluationViewModel(dialogService, teacherService);
     TeacherDetailsViewModel    = new TeacherDetailsViewModel(dialogService, teacherService);
     TArgs = new TeacherDetailsArgs();
     EArgs = new TeacherEvaluationArgs();
 }
        public async Task LoadAsync(TeacherDetailsArgs args)
        {
            ViewModelArgs = args ?? TeacherDetailsArgs.CreateDefault();

            if (ViewModelArgs.IsNew)
            {
                Item = new TeacherModel();
            }
            else
            {
                try
                {
                    var item = await TeacherService.GetTeacherAsync(ViewModelArgs.TeacherId);

                    Item = item ?? new TeacherModel {
                        TeacherId = ViewModelArgs.TeacherId, IsEmpty = true
                    };
                }
                catch (Exception e)
                {
                    await DialogService.ShowAsync("载入失败", e.InnerException?.Message ?? e.Message);
                }
            }
        }