private void ProcessMembershipGroup(MembershipGroupModel membershipGroup) { _isEditMode = (membershipGroup != null); MembershipGroup = membershipGroup ?? GetNewMembershipGroup(); MembershipGroup.PropertyChanged += OnMembershipGroupPropertyChanged; }
public AddMembershipGroupViewModel(MembershipGroupModel membershipGroup) { var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve <IDataUnitLocator>(); _adminDataUnit = dataUnitLocator.ResolveDataUnit <IAdminDataUnit>(); SaveCommand = new RelayCommand(SaveCommandExecuted, SaveCommandCanExecute); ProcessMembershipGroup(membershipGroup); }
public AddMembershipGroupView(MembershipGroupModel membershipGroup) { InitializeComponent(); if (membershipGroup != null) { Header = "Edit Category Group"; } ViewModel = new AddMembershipGroupViewModel(membershipGroup); DataContext = ViewModel; Owner = Application.Current.MainWindow; }
private MembershipGroupModel GetNewMembershipGroup() { var membershipGroup = new MembershipGroupModel(new MembershipGroup() { ID = Guid.NewGuid(), MembershipGroupEPOS = new MembershipGroupEPOS() { AllowedClubCard = true } }); return(membershipGroup); }
private async void DeleteMembershipGroupCommandExecuted(MembershipGroupModel membershipGroup) { if (membershipGroup == null) { return; } bool? dialogResult = null; string confirmText = Properties.Resources.MESSAGE_ASK_BEFORE_DELETING_ITEM; RaisePropertyChanged("DisableParentWindow"); RadWindow.Confirm(confirmText, (sender, args) => { dialogResult = args.DialogResult; }); RaisePropertyChanged("EnableParentWindow"); if (dialogResult != true) { return; } // Check if Category Group has dependencies if (membershipGroup.MembershipGroup.MembershipCategories.Any()) { var sb = new StringBuilder(); sb.AppendLine("Sorry, we can't delete this category group :("); sb.AppendLine("This category group already in use by these categories:"); membershipGroup.MembershipGroup.MembershipCategories.Select(x => x.Name).ForEach(x => sb.AppendLine(string.Format("- {0}", x))); RaisePropertyChanged("DisableParentWindow"); RadWindow.Alert(sb.ToString()); RaisePropertyChanged("EnableParentWindow"); return; } // Delete MembershipGroupEPOS _adminDataUnit.MembershipGroupEPOSRepository.Delete(membershipGroup.MembershipGroup.MembershipGroupEPOS); // Delete MembershipGroup _adminDataUnit.MembershipGroupsRepository.Delete(membershipGroup.MembershipGroup); await _adminDataUnit.SaveChanges(); MembershipGroups.Remove(membershipGroup); }
private void EditMembershipGroupCommandExecuted(MembershipGroupModel membershipGroup) { RaisePropertyChanged("DisableParentWindow"); var view = new AddMembershipGroupView(membershipGroup); view.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (view.DialogResult != null && view.DialogResult == true) { _adminDataUnit.MembershipGroupsRepository.Refresh(); RefreshMembershipGroups(); } }