Ejemplo n.º 1
0
        protected override void LoadAllCommandCompletedHelper()
        {
            try
            {
                dispatcher.BeginInvoke
                    (() =>
                {
                    if (Utility.FaultExist(service.Fault))
                    {
                        return;
                    }

                    Models = new PagedCollectionView(service.Models);
                    if (service.Models != null && service.Models.Count > 0)
                    {
                        RecordCount = RecordCountLabel + service.Models.Count;
                        Models.MoveCurrentTo(null);
                        Models.CurrentChanged += (s, e) =>
                        {
                            Model = Models.CurrentItem as StaffLevel;
                            if (Model != null)
                            {
                                if (JobLevels != null)
                                {
                                    ObservableCollection <Level> levels = (ObservableCollection <Level>)JobLevels.SourceCollection;
                                    Level level = levels.Where(l => l.Id == Model.Level.Id).SingleOrDefault();
                                    JobLevels.MoveCurrentTo(level);
                                }

                                if (Staffs != null)
                                {
                                    ObservableCollection <Infrastructure.MangoService.Staff> staffs = (ObservableCollection <Infrastructure.MangoService.Staff>)Staffs.SourceCollection;
                                    Infrastructure.MangoService.Staff staff = staffs.Where(l => l.Id == Model.Staff.Id).SingleOrDefault();
                                    Staffs.MoveCurrentTo(staff);
                                }
                            }

                            UpdateViewState(Edit.Mode.Editing);
                            CanSaveItem = false;
                        };
                    }
                    else
                    {
                        RecordCount = RecordCountLabel + 0;
                    }
                });
            }
            catch (Exception ex)
            {
                Utility.DisplayMessage(ex.Message);
            }
        }