public StandingOrderDetailsViewModel(ApplicationViewModel application, Action <StandingOrderEntityData> onSave, Action <StandingOrderDetailsViewModel> onCancel) { _application = application; SaveCommand = new CommandViewModel(() => onSave(CreateStandingOrderEntityData())); CancelCommand = new CommandViewModel(() => onCancel(this)); PaymentsProperty = new SingleValuedProperty <int> { Value = 1 }; ValueProperty = new SingleValuedProperty <double>(); IsEndingTransactionProperty = new SingleValuedProperty <bool>(); MonthPeriods = new EnumeratedSingleValuedProperty <MonthPeriod>(); Categories = new EnumeratedSingleValuedProperty <CategoryViewModel>(); FirstBookDateProperty = new SingleValuedProperty <DateTime>(); DescriptionProperty = new SingleValuedProperty <string>(); RequestKind = new EnumeratedSingleValuedProperty <RequestKind>(); IsEndingTransactionProperty.OnValueChanged += OnIsEndingTransactionPropertyChanged; MonthPeriods.OnValueChanged += OnMonthPeriodsPropertyChanged; PaymentsProperty.OnValueChanged += OnPaymentsPropertyChanged; RequestKind.OnValueChanged += RequestKindOnOnValueChanged; ValueProperty.OnIsValidChanged += ValuePropertyOnOnIsValidChanged; ValueProperty.OnValueChanged += ValuePropertyOnOnValueChanged; ValueProperty.Validate = ValidateValueProperty; foreach (MonthPeriod value in Enum.GetValues(typeof(MonthPeriod))) { MonthPeriods.AddValue(value); } var allCategoryViewModels = application.Repository.QueryAllCategories().Select(c => new CategoryViewModel(application, c.PersistentId)).ToList(); allCategoryViewModels.ForEach(a => a.Refresh()); Categories.SetRange(allCategoryViewModels.OrderBy(c => c.Name)); FirstBookDateProperty.Value = application.ApplicationContext.Now.Date; RequestKind.SetRange(Enum.GetValues(typeof(RequestKind)).Cast <RequestKind>()); RequestKind.Value = RequestManagement.RequestKind.Expenditure; UpdateCommandStates(); UpdateCaption(); }
public StandingOrderDetailsViewModel(ApplicationViewModel application, Action<StandingOrderEntityData> onSave, Action<StandingOrderDetailsViewModel> onCancel) { _application = application; SaveCommand = new CommandViewModel(() => onSave(CreateStandingOrderEntityData())); CancelCommand = new CommandViewModel(() => onCancel(this)); PaymentsProperty = new SingleValuedProperty<int> { Value = 1 }; ValueProperty = new SingleValuedProperty<double>(); IsEndingTransactionProperty = new SingleValuedProperty<bool>(); MonthPeriods = new EnumeratedSingleValuedProperty<MonthPeriod>(); Categories = new EnumeratedSingleValuedProperty<CategoryViewModel>(); FirstBookDateProperty = new SingleValuedProperty<DateTime>(); DescriptionProperty = new SingleValuedProperty<string>(); RequestKind = new EnumeratedSingleValuedProperty<RequestKind>(); IsEndingTransactionProperty.OnValueChanged += OnIsEndingTransactionPropertyChanged; MonthPeriods.OnValueChanged += OnMonthPeriodsPropertyChanged; PaymentsProperty.OnValueChanged += OnPaymentsPropertyChanged; RequestKind.OnValueChanged += RequestKindOnOnValueChanged; ValueProperty.OnIsValidChanged += ValuePropertyOnOnIsValidChanged; ValueProperty.OnValueChanged += ValuePropertyOnOnValueChanged; ValueProperty.Validate = ValidateValueProperty; foreach (MonthPeriod value in Enum.GetValues(typeof(MonthPeriod))) { MonthPeriods.AddValue(value); } var allCategoryViewModels = application.Repository.QueryAllCategories().Select(c => new CategoryViewModel(application, c.PersistentId)).ToList(); allCategoryViewModels.ForEach(a => a.Refresh()); Categories.SetRange(allCategoryViewModels.OrderBy(c => c.Name)); FirstBookDateProperty.Value = application.ApplicationContext.Now.Date; RequestKind.SetRange(Enum.GetValues(typeof(RequestKind)).Cast<RequestKind>()); RequestKind.Value = RequestManagement.RequestKind.Expenditure; UpdateCommandStates(); UpdateCaption(); }
private void InitializeViewModel(ApplicationViewModel application, int year, int month, string selectedCategoryId, Action <RequestDialogViewModel> onOk) { _onOk = onOk; Categories = new EnumeratedSingleValuedProperty <CategoryViewModel>(); DescriptionProperty = new SingleValuedProperty <string>(); ValueProperty = new SingleValuedProperty <double>(); DateProperty = new SingleValuedProperty <DateTime>(); CreateRequestCommand = new CommandViewModel(OnCreateRequestCommand); RequestKind = new EnumeratedSingleValuedProperty <RequestKind>(); DateProperty.OnValueChanged += DatePropertyOnOnValueChanged; RequestKind.OnValueChanged += RequestKindOnOnValueChanged; ValueProperty.Validate = ValidateValueProperty; ValueProperty.OnIsValidChanged += ValuePropertyOnOnIsValidChanged; ValueProperty.OnValueChanged += ValuePropertyOnOnValueChanged; FirstPossibleDate = new DateTime(year, month, 1); LastPossibleDate = new DateTime(year, month, DateTime.DaysInMonth(year, month)); RequestKind.SetRange(Enum.GetValues(typeof(RequestKind)).Cast <RequestKind>()); RequestKind.Value = RequestManagement.RequestKind.Expenditure; var categories = application.Repository.QueryAllCategories() .Select(c => new CategoryViewModel(application, c.PersistentId)) .ToList(); categories.ForEach(c => c.Refresh()); Categories.SetRange(categories.OrderBy(c => c.Name)); if (!string.IsNullOrEmpty(selectedCategoryId)) { Categories.Value = Categories.SelectableValues.Single(c => c.EntityId == selectedCategoryId); } UpdateLocalizedProperties(); UpdateCommandStates(); }
private void InitializeViewModel(ApplicationViewModel application, int year, int month, string selectedCategoryId, Action<RequestDialogViewModel> onOk) { _onOk = onOk; Categories = new EnumeratedSingleValuedProperty<CategoryViewModel>(); DescriptionProperty = new SingleValuedProperty<string>(); ValueProperty = new SingleValuedProperty<double>(); DateProperty = new SingleValuedProperty<DateTime>(); CreateRequestCommand = new CommandViewModel(OnCreateRequestCommand); RequestKind = new EnumeratedSingleValuedProperty<RequestKind>(); DateProperty.OnValueChanged += DatePropertyOnOnValueChanged; RequestKind.OnValueChanged += RequestKindOnOnValueChanged; ValueProperty.Validate = ValidateValueProperty; ValueProperty.OnIsValidChanged += ValuePropertyOnOnIsValidChanged; ValueProperty.OnValueChanged += ValuePropertyOnOnValueChanged; FirstPossibleDate = new DateTime(year, month, 1); LastPossibleDate = new DateTime(year, month, DateTime.DaysInMonth(year, month)); RequestKind.SetRange(Enum.GetValues(typeof(RequestKind)).Cast<RequestKind>()); RequestKind.Value = RequestManagement.RequestKind.Expenditure; var categories = application.Repository.QueryAllCategories() .Select(c => new CategoryViewModel(application, c.PersistentId)) .ToList(); categories.ForEach(c => c.Refresh()); Categories.SetRange(categories.OrderBy(c => c.Name)); if (!string.IsNullOrEmpty(selectedCategoryId)) { Categories.Value = Categories.SelectableValues.Single(c => c.EntityId == selectedCategoryId); } UpdateLocalizedProperties(); UpdateCommandStates(); }