Exemplo n.º 1
0
        public async Task <CreateItemResponse> Post([FromBody] CreateItemRequest request)
        {
            CreateItemResponse createItemResponse = null;
            var pattern = @"^(?:\d{12})$";

            try
            {
                if (!Regex.IsMatch(request.UPC, pattern))
                {
                    throw new Exception("UPC must be 12 digit number.");
                }

                var item = await _domainService.CreateItem(request);

                if (item != null)
                {
                    createItemResponse = _mapper.Map <CreateItemResponse>(item);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(createItemResponse);
        }
        public PublisherDetailViewModel(IEventAggregator eventAggregator,
                                        ILogger logger,
                                        IDomainService <Publisher> domainService,
                                        IDialogService dialogService)
            : base(eventAggregator, logger, domainService, dialogService)
        {
            AddPublisherLogoCommand = new DelegateCommand(OnAddPublisherLogoExecute);
            SaveItemCommand         = new DelegateCommand(SaveItemExecute, SaveItemCanExecute)
                                      .ObservesProperty(() => SelectedItem.Name);

            SelectedItem = new PublisherWrapper(domainService.CreateItem());
        }
Exemplo n.º 3
0
        public AuthorDetailViewModel(IEventAggregator eventAggregator,
                                     ILogger logger,
                                     IDomainService <Author> domainService,
                                     IDialogService dialogService)
            : base(eventAggregator, logger, domainService, dialogService)
        {
            AddAuthorPictureCommand            = new DelegateCommand(OnAddAuthorPictureExecute);
            AddNewNationalityCommand           = new DelegateCommand(OnAddNewNationalityExecute);
            NationalitySelectionChangedCommand = new DelegateCommand(OnNationalitySelectionChangedExecute);
            SaveItemCommand = new DelegateCommand(SaveItemExecute, SaveItemCanExecute)
                              .ObservesProperty(() => SelectedItem.FirstName)
                              .ObservesProperty(() => SelectedItem.LastName);
            SelectedItem = new AuthorWrapper(domainService.CreateItem());

            Nationalities = new ObservableCollection <LookupItem>();
        }
Exemplo n.º 4
0
        public BookDetailViewModel(IEventAggregator eventAggregator,
                                   ILogger logger,
                                   IDomainService <Book> domainService,
                                   IDialogService dialogService)
            : base(eventAggregator, logger, domainService, dialogService)
        {
            HighlightMouseOverCommand  = new DelegateCommand(HighlightMouseOverExecute);
            HighlightMouseLeaveCommand = new DelegateCommand(HighlightMouseLeaveExecute);
            SetReadDateCommand         = new DelegateCommand(SetReadDateExecute, SetReadDateCanExecute)
                                         .ObservesProperty(() => NewReadDate);
            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);
            AddNewFormatCommand = new DelegateCommand <string>(OnAddNewFormatExecute, OnAddNewFormatCanExecute)
                                  .ObservesProperty(() => NewFormatName);
            AddNewGenreCommand = new DelegateCommand <string>(OnAddNewGenreExecute, OnAddNewGenreCanExecute)
                                 .ObservesProperty(() => NewGenreName);
            SaveItemCommand = new DelegateCommand(SaveItemExecute, SaveItemCanExecute)
                              .ObservesProperty(() => SelectedItem.Title)
                              .ObservesProperty(() => SelectedItem.PageCount)
                              .ObservesProperty(() => SelectedItem.LanguageId)
                              .ObservesProperty(() => SelectedItem.PublisherId);

            SelectedItem = new BookWrapper(domainService.CreateItem(), domainService);

            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> >();

            YearsList = PopulateYearsMenu();
        }
        public NationalityDetailViewModel(IEventAggregator eventAggregator,
                                          ILogger logger,
                                          IDomainService <Nationality> domainService,
                                          INationalityLookupDataService nationalityLookupDataService,
                                          IDialogService dialogService)
            : base(eventAggregator, logger, domainService, dialogService)
        {
            this.nationalityLookupDataService = nationalityLookupDataService ?? throw new ArgumentNullException(nameof(nationalityLookupDataService));

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

            SelectedItem = CreateWrapper(domainService.CreateItem());

            Nations = new ObservableCollection <LookupItem>();

            UserMode = (!UserMode.Item1, DetailViewState.EditMode, Brushes.LightGray, !UserMode.Item4).ToTuple();
        }
Exemplo n.º 6
0
        public SeriesDetailViewModel(IEventAggregator eventAggregator,
                                     ILogger logger,
                                     IDomainService <Series> domainService,
                                     IBookLookupDataService bookLookupDataService,
                                     IDialogService dialogService)
            : base(eventAggregator, logger, domainService, dialogService)
        {
            this.bookLookupDataService = bookLookupDataService ?? throw new ArgumentNullException(nameof(bookLookupDataService));

            AddSeriesPictureCommand = new DelegateCommand(OnAddSeriesPictureExecute);
            FilterBookListCommand   = new DelegateCommand <string>(OnFilterBookListExecute);
            AddBookToSeriesCommand  = new DelegateCommand <Guid?>(OnAddBookToSeriesExecute, OnAddBookToSeriesCanExecute);
            SaveItemCommand         = new DelegateCommand(SaveItemExecute, SaveItemCanExecute)
                                      .ObservesProperty(() => SelectedItem.Name);
            SelectedItem = new SeriesWrapper(domainService.CreateItem());

            Books    = new ObservableCollection <LookupItem>();
            AllBooks = new ObservableCollection <LookupItem>();
        }