コード例 #1
0
 public AddMembershipCategoryView(MembershipCategoryModel membershipCategory)
 {
     InitializeComponent();
     Owner = Application.Current.MainWindow;
     if (membershipCategory != null)
         Header = "Edit Category";
     ViewModel = new AddMembershipCategoryViewModel(membershipCategory);
     DataContext = ViewModel;
     Loaded += OnViewLoaded;
 }
コード例 #2
0
 private MembershipCategoryModel GetNewMembershipCategory()
 {
     var membershipCategory = new MembershipCategoryModel(new MembershipCategory()
     {
         ID = Guid.NewGuid(),
         CurrentCategory = true,
     });
     return membershipCategory;
 }
コード例 #3
0
        private void ProcessMembershipCategory(MembershipCategoryModel membershipCategory)
        {
            _isEditMode = (membershipCategory != null);

            MembershipCategory = membershipCategory ?? GetNewMembershipCategory();

            if (!_isEditMode)
            {
                MembershipCategory.MembershipFullPaymentComponent = new MembershipFullPaymentCostModel(new MembershipFullPaymentComponent()
                {
                    MembershipCategory = MembershipCategory.MembershipCategory,
                    ID = MembershipCategory.MembershipCategory.ID
                });
                MembershipCategory.MembershipMonthlyPaymentUpFrontCost = new MembershipMonthlyPaymentUpFrontCostModel(new MembershipMonthlyPaymentUpFrontCost()
                {
                    MembershipCategory = MembershipCategory.MembershipCategory,
                    ID = MembershipCategory.MembershipCategory.ID
                });
                MembershipCategory.MembershipMonthlyPaymentOngoingCost = new MembershipMonthlyPaymentOngoingCostModel(new MembershipMonthlyPaymentOngoingCost()
                {
                    MembershipCategory = MembershipCategory.MembershipCategory,
                    ID = MembershipCategory.MembershipCategory.ID
                });
                MembershipCategory.MembershipCategoryGroupDefault = new MembershipCategoryGroupDefaultModel(new MembershipCategoryGroupDefault()
                    {
                        MembershipCategory = MembershipCategory.MembershipCategory,
                        ID = MembershipCategory.MembershipCategory.ID,
                        MembershipCategoryGroupDefaultEPOS = new MembershipCategoryGroupDefaultEPOS()
                        {
                            AllowedClubCard = true
                        }
                    });
            }
            MembershipCategory.PropertyChanged += OnMembershipCategoryPropertyChanged;
        }
コード例 #4
0
        public AddMembershipCategoryViewModel(MembershipCategoryModel membershipCategory)
        {
            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve<IDataUnitLocator>();
            _adminDataUnit = dataUnitLocator.ResolveDataUnit<IAdminDataUnit>();

            SaveCommand = new RelayCommand(SaveCommandExecuted, SaveCommandCanExecute);

            ProcessMembershipCategory(membershipCategory);
        }
コード例 #5
0
        private void EditMembershipCategoryCommandExecuted(MembershipCategoryModel membershipCategory)
        {
            RaisePropertyChanged("DisableParentWindow");

            var view = new AddMembershipCategoryView(membershipCategory);
            view.ShowDialog();

            RaisePropertyChanged("EnableParentWindow");

            if (view.DialogResult != null && view.DialogResult == true)
            {
                _membershipDataUnit.MembershipCategoriesRepository.Refresh();
                _adminDataUnit.MembershipCategoriesRepository.RefreshCategoryGroupsWithItsTabs();
                RefreshMembershipCategories();
                SelectedMembershipCategory = membershipCategory;
            }
        }
コード例 #6
0
        private async void DeleteMembershipCategoryCommandExecuted(MembershipCategoryModel membershipCategory)
        {
            if (membershipCategory == 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;

            // Delete MembershipCategoryGroupDefaultEPOS
            _adminDataUnit.MembershipCategoryGroupDefaultEPOSRepository.Delete(membershipCategory.MembershipCategoryGroupDefault.MembershipCategoryGroupDefault.MembershipCategoryGroupDefaultEPOS);

            // Delete MembershipCategoryGroupDefaults
            //var categoryGroupDefaults = await _adminDataUnit.MembershipCategoryGroupDefaultsRepository.GetAllAsync(categoryGroupDefault => categoryGroupDefault.ID == membershipCategory.MembershipCategory.ID);
            _adminDataUnit.MembershipCategoryGroupDefaultsRepository.Delete(membershipCategory.MembershipCategoryGroupDefault.MembershipCategoryGroupDefault);

            // Delete MembershipFullPaymentCosts
            //var categoryFullPaymentCosts = await _adminDataUnit.MembershipFullPaymentCostsRepository.GetAllAsync(fullPaymentCost => fullPaymentCost.ID == membershipCategory.MembershipCategory.ID);
            _adminDataUnit.MembershipFullPaymentCostsRepository.Delete(membershipCategory.MembershipFullPaymentComponent.MembershipFullPaymentComponent);

            // Delete MembershipMontlyPaymentUpFrontCosts
            //var categoryMonthlytPaymentUpFrontCosts = await _adminDataUnit.MembershipMonthlyPaymentUpFrontCostsRepository.GetAllAsync(fullPaymentCost => fullPaymentCost.ID == membershipCategory.MembershipCategory.ID);
            _adminDataUnit.MembershipMonthlyPaymentUpFrontCostsRepository.Delete(membershipCategory.MembershipMonthlyPaymentUpFrontCost.MembershipMonthlyPaymentUpFrontCost);

            // Delete MembershipMontlyPaymentOnGoingCosts
            //var categoryMonthlytPaymentOngoingCosts = await _adminDataUnit.MembershipMonthlyPaymentOngoingCostsRepository.GetAllAsync(fullPaymentCost => fullPaymentCost.ID == membershipCategory.MembershipCategory.ID);
            _adminDataUnit.MembershipMonthlyPaymentOngoingCostsRepository.Delete(membershipCategory.MembershipMonthlyPaymentOngoingCost.MembershipMonthlyPaymentOngoingCost);

            // Check if Category has dependencies
            if (membershipCategory.MembershipCategory.MembershipLinkTypes.Any() || membershipCategory.MembershipCategory.MembershipLinkTypes1.Any())
            {
                var sb = new StringBuilder();

                sb.AppendLine("Sorry, we can't delete this category :(");
                sb.AppendLine("This category is being used in link types");

                RaisePropertyChanged("DisableParentWindow");

                RadWindow.Alert(sb.ToString());

                RaisePropertyChanged("EnableParentWindow");

                return;
            }

            // Delete MembershipCategory
            _adminDataUnit.MembershipCategoriesRepository.Delete(membershipCategory.MembershipCategory);

            await _adminDataUnit.SaveChanges();

            MembershipCategories.Remove(membershipCategory);
        }