示例#1
0
        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);
        }
示例#2
0
 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());
     }
 }
示例#3
0
        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();
        }
示例#4
0
        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();
        }
示例#5
0
        private async Task CreateBookAsync()
        {
            try
            {
                await BookAppService.CreateAsync(NewBookDto);

                await GetBooksAsync();
            }
            finally
            {
                NewDialogOpen = false;
            }
        }
示例#6
0
        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();
        }
示例#7
0
        private async Task UpdateBookAsync()
        {
            try
            {
                await BookAppService.UpdateAsync(EditingBookId, EditingBookDto);
            }
            finally
            {
                EditingDialogOpen = false;

                await GetBooksAsync();
            }
        }
示例#8
0
        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);
            }
        }
示例#9
0
        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());
            }
        }
示例#10
0
        private async Task GetBooksAsync()
        {
            try
            {
                Loading = true;

                await InvokeAsync(() => StateHasChanged());

                BookList = await BookAppService.GetListAsync();
            }
            finally
            {
                Loading = false;

                await InvokeAsync(() => StateHasChanged());
            }
        }
示例#11
0
 public HomeController(BookAppService bookAppService)
 {
     _bookAppService = bookAppService;
 }
示例#12
0
 public ProductController(AuthorAppService authorAppService, BookAppService bookAppService)
 {
     _authorAppService = authorAppService;
     _bookAppService   = bookAppService;
 }
示例#13
0
        private async Task GetBooksAsync()
        {
            BookList = await BookAppService.GetListAsync();

            StateHasChanged();
        }