public override int AddNewItem(Book book) { var itemInput = new GetItemByIdInput(); var barcodeInput = new SetItemBarcodeInput(); var updateInput = new UpdateItemInput(); var input = new AddNewBookInput { Book = new BookDto(book) }; using (var repo = new BookRepository()) { var app = new BookAppService(repo); itemInput.Id = app.AddNewBook(input).Id; } using (var itemRepo = new ItemRepository()) { var app = new ItemAppService(itemRepo); var thisItem = app.GetItemById(itemInput); barcodeInput.Item = thisItem.Item; var barcodeOutput = app.SetItemBarcode(barcodeInput); thisItem.Item.Barcode = barcodeOutput.Barcode; updateInput.Item = thisItem.Item; app.UpdateItem(updateInput); } return(itemInput.Id); }
public override IEnumerable <Book> GetAllItems() { using (var repo = new BookRepository()) { var app = new BookAppService(repo); var output = app.GetAllBooks(); return(output.Books.Select(book => book.ConvertToBook()).ToList()); } }
private async Task UpdateBookAsync(BookDto book, IDictionary <string, object> input) { EditingBookDto.Name = input.GetOrDefault("Name") == null ? book.Name : input.GetOrDefault("Name").ToString(); EditingBookDto.Price = input.GetOrDefault("Price") == null ? book.Price : (float)input.GetOrDefault("Price"); EditingBookDto.PublishDate = input.GetOrDefault("PublishDate") == null ? book.PublishDate : (DateTime)input.GetOrDefault("PublishDate"); await BookAppService.UpdateAsync(book.Id, EditingBookDto); await GetBooksAsync(); }
private async Task CreateBookAsync(IDictionary <string, object> input) { NewBookDto.Name = input.GetOrDefault("Name").ToString(); NewBookDto.Price = (float)input.GetOrDefault("Price"); NewBookDto.PublishDate = (DateTime)input.GetOrDefault("PublishDate"); Console.WriteLine(input.GetOrDefault("Type") == null ? "null" : input.GetOrDefault("Type")); await BookAppService.CreateAsync(NewBookDto); await GetBooksAsync(); }
private async Task CreateBookAsync() { try { await BookAppService.CreateAsync(NewBookDto); await GetBooksAsync(); } finally { NewDialogOpen = false; } }
private async Task DeleteBookAsync(BookDto book) { var confirmMessage = L["BookDeletionConfirmationMessage", book.Name]; if (!await Message.Confirm(confirmMessage)) { return; } await BookAppService.DeleteAsync(book.Id); await GetBooksAsync(); }
private async Task UpdateBookAsync() { try { await BookAppService.UpdateAsync(EditingBookId, EditingBookDto); } finally { EditingDialogOpen = false; await GetBooksAsync(); } }
public override int UpdateItem(Book updatedBook) { var input = new UpdateBookInput { Book = new BookDto(updatedBook) }; using (var repo = new BookRepository()) { var app = new BookAppService(repo); return(app.UpdateBook(input).Id); } }
public Book GetBookByIsbn(string isbn) { var input = new GetBookByIsbnInput { Isbn = isbn }; using (var repo = new BookRepository()) { var app = new BookAppService(repo); var output = app.GetBookByIsbn(input); return(output.Book.ConvertToBook()); } }
private async Task GetBooksAsync() { try { Loading = true; await InvokeAsync(() => StateHasChanged()); BookList = await BookAppService.GetListAsync(); } finally { Loading = false; await InvokeAsync(() => StateHasChanged()); } }
public HomeController(BookAppService bookAppService) { _bookAppService = bookAppService; }
public ProductController(AuthorAppService authorAppService, BookAppService bookAppService) { _authorAppService = authorAppService; _bookAppService = bookAppService; }
private async Task GetBooksAsync() { BookList = await BookAppService.GetListAsync(); StateHasChanged(); }