Example #1
0
        public BookDetailViewModel(IEventAggregator eventAggregator,
                                   IMetroDialogService metroDialogService,
                                   IRepository <Book> booksRepo,
                                   ILanguageLookupDataService languageLookupDataService,
                                   IPublisherLookupDataService publisherLookupDataService,
                                   IAuthorLookupDataService authorLookupDataService,
                                   IFormatLookupDataService formatLookupDataService,
                                   IGenreLookupDataService genreLookupDataService)
            : base(eventAggregator, metroDialogService)
        {
            this.languageLookupDataService = languageLookupDataService
                                             ?? throw new ArgumentNullException(nameof(languageLookupDataService));
            this.publisherLookupDataService = publisherLookupDataService
                                              ?? throw new ArgumentNullException(nameof(publisherLookupDataService));
            this.authorLookupDataService = authorLookupDataService
                                           ?? throw new ArgumentNullException(nameof(authorLookupDataService));
            this.formatLookupDataService = formatLookupDataService
                                           ?? throw new ArgumentNullException(nameof(formatLookupDataService));
            this.genreLookupDataService = genreLookupDataService
                                          ?? throw new ArgumentNullException(nameof(genreLookupDataService));

            HighlightMouseOverCommand          = new DelegateCommand(HighlightMouseOverExecute);
            HighlightMouseLeaveCommand         = new DelegateCommand(HighlightMouseLeaveExecute);
            SetReadDateCommand                 = new DelegateCommand(SetReadDateExecute);
            AddBookCoverImageCommand           = new DelegateCommand(AddBookCoverImageExecute);
            AddAuthorAsABookAuthorCommand      = new DelegateCommand <LookupItem>(AddBookAuthorExecute);
            AddNewAuthorCommand                = new DelegateCommand(OnAddNewAuthorExecute);
            AddNewPublisherCommand             = new DelegateCommand(OnAddNewPublisherExecute);
            AddNewLanguageCommand              = new DelegateCommand(OnAddNewLanguageExecute);
            RemoveAuthorAsABookAuthorCommand   = new DelegateCommand <Guid?>(RemoveAuthorExecute);
            LanguageSelectionChangedCommand    = new DelegateCommand(OnLanguageSelectionChangedExecute);
            PublisherSelectionChangedCommand   = new DelegateCommand(OnPublisherSelectionChangedExecute);
            RemoveDateAsABookReadDateCommand   = new DelegateCommand <DateTime?>(OnRemoveDateAsABookReadDateExecute);
            ReleaseYearSelectionChangedCommand = new DelegateCommand(OnReleaseYearSelectionChangedExecute);
            ShowSelectedPublisherCommand
                = new DelegateCommand <Guid?>(OnShowSelectedPublisherExecute, OnShowSelectedPublisherCanExecute);
            ShowSelectedAuthorCommand         = new DelegateCommand <Guid?>(OnShowSelectedAuthorExecute, OnShowSelectedAuthorCanExecute);
            ShowSelectedSeriesCommand         = new DelegateCommand <Guid?>(OnShowSelectedSeriesExecute, OnShowSelectedSeriesCanExecute);
            BookFormatSelectionChangedCommand = new DelegateCommand <LookupItem>(OnBookFormatSelectionChangedExecute);
            BookGenreSelectionChangedCommand  = new DelegateCommand <LookupItem>(OnBookGenreSelectionChangedExecute);

            Repository = booksRepo ?? throw new ArgumentNullException(nameof(booksRepo));

            NewReadDate    = DateTime.Today;
            Languages      = new ObservableCollection <LookupItem>();
            Publishers     = new ObservableCollection <LookupItem>();
            Authors        = new ObservableCollection <LookupItem>();
            AllBookFormats = new ObservableCollection <Tuple <LookupItem, bool> >();
            AllBookGenres  = new ObservableCollection <Tuple <LookupItem, bool> >();
            SelectedItem   = new Book();

            YearsList = PopulateYearsMenu();
        }
        public FormatDetailViewModel(IEventAggregator eventAggregator,
                                     IMetroDialogService metroDialogService,
                                     IRepository <Format> formatRepository,
                                     IFormatLookupDataService formatLookupService)
            : base(eventAggregator, metroDialogService)
        {
            Repository = formatRepository;
            this.formatLookupService = formatLookupService ?? throw new ArgumentNullException(nameof(formatLookupService));

            ChangeEditedFormatCommand = new DelegateCommand <Guid?>(OnChangeEditedFormatExecute);

            SelectedItem = new Format();

            UserMode = (!UserMode.Item1, DetailViewState.EditMode, Brushes.LightGray, !UserMode.Item4).ToTuple();

            Formats = new ObservableCollection <LookupItem>();
        }
        public MainPageViewModel(IEventAggregator eventAggregator, ILanguageLookupDataService languageLookup,
                                 INationalityLookupDataService nationalityLookupDataService,
                                 IFormatLookupDataService formatLookupDataService,
                                 IGenreLookupDataService genreLookupDataService)
        {
            this.eventAggregator = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator));
            this.languageLookup  = languageLookup ?? throw new ArgumentNullException(nameof(languageLookup));
            this.nationalityLookupDataService = nationalityLookupDataService ?? throw new ArgumentNullException(nameof(nationalityLookupDataService));
            this.formatLookupDataService      = formatLookupDataService ?? throw new ArgumentNullException(nameof(formatLookupDataService));
            this.genreLookupDataService       = genreLookupDataService ?? throw new ArgumentNullException(nameof(genreLookupDataService));

            AddNewItemCommand        = new DelegateCommand <Type>(OnAddNewItemExecute);
            EditLanguagesCommand     = new DelegateCommand(OnEditLanguagesExecute);
            EditNationalitiesCommand = new DelegateCommand(OnEditNationalitiesExecute);
            EditBookFormatsCommand   = new DelegateCommand(OnEditBookFormatsExecute);
            EditBookGenresCommand    = new DelegateCommand(OnEditBookGenresExecute);
        }
Example #4
0
 public BookService(IRepository <Book, BookId> repository,
                    ILanguageLookupDataService languageLookupDataService   = null,
                    IPublisherLookupDataService publisherLookupDataService = null,
                    IAuthorLookupDataService authorLookupDataService       = null,
                    IFormatLookupDataService formatLookupDataService       = null,
                    IGenreLookupDataService genreLookupDataService         = null,
                    IGenreService genreService   = null,
                    IFormatService formatService = null)
 {
     Repository = repository ?? throw new ArgumentNullException(nameof(repository));
     _languageLookupDataService  = languageLookupDataService;
     _publisherLookupDataService = publisherLookupDataService;
     _authorLookupDataService    = authorLookupDataService;
     _formatLookupDataService    = formatLookupDataService;
     _genreLookupDataService     = genreLookupDataService;
     _genreService  = genreService;
     _formatService = formatService;
 }
 public BookService(IRepository <Book> repository,
                    IFormatRepository formatRepository,
                    IGenreRepository genreRepository,
                    ILanguageLookupDataService languageLookupDataService,
                    IPublisherLookupDataService publisherLookupDataService,
                    IAuthorLookupDataService authorLookupDataService,
                    IFormatLookupDataService formatLookupDataService,
                    IGenreLookupDataService genreLookupDataService)
 {
     Repository = repository ?? throw new ArgumentNullException(nameof(repository));
     this.languageLookupDataService  = languageLookupDataService ?? throw new ArgumentNullException(nameof(languageLookupDataService));
     this.publisherLookupDataService = publisherLookupDataService ?? throw new ArgumentNullException(nameof(publisherLookupDataService));
     this.authorLookupDataService    = authorLookupDataService ?? throw new ArgumentNullException(nameof(authorLookupDataService));
     this.formatLookupDataService    = formatLookupDataService ?? throw new ArgumentNullException(nameof(formatLookupDataService));
     this.genreLookupDataService     = genreLookupDataService ?? throw new ArgumentNullException(nameof(genreLookupDataService));
     this.formatRepository           = formatRepository ?? throw new ArgumentNullException(nameof(formatRepository));
     this.genreRepository            = genreRepository ?? throw new ArgumentNullException(nameof(genreRepository));
 }
        public FormatDetailViewModel(IEventAggregator eventAggregator,
                                     ILogger logger,
                                     IFormatService domainService,
                                     IFormatLookupDataService formatLookupDataService,
                                     IDialogService dialogService)
            : base(eventAggregator, logger, domainService, dialogService)
        {
            _formatLookupDataService = formatLookupDataService ?? throw new ArgumentNullException(nameof(formatLookupDataService));

            ChangeEditedFormatCommand = new DelegateCommand <Guid?>(OnChangeEditedFormatExecute);
            SaveItemCommand           = new DelegateCommand(SaveItemExecute, base.SaveItemCanExecute)
                                        .ObservesProperty(() => SelectedItem.Name);

            SelectedItem = CreateWrapper(domainService.CreateItem());

            Formats = new ObservableCollection <LookupItem>();

            UserMode = (!UserMode.Item1, DetailViewState.EditMode, Brushes.LightGray, !UserMode.Item4).ToTuple();
        }
        public MainPageViewModel([NotNull] IEventAggregator eventAggregator,
                                 [NotNull] INationalityLookupDataService nationalityLookupDataService,
                                 [NotNull] IFormatLookupDataService formatLookupDataService,
                                 [NotNull] IGenreLookupDataService genreLookupDataService,
                                 [NotNull] ILanguageLookupDataService languageLookupDataService)
        {
            _eventAggregator = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator));
            _nationalityLookupDataService = nationalityLookupDataService
                                            ?? throw new ArgumentNullException(nameof(nationalityLookupDataService));
            _formatLookupDataService   = formatLookupDataService ?? throw new ArgumentNullException(nameof(formatLookupDataService));
            _genreLookupDataService    = genreLookupDataService ?? throw new ArgumentNullException(nameof(genreLookupDataService));
            _languageLookupDataService = languageLookupDataService ?? throw new ArgumentNullException(nameof(languageLookupDataService));

            ShowItemsCommand = new DelegateCommand <Type>(OnShowItemsExecute);

            AddNewItemCommand        = new DelegateCommand <Type>(OnAddNewItemExecute);
            EditLanguagesCommand     = new DelegateCommand(OnEditLanguagesExecute);
            EditNationalitiesCommand = new DelegateCommand(OnEditNationalitiesExecute);
            EditBookFormatsCommand   = new DelegateCommand(OnEditBookFormatsExecute);
            EditBookGenresCommand    = new DelegateCommand(OnEditBookGenresExecute);
        }