private async Task LoadMusculeGroupsLookupAsync()
        {
            MusculeGroups.Clear();
            //MusculeGroups.Add(new NullLookupItem { DisplayMember = " - " });
            var lookup = await _musculeGroupLookupDataService.GetMusculeGroupLookupAsync();

            foreach (var lookupItem in lookup)
            {
                MusculeGroups.Add(lookupItem);
            }
        }
        private void OnAddExecute()
        {
            var wrapper = new MusculeGroupWrapper(new MusculeGroup());

            wrapper.PropertyChanged += Wrapper_PropertyChanged;
            _musculeGroupRepository.Add(wrapper.Model);
            MusculeGroups.Add(wrapper);

            //trigger the validation
            wrapper.Name = "";
        }
        public async override Task LoadAsync(int id)
        {
            Id = id;
            foreach (var wrapper in MusculeGroups)
            {
                wrapper.PropertyChanged -= Wrapper_PropertyChanged;
            }

            MusculeGroups.Clear();
            var musculeGroups = await _musculeGroupRepository.GetAllAsync();

            foreach (var model in musculeGroups)
            {
                var wrapper = new MusculeGroupWrapper(model);
                wrapper.PropertyChanged += Wrapper_PropertyChanged;
                MusculeGroups.Add(wrapper);
            }
        }
        private async void OnRemoveExecute()
        {
            var isReferenced = await _musculeGroupRepository.IsReferencedByExerciseAsync(SelectedMusculeGroup.Id);

            if (isReferenced)
            {
                await MessageDialogService.ShowInfoDialogAsync($"Мускулната {SelectedMusculeGroup.Name} не може да бъде премахната" +
                                                               $", понеже се съдържа в поне едно упражнение.");

                return;
            }

            SelectedMusculeGroup.PropertyChanged -= Wrapper_PropertyChanged;
            _musculeGroupRepository.Remove(SelectedMusculeGroup.Model);
            MusculeGroups.Remove(SelectedMusculeGroup);
            SelectedMusculeGroup = null;
            HasChanges           = _musculeGroupRepository.HasChanges();
            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
        }
 protected override bool OnSaveCanExecute()
 {
     return(HasChanges && MusculeGroups.All(m => !m.HasErrors));
 }