//autofac uses this public LibraryBookView(BookSelection bookSelection, //SendReceiver sendReceiver, CreateFromSourceBookCommand createFromSourceBookCommand, EditBookCommand editBookCommand, SelectedTabChangedEvent selectedTabChangedEvent, NavigationIsolator isolator) { InitializeComponent(); _previewBrowser.Isolator = isolator; _readmeBrowser.Isolator = isolator; _bookSelection = bookSelection; //_sendReceiver = sendReceiver; _createFromSourceBookCommand = createFromSourceBookCommand; _editBookCommand = editBookCommand; bookSelection.SelectionChanged += new EventHandler(OnBookSelectionChanged); selectedTabChangedEvent.Subscribe(c => { _visible = c.To is LibraryView; if(_reshowPending) { ShowBook(); } }); _editBookButton.Visible = false; }
public AppApi(BookSelection bookSelection, EditBookCommand editBookCommand, CreateFromSourceBookCommand createFromSourceBookCommand) { _bookSelection = bookSelection; _editBookCommand = editBookCommand; _createFromSourceBookCommand = createFromSourceBookCommand; }
public LibraryModel(string pathToLibrary, CollectionSettings collectionSettings, //SendReceiver sendReceiver, BookSelection bookSelection, SourceCollectionsList sourceCollectionsList, BookCollection.Factory bookCollectionFactory, EditBookCommand editBookCommand, CreateFromSourceBookCommand createFromSourceBookCommand, BookServer bookServer, CurrentEditableCollectionSelection currentEditableCollectionSelection, BookThumbNailer thumbNailer, TeamCollectionManager tcManager) { _bookSelection = bookSelection; _pathToLibrary = pathToLibrary; _collectionSettings = collectionSettings; //_sendReceiver = sendReceiver; _sourceCollectionsList = sourceCollectionsList; _bookCollectionFactory = bookCollectionFactory; _editBookCommand = editBookCommand; _bookServer = bookServer; _currentEditableCollectionSelection = currentEditableCollectionSelection; _thumbNailer = thumbNailer; _tcManager = tcManager; createFromSourceBookCommand.Subscribe(CreateFromSourceBook); }
public CollectionModel(string pathToCollection, CollectionSettings collectionSettings, BookSelection bookSelection, SourceCollectionsList sourceCollectionsList, BookCollection.Factory bookCollectionFactory, EditBookCommand editBookCommand, CreateFromSourceBookCommand createFromSourceBookCommand, BookServer bookServer, CurrentEditableCollectionSelection currentEditableCollectionSelection, BookThumbNailer thumbNailer, TeamCollectionManager tcManager, BloomWebSocketServer webSocketServer, BookCollectionHolder bookCollectionHolder, LocalizationChangedEvent localizationChangedEvent) { _bookSelection = bookSelection; _pathToCollection = pathToCollection; _collectionSettings = collectionSettings; _sourceCollectionsList = sourceCollectionsList; _bookCollectionFactory = bookCollectionFactory; _editBookCommand = editBookCommand; _bookServer = bookServer; _currentEditableCollectionSelection = currentEditableCollectionSelection; _thumbNailer = thumbNailer; _tcManager = tcManager; _webSocketServer = webSocketServer; _bookCollectionHolder = bookCollectionHolder; _localizationChangedEvent = localizationChangedEvent; createFromSourceBookCommand.Subscribe(CreateFromSourceBook); }
public delegate LibraryBookView Factory(); //autofac uses this public LibraryBookView(BookSelection bookSelection, SendReceiver sendReceiver, CreateFromSourceBookCommand createFromSourceBookCommand, EditBookCommand editBookCommand, SelectedTabChangedEvent selectedTabChangedEvent, NavigationIsolator isolator) { InitializeComponent(); _previewBrowser.Isolator = isolator; _readmeBrowser.Isolator = isolator; _bookSelection = bookSelection; _sendReceiver = sendReceiver; _createFromSourceBookCommand = createFromSourceBookCommand; _editBookCommand = editBookCommand; bookSelection.SelectionChanged += new EventHandler(OnBookSelectionChanged); selectedTabChangedEvent.Subscribe(c => { _visible = c.To is LibraryView; if (_reshowPending) { ShowBook(); } }); _editBookButton.Visible = false; }
public IActionResult Edit(EditBookDto dto) { var command = new EditBookCommand(dto); commandBus.Send(command); return(Redirect("~/book")); }
public CollectionApi(CollectionSettings settings, CollectionModel collectionModel, BookSelection bookSelection, EditBookCommand editBookCommand, BookThumbNailer thumbNailer, BloomWebSocketServer webSocketServer) { _settings = settings; _collectionModel = collectionModel; _bookSelection = bookSelection; _editBookCommand = editBookCommand; _thumbNailer = thumbNailer; _webSocketServer = webSocketServer; }
public async Task <Unit> Handle(EditBookCommand request, CancellationToken cancellationToken) { var book = _context.Books.Single(x => x.Id == request.Id); book.Name = request.Name; await _context.SaveChangesAsync(); return(Unit.Value); }
public async Task <IActionResult> UpdateBook([FromBody] Book book) { if (ModelState.IsValid) { var command = new EditBookCommand(book); var result = await _mediator.Send(command); return(Ok(result)); } else { return(BadRequest(ModelState)); } }
public async Task <BookDTO> Handle(EditBookCommand request, CancellationToken cancellationToken) { // BookUpdate represents the book with updateded values var bookUpdate = request.Book; // ExisitingBook is a book that is already in the database var exsistingBook = await _unitOfWork.GetRepository <Book>().FindAsync(bookUpdate.Id); var category = _unitOfWork.GetRepository <Category>().Find(exsistingBook.categoryId); exsistingBook.Category = category; exsistingBook.Pages = bookUpdate.Pages; exsistingBook.Author = bookUpdate.Author; exsistingBook.Title = bookUpdate.Title; _unitOfWork.GetRepository <Book>().Update(exsistingBook); _unitOfWork.SaveChanges(); return(_mapper.Map <BookDTO>(exsistingBook)); }
public async Task <DetailedBookDto> EditBook(int id, EditBookCommand command) { var book = await this.Find(id); if (book == null) { throw new NotFoundException($"the requested item with id: {id} could not be found"); } List <Genre> dbGenres = new List <Genre>(); if (command.Genres.Any()) { IQueryable <Genre> genres = this.Context.Genres.AsQueryable(); foreach (var genre in command.Genres) { var genre1 = genre; genres = genres.Where(x => x.Id == genre1); } dbGenres = await genres.ToListAsync(); } // Commence updating book... book.Title = string.IsNullOrEmpty(command.Title) ? book.Title : command.Title; book.Summary = string.IsNullOrEmpty(command.Summary) ? book.Summary : command.Summary; book.AuthorId = command.AuthorId > 0 ? command.AuthorId.Value : book.AuthorId; book.PublishYear = command.PublishYear ?? book.PublishYear; if (dbGenres.Any()) { book.Genres = dbGenres.Select(genre => genre).ToList(); } book.PublisherId = command.PublisherId > 0 ? command.PublisherId.Value : book.PublisherId; book.Language = string.IsNullOrEmpty(command.Language) ? book.Language : command.Language; book.CopiesAvailable = command.CopiesAvailable ?? book.CopiesAvailable; book.PageCount = command.PageCount ?? book.PageCount; book.ViewCount = command.ViewCount ?? book.ViewCount; book.ISBN = string.IsNullOrEmpty(command.ISBN) ? command.ISBN : book.ISBN; book.Price = command.Price ?? book.Price; //woah var resultBook = await this.Update(book); return(resultBook.ToDetailedDto()); }
public delegate LibraryBookView Factory(); //autofac uses this public LibraryBookView(BookSelection bookSelection, //SendReceiver sendReceiver, CreateFromSourceBookCommand createFromSourceBookCommand, EditBookCommand editBookCommand, SelectedTabChangedEvent selectedTabChangedEvent, SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent, NavigationIsolator isolator) { InitializeComponent(); _previewBrowser.Isolator = isolator; _readmeBrowser.Isolator = isolator; _bookSelection = bookSelection; //_sendReceiver = sendReceiver; _createFromSourceBookCommand = createFromSourceBookCommand; _editBookCommand = editBookCommand; bookSelection.SelectionChanged += OnBookSelectionChanged; selectedTabAboutToChangeEvent.Subscribe(c => { if (!(c.To is LibraryView)) { // We're becoming invisible. Stop any work in progress to generate a preview // (thus allowing other browsers, like the ones in the Edit view, to navigate // to their destinations.) HidePreview(); } }); selectedTabChangedEvent.Subscribe(c => { var wasVisible = _visible; _visible = c.To is LibraryView; if (_reshowPending || wasVisible != _visible) { ShowBook(); } }); _editBookButton.Visible = false; }
public delegate LibraryBookView Factory(); //autofac uses this public LibraryBookView(BookSelection bookSelection, //SendReceiver sendReceiver, CreateFromSourceBookCommand createFromSourceBookCommand, EditBookCommand editBookCommand, SelectedTabChangedEvent selectedTabChangedEvent, SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent, BloomWebSocketServer webSocketServer) { InitializeComponent(); _bookSelection = bookSelection; //_sendReceiver = sendReceiver; _createFromSourceBookCommand = createFromSourceBookCommand; _editBookCommand = editBookCommand; _webSocketServer = webSocketServer; if (!Bloom.CLI.UploadCommand.IsUploading) { bookSelection.SelectionChanged += OnBookSelectionChanged; } selectedTabAboutToChangeEvent.Subscribe(c => { if (!(c.To is LibraryView)) { // We're becoming invisible. Stop any work in progress to generate a preview // (thus allowing other browsers, like the ones in the Edit view, to navigate // to their destinations.) HidePreview(); } }); selectedTabChangedEvent.Subscribe(c => { var wasVisible = _visible; _visible = c.To is LibraryView || c is ReactCollectionTabView; if (_reshowPending || wasVisible != _visible) { ShowBook(); } }); }
public LibraryModel(string pathToLibrary, CollectionSettings collectionSettings, SendReceiver sendReceiver, BookSelection bookSelection, SourceCollectionsList sourceCollectionsList, BookCollection.Factory bookCollectionFactory, EditBookCommand editBookCommand, CreateFromSourceBookCommand createFromSourceBookCommand, BookServer bookServer, CurrentEditableCollectionSelection currentEditableCollectionSelection) { _bookSelection = bookSelection; _pathToLibrary = pathToLibrary; _collectionSettings = collectionSettings; _sendReceiver = sendReceiver; _sourceCollectionsList = sourceCollectionsList; _bookCollectionFactory = bookCollectionFactory; _editBookCommand = editBookCommand; _bookServer = bookServer; _currentEditableCollectionSelection = currentEditableCollectionSelection; createFromSourceBookCommand.Subscribe(CreateFromSourceBook); }
public async Task <ActionResult> Edit( int id, EditBookCommand command) => await this.Send(command.SetId(id));
//autofac uses this public WorkspaceView(WorkspaceModel model, Control libraryView, EditingView.Factory editingViewFactory, PublishView.Factory pdfViewFactory, CollectionSettingsDialog.Factory settingsDialogFactory, EditBookCommand editBookCommand, SendReceiveCommand sendReceiveCommand, SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent, SelectedTabChangedEvent selectedTabChangedEvent, FeedbackDialog.Factory feedbackDialogFactory, ChorusSystem chorusSystem, Sparkle sparkleApplicationUpdater, LocalizationManager localizationManager ) { _model = model; _settingsDialogFactory = settingsDialogFactory; _selectedTabAboutToChangeEvent = selectedTabAboutToChangeEvent; _selectedTabChangedEvent = selectedTabChangedEvent; _feedbackDialogFactory = feedbackDialogFactory; _chorusSystem = chorusSystem; _sparkleApplicationUpdater = sparkleApplicationUpdater; _localizationManager = localizationManager; _model.UpdateDisplay += new System.EventHandler(OnUpdateDisplay); InitializeComponent(); #if !DEBUG _sparkleApplicationUpdater.CheckOnFirstApplicationIdle(); #endif _toolStrip.Renderer = new NoBorderToolStripRenderer(); //we have a number of buttons which don't make sense for the remote (therefore vulnerable) low-end user //_settingsLauncherHelper.CustomSettingsControl = _toolStrip; _settingsLauncherHelper.ManageComponent(_settingsButton); //NB: the rest of these aren't really settings, but we're using that feature to simplify this menu down to what makes sense for the easily-confused user _settingsLauncherHelper.ManageComponent(_openCreateCollectionButton); _settingsLauncherHelper.ManageComponent(deepBloomPaperToolStripMenuItem); _settingsLauncherHelper.ManageComponent(_makeASuggestionMenuItem); _settingsLauncherHelper.ManageComponent(_webSiteMenuItem); _settingsLauncherHelper.ManageComponent(_showLogMenuItem); _settingsLauncherHelper.ManageComponent(_releaseNotesMenuItem); _settingsLauncherHelper.ManageComponent(_divider2); _settingsLauncherHelper.ManageComponent(_divider3); _settingsLauncherHelper.ManageComponent(_divider4); OnSettingsProtectionChanged(this, null);//initial setup SettingsProtectionSettings.Default.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnSettingsProtectionChanged); _uiLanguageMenu.Visible = true; _settingsLauncherHelper.ManageComponent(_uiLanguageMenu); editBookCommand.Subscribe(OnEditBook); sendReceiveCommand.Subscribe(OnSendReceive); //Cursor = Cursors.AppStarting; Application.Idle += new EventHandler(Application_Idle); Text = _model.ProjectName; //SetupTabIcons(); // // _collectionView // this._collectionView = (LibraryView) libraryView; this._collectionView.Dock = System.Windows.Forms.DockStyle.Fill; // // _editingView // this._editingView = editingViewFactory(); this._editingView.Dock = System.Windows.Forms.DockStyle.Fill; // // _pdfView // this._publishView = pdfViewFactory(); this._publishView.Dock = System.Windows.Forms.DockStyle.Fill; _collectionTab.Tag = _collectionView; _publishTab.Tag = _publishView; _editTab.Tag = _editingView; this._collectionTab.Text = _collectionView.CollectionTabLabel; SetTabVisibility(_publishTab, false); SetTabVisibility(_editTab, false); // if (Program.StartUpWithFirstOrNewVersionBehavior) // { // _tabStrip.SelectedTab = _infoTab; // SelectPage(_infoView); // } // else // { _tabStrip.SelectedTab = _collectionTab; SelectPage(_collectionView); // } SetupUILanguageMenu(); }
//autofac uses this public WorkspaceView(WorkspaceModel model, Control libraryView, EditingView.Factory editingViewFactory, PublishView.Factory pdfViewFactory, CollectionSettingsDialog.Factory settingsDialogFactory, EditBookCommand editBookCommand, SendReceiveCommand sendReceiveCommand, SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent, SelectedTabChangedEvent selectedTabChangedEvent, LocalizationChangedEvent localizationChangedEvent, FeedbackDialog.Factory feedbackDialogFactory, ProblemReporterDialog.Factory problemReportDialogFactory, //ChorusSystem chorusSystem, LocalizationManager localizationManager ) { _model = model; _settingsDialogFactory = settingsDialogFactory; _selectedTabAboutToChangeEvent = selectedTabAboutToChangeEvent; _selectedTabChangedEvent = selectedTabChangedEvent; _localizationChangedEvent = localizationChangedEvent; _feedbackDialogFactory = feedbackDialogFactory; _problemReportDialogFactory = problemReportDialogFactory; //_chorusSystem = chorusSystem; _localizationManager = localizationManager; _model.UpdateDisplay += new System.EventHandler(OnUpdateDisplay); InitializeComponent(); _checkForNewVersionMenuItem.Visible = SIL.PlatformUtilities.Platform.IsWindows; _toolStrip.Renderer = new NoBorderToolStripRenderer(); //we have a number of buttons which don't make sense for the remote (therefore vulnerable) low-end user //_settingsLauncherHelper.CustomSettingsControl = _toolStrip; _settingsLauncherHelper.ManageComponent(_settingsButton); //NB: the rest of these aren't really settings, but we're using that feature to simplify this menu down to what makes sense for the easily-confused user _settingsLauncherHelper.ManageComponent(_openCreateCollectionButton); _settingsLauncherHelper.ManageComponent(_keyBloomConceptsMenuItem); _settingsLauncherHelper.ManageComponent(_makeASuggestionMenuItem); _settingsLauncherHelper.ManageComponent(_webSiteMenuItem); _settingsLauncherHelper.ManageComponent(_showLogMenuItem); _settingsLauncherHelper.ManageComponent(_releaseNotesMenuItem); _settingsLauncherHelper.ManageComponent(_divider2); _settingsLauncherHelper.ManageComponent(_divider3); _settingsLauncherHelper.ManageComponent(_divider4); OnSettingsProtectionChanged(this, null); //initial setup SettingsProtectionSettings.Default.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnSettingsProtectionChanged); _uiLanguageMenu.Visible = true; _settingsLauncherHelper.ManageComponent(_uiLanguageMenu); editBookCommand.Subscribe(OnEditBook); sendReceiveCommand.Subscribe(OnSendReceive); //Cursor = Cursors.AppStarting; Application.Idle += new EventHandler(Application_Idle); Text = _model.ProjectName; //SetupTabIcons(); // // _collectionView // this._collectionView = (LibraryView)libraryView; this._collectionView.Dock = System.Windows.Forms.DockStyle.Fill; // // _editingView // this._editingView = editingViewFactory(); this._editingView.Dock = System.Windows.Forms.DockStyle.Fill; // // _pdfView // this._publishView = pdfViewFactory(); this._publishView.Dock = System.Windows.Forms.DockStyle.Fill; _collectionTab.Tag = _collectionView; _publishTab.Tag = _publishView; _editTab.Tag = _editingView; this._collectionTab.Text = _collectionView.CollectionTabLabel; SetTabVisibility(_publishTab, false); SetTabVisibility(_editTab, false); // if (Program.StartUpWithFirstOrNewVersionBehavior) // { // _tabStrip.SelectedTab = _infoTab; // SelectPage(_infoView); // } // else // { _tabStrip.SelectedTab = _collectionTab; SelectPage(_collectionView); // } if (SIL.PlatformUtilities.Platform.IsMono) { // Without this adjustment, we lose some controls on smaller resolutions. AdjustToolPanelLocation(true); // in mono auto-size causes the height of the tab strip to be too short _tabStrip.AutoSize = false; } SetupUiLanguageMenu(); _viewInitialized = false; }
//autofac uses this public WorkspaceView(WorkspaceModel model, Control libraryView, EditingView.Factory editingViewFactory, PublishView.Factory pdfViewFactory, CollectionSettingsDialog.Factory settingsDialogFactory, EditBookCommand editBookCommand, SendReceiveCommand sendReceiveCommand, SelectedTabAboutToChangeEvent selectedTabAboutToChangeEvent, SelectedTabChangedEvent selectedTabChangedEvent, FeedbackDialog.Factory feedbackDialogFactory, ChorusSystem chorusSystem, Sparkle sparkleApplicationUpdater, LocalizationManager localizationManager ) { _model = model; _settingsDialogFactory = settingsDialogFactory; _selectedTabAboutToChangeEvent = selectedTabAboutToChangeEvent; _selectedTabChangedEvent = selectedTabChangedEvent; _feedbackDialogFactory = feedbackDialogFactory; _chorusSystem = chorusSystem; _sparkleApplicationUpdater = sparkleApplicationUpdater; _localizationManager = localizationManager; _model.UpdateDisplay += new System.EventHandler(OnUpdateDisplay); InitializeComponent(); #if !DEBUG _sparkleApplicationUpdater.CheckOnFirstApplicationIdle(); #endif _toolStrip.Renderer = new NoBorderToolStripRenderer(); //we have a number of buttons which don't make sense for the remote (therefore vulnerable) low-end user //_settingsLauncherHelper.CustomSettingsControl = _toolStrip; _settingsLauncherHelper.ManageComponent(_settingsButton); //NB: the rest of these aren't really settings, but we're using that feature to simplify this menu down to what makes sense for the easily-confused user _settingsLauncherHelper.ManageComponent(_openCreateCollectionButton); _settingsLauncherHelper.ManageComponent(deepBloomPaperToolStripMenuItem); _settingsLauncherHelper.ManageComponent(_makeASuggestionMenuItem); _settingsLauncherHelper.ManageComponent(_webSiteMenuItem); _settingsLauncherHelper.ManageComponent(_showLogMenuItem); _settingsLauncherHelper.ManageComponent(_releaseNotesMenuItem); _settingsLauncherHelper.ManageComponent(_divider2); _settingsLauncherHelper.ManageComponent(_divider3); _settingsLauncherHelper.ManageComponent(_divider4); OnSettingsProtectionChanged(this, null); //initial setup SettingsProtectionSettings.Default.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnSettingsProtectionChanged); _uiLanguageMenu.Visible = true; _settingsLauncherHelper.ManageComponent(_uiLanguageMenu); editBookCommand.Subscribe(OnEditBook); sendReceiveCommand.Subscribe(OnSendReceive); //Cursor = Cursors.AppStarting; Application.Idle += new EventHandler(Application_Idle); Text = _model.ProjectName; //SetupTabIcons(); // // _collectionView // this._collectionView = (LibraryView)libraryView; this._collectionView.Dock = System.Windows.Forms.DockStyle.Fill; // // _editingView // this._editingView = editingViewFactory(); this._editingView.Dock = System.Windows.Forms.DockStyle.Fill; // // _pdfView // this._publishView = pdfViewFactory(); this._publishView.Dock = System.Windows.Forms.DockStyle.Fill; _collectionTab.Tag = _collectionView; _publishTab.Tag = _publishView; _editTab.Tag = _editingView; this._collectionTab.Text = _collectionView.CollectionTabLabel; SetTabVisibility(_publishTab, false); SetTabVisibility(_editTab, false); // if (Program.StartUpWithFirstOrNewVersionBehavior) // { // _tabStrip.SelectedTab = _infoTab; // SelectPage(_infoView); // } // else // { _tabStrip.SelectedTab = _collectionTab; SelectPage(_collectionView); // } SetupUILanguageMenu(); }
public async Task <IHttpActionResult> Update(int id, [FromBody] EditBookCommand command) { return(await this.Try(() => this._bookRepository.EditBook(id, command))); }