private void ProcessMembershipGroupAge(MembershipGroupAgeModel membershipGroupAge)
        {
            _isEditMode = (membershipGroupAge != null);

            MembershipGroupAge = membershipGroupAge ?? GetNewMembershipGroupAge();

            MembershipGroupAge.PropertyChanged += OnMembershipGroupAgePropertyChanged;
        }
 public AddMembershipGroupAgeView(MembershipGroupAgeModel membershipGroupAge)
 {
     InitializeComponent();
     if (membershipGroupAge != null)
         Header = "Edit Category Group Age";
     ViewModel = new AddMembershipGroupAgeViewModel(membershipGroupAge);
     DataContext = ViewModel;
     Owner = Application.Current.MainWindow;
 }
        public AddMembershipGroupAgeViewModel(MembershipGroupAgeModel membershipGroupAge)
        {
            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve<IDataUnitLocator>();
            _adminDataUnit = dataUnitLocator.ResolveDataUnit<IAdminDataUnit>();

            SaveCommand = new RelayCommand(SaveCommandExecuted, SaveCommandCanExecute);
            ExpandCollapseButtonCommand = new RelayCommand(ExpandCollapseButtonCommandExecuted);

            ProcessMembershipGroupAge(membershipGroupAge);
        }
 private MembershipGroupAgeModel GetNewMembershipGroupAge()
 {
     var membershipGroupAge = new MembershipGroupAgeModel(new MembershipGroupAge()
     {
         ID = Guid.NewGuid()
     });
     return membershipGroupAge;
 }
Exemplo n.º 5
0
        private async void DeleteMembershipGroupAgeCommandExecuted(MembershipGroupAgeModel membershipGroupAge)
        {
            if (membershipGroupAge == 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 Age has dependencies
            if (membershipGroupAge.MembershipGroupAge.MembershipCategories.Any())
            {
                var sb = new StringBuilder();

                sb.AppendLine("Sorry, we can't delete this category age :(");
                sb.AppendLine("This category age already in use by these categories:");

                membershipGroupAge.MembershipGroupAge.MembershipCategories.Select(x => x.Name).ForEach(x => sb.AppendLine(string.Format("- {0}", x)));

                RaisePropertyChanged("DisableParentWindow");

                RadWindow.Alert(sb.ToString());

                RaisePropertyChanged("EnableParentWindow");

                return;
            }

            // Delete MembershipGroupAge
            _adminDataUnit.MembershipGroupAgesRepository.Delete(membershipGroupAge.MembershipGroupAge);

            await _adminDataUnit.SaveChanges();

            MembershipGroupAges.Remove(membershipGroupAge);
        }
Exemplo n.º 6
0
        private void EditMembershipGroupAgeCommandExecuted(MembershipGroupAgeModel membershipGroupAge)
        {
            RaisePropertyChanged("DisableParentWindow");

            var view = new AddMembershipGroupAgeView(membershipGroupAge);
            view.ShowDialog();

            RaisePropertyChanged("EnableParentWindow");

            if (view.DialogResult != null && view.DialogResult == true)
            {
                _adminDataUnit.MembershipGroupAgesRepository.Refresh();
            }
        }