private void ProcessMembershipGroupStyle(MembershipGroupStyleModel membershipGroupStyle) { _isEditMode = (membershipGroupStyle != null); MembershipGroupStyle = membershipGroupStyle ?? GetNewMembershipGroupStyle(); MembershipGroupStyle.PropertyChanged += OnMembershipGroupStylePropertyChanged; }
public AddMembershipGroupStyleView(MembershipGroupStyleModel membershipGroupStyle) { InitializeComponent(); if (membershipGroupStyle != null) Header = "Edit Category Group Style"; ViewModel = new AddMembershipGroupStyleViewModel(membershipGroupStyle); DataContext = ViewModel; Owner = Application.Current.MainWindow; }
public AddMembershipGroupStyleViewModel(MembershipGroupStyleModel membershipGroupStyle) { var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve<IDataUnitLocator>(); _adminDataUnit = dataUnitLocator.ResolveDataUnit<IAdminDataUnit>(); SaveCommand = new RelayCommand(SaveCommandExecuted, SaveCommandCanExecute); ExpandCollapseButtonCommand = new RelayCommand(ExpandCollapseButtonCommandExecuted); ProcessMembershipGroupStyle(membershipGroupStyle); }
private MembershipGroupStyleModel GetNewMembershipGroupStyle() { var membershipGroupStyle = new MembershipGroupStyleModel(new MembershipGroupStyle() { ID = Guid.NewGuid() }); return membershipGroupStyle; }
private async void DeleteMembershipGroupStyleCommandExecuted(MembershipGroupStyleModel membershipGroupStyle) { if (membershipGroupStyle == 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 Style has dependencies if (membershipGroupStyle.MembershipGroupStyle.MembershipCategories.Any()) { var sb = new StringBuilder(); sb.AppendLine("Sorry, we can't delete this category style :("); sb.AppendLine("This category style already in use by these categories:"); membershipGroupStyle.MembershipGroupStyle.MembershipCategories.Select(x => x.Name).ForEach(x => sb.AppendLine(string.Format("- {0}", x))); RaisePropertyChanged("DisableParentWindow"); RadWindow.Alert(sb.ToString()); RaisePropertyChanged("EnableParentWindow"); return; } // Delete MembershipGroupStyle _adminDataUnit.MembershipGroupStylesRepository.Delete(membershipGroupStyle.MembershipGroupStyle); await _adminDataUnit.SaveChanges(); MembershipGroupStyles.Remove(membershipGroupStyle); }
private void EditMembershipGroupStyleCommandExecuted(MembershipGroupStyleModel membershipGroupStyle) { RaisePropertyChanged("DisableParentWindow"); var view = new AddMembershipGroupStyleView(membershipGroupStyle); view.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (view.DialogResult != null && view.DialogResult == true) { _adminDataUnit.MembershipGroupStylesRepository.Refresh(); } }