Example #1
0
        public void Delete(string cwid, int id)
        {
            Console.WriteLine("Made it to the delete with cwid " + cwid + " and id " + id);
            IDeleteBook delete = new DeleteBook();

            delete.Delete(id);
        }
        public void Handle(DeleteBook cmd)
        {
            var book = repo.GetById <Book>(cmd.Id);

            book.Delete();
            Save(book, by: cmd);
        }
Example #3
0
        public DeleteBookShould()
        {
            _bookServiceMock = new Mock <IBookService>();
            _loggerMock      = new Mock <ILogger <DeleteBook> >();
            _httpRequestMock = new Mock <HttpRequest>();

            _func = new DeleteBook(
                _bookServiceMock.Object,
                _loggerMock.Object);
        }
        public async Task <IActionResult> Delete(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(BadRequest());
            }

            var command = new DeleteBook(id, UserId);
            await Mediator.Send(command);

            return(Ok());
        }
Example #5
0
        public async Task <ActionResult> DeleteConfirm(DeleteBook model)
        {
            if (ModelState.IsValid)
            {
                // silme islemini yap
                await _booksService.Delete(model.Id);
            }
            // ve

            // liste sayfasina gonder
            return(RedirectToAction("Index", "Books"));
        }
        public async Task Handle(DeleteBook message, CancellationToken cancellationToken)
        {
            var oldBook = await BookEntityHandler.Get(message.Id);

            if (oldBook == null)
            {
                throw new EntityNotFoundException <Book>(message.Id);
            }

            BookEntityHandler.Delete(oldBook);

            await Mediator.Send(new SaveChanges());

            await Mediator.Publish(new BookRemoved(oldBook, message.UserId));
        }
Example #7
0
        public IActionResult Delete(DeleteBook model)
        {
            if (ModelState.IsValid)
            {
                var result = new DeleteBookResult();
                result = Helper.ApiHelper <DeleteBookResult> .HttpPostAsync("api/Book/Delete", "POST", model);

                if (result.BookId > 0)
                {
                    return(RedirectToAction("index"));
                }
                ModelState.AddModelError("", result.Message);
                return(View(model));
            }
            return(View(model));
        }
Example #8
0
        public int DeleteBook(DeleteBook model)
        {
            int rowAffected = 0;

            try
            {
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("@Id", model.Id);
                rowAffected = SqlMapper.Execute(con, "sp_DeleteBook", param: parameters, commandType: CommandType.StoredProcedure);
                return(rowAffected);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #9
0
        private void DelBook(object sender, RoutedEventArgs e)

        {
            Buch sel = BuchGrid.SelectedItem as Buch;

            if (sel == null)
            {
                MessageBox.Show("Bitte zunächst einen Titel auswählen!");
                return;
            }
            var erg = MessageBox.Show("Möchten Sie das Buch '" + sel.Titel + "' wirklich löschen?", "Buch löschen!", MessageBoxButton.YesNo);

            if (erg == MessageBoxResult.Yes)
            {
            }
            if (DeleteBook.delBook(cBookID))
            {
                LoadBooks();

                MessageBox.Show("Buch wurde gelöscht.");
            }
        }
 public BookViewModel(MainViewModel mainViewModel)
 {
     Books       = new ObservableCollection <BookEntity>();
     filials     = new List <FilialEntity>();
     BuyBookCMD  = new BuyBook(mainViewModel, this);
     RentCMD     = new Rent(mainViewModel, this);
     addBook     = new AddBook(this);
     DeleteBook  = new DeleteBook(this);
     UpdateBook  = new UpdateBook(this);
     currentbook = new BookEntity();
     selectbook  = new BookEntity();
     //if (File.Exists("Filials.json"))
     //{
     //    string jsonFilial = File.ReadAllText("Filials.json");
     //   this.filials = JsonConvert.DeserializeObject<List<FilialEntity>>(jsonFilial);
     //}
     //if (File.Exists("Books.json"))
     //{
     //    string jsonBook = File.ReadAllText("Books.json");
     //    this.Books = JsonConvert.DeserializeObject<ObservableCollection<BookEntity>>(jsonBook);
     //}
 }
Example #11
0
        public void Delete(int id)
        {
            IDeleteBook deleteObject = new DeleteBook();

            deleteObject.RemoveBook(id);
        }
Example #12
0
 public IActionResult DeleteBook(DeleteBook model)
 {
     _bookRepository.DeleteBook(model);
     return(RedirectToAction("BooksList", "Book"));
 }