Update() public method

public Update ( ) : void
return void
Ejemplo n.º 1
0
        public void UpdateStat()
        {
            _book.Populate(@"FOR: -1").Should().BeEmpty();
            _book.Update("FOR: 17").Should().BeEmpty();

            _statService.GetValue("FOR").Should().Be(17);
        }
Ejemplo n.º 2
0
        public ActionResult UpdateBook(int id)
        {
            Book foundBook = Book.Find(id);

            foundBook.Update(Request.Form["book-title"]);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public static void Update(ContextDB db)
        {
            Console.WriteLine(Utilities.Messages.OutputMessages.InfoStringForTable);
            string table = Console.ReadLine();

            switch (table)
            {
            case "Genres":
                string[] input = ReadingInputGenreAndAuthor();
                Genre    genre = new Genre(int.Parse(input[0]) /*id*/, input[1] /*name*/);
                genre.Update(db);
                break;

            case "Authors":
                input = ReadingInputGenreAndAuthor();
                Author author = new Author(int.Parse(input[0]) /*id*/, input[1] /*name*/);
                author.Update(db);
                break;

            case "Books":
                input = ReadingInputBook();
                Book book = new Book(int.Parse(input[0]) /*id*/, input[1] /*name*/, int.Parse(input[2]) /*ISBN*/, int.Parse(input[3]) /*GenreID*/);
                book.Update(db);
                break;

            default:
                Console.WriteLine(Utilities.Messages.ExceptionMessages.IncorrectInputMessege);
                break;
            }
        }
Ejemplo n.º 4
0
        public ActionResult Update(int bookId)
        {
            Book thisBook = Book.Find(bookId);

            thisBook.Update(Request.Form["newTitle"], Request.Form["newAuthor"], (Convert.ToInt32(Request.Form["newCopies"])), Request.Form["newDescription"]);
            return(RedirectToAction("Index"));
        }
        public Book UpdateBook(ChgBook book)
        {
            return(repo.Transaction(() =>
            {
                Book entity = Book.FindById(repo, book.Id);

                if (entity != null)
                {
                    entity.Title = book.Title;
                    entity.Isbn = book.Isbn;

                    Category category = Category.FindById(repo, book.CategoryId);
                    Format format = Format.FindById(repo, book.FormatId);

                    if (category != null && format != null)
                    {
                        entity.Category = category;
                        entity.Format = format;
                        entity.Update(repo);
                        return entity;
                    }
                    return null;
                }
                return null;
            }));
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        private bool Update(string id, string description)
        {
            var logic = new Book();

            return(logic.Update(new Example_Models.Entities.Book {
                ID = id, Description = description
            }));
        }
Ejemplo n.º 7
0
        public void Update_UpdatesBookinDB_True()
        {
            Book newBook = new Book("Carrie");

            newBook.Save();
            newBook.Update("It");
            Book foundBook = Book.Find(newBook.GetId());

            Assert.Equal(newBook, foundBook);
        }
Ejemplo n.º 8
0
        public async Task <ActionResult> Update(int id, [FromBody] BookEditModel model)
        {
            Book book = await booksService.Find(id);

            if (book == null)
            {
                return(NotFound());
            }
            book.Update(model);
            return(Ok(await booksService.Update(book)));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 書籍情報を更新する
 /// </summary>
 /// <param name="v">コマンド引数</param>
 private void UpdateBook(object v)
 {
     if (Book.ValidationCheck())
     {
         if (UserConfirm("確認", "書籍情報を更新しますか?", MessageBoxButton.YesNo, MessageBoxImage.Question))
         {
             // 更新処理
             Book.Update();
             InvokeCloseView(true);
         }
     }
 }
Ejemplo n.º 10
0
 public void Put(int id, [FromBody] Book book)
 {
     try
     {
         IUpdate bookDetail = new Book();
         bookDetail.Update(id, book);
     }
     catch (Exception ex)
     {
         _logger.LogError(string.Format("BookController => PUT   Error Occured at: {0}{1}Error Details: {2}", DateTime.Now, Environment.NewLine, ex.InnerException.Message));
     }
 }
Ejemplo n.º 11
0
        public void Test_UpdateBookInDatabase()
        {
            string testName = "The Greats of Wrath";
            Book   testBook = new Book(testName, "Lorem ipsuM");

            testBook.Save();
            string newName = "The Grapes of Wrath";

            testBook.Update(newName, "Lorem ipsum");
            string result = testBook.Title;

            Assert.Equal(newName, result);
        }
Ejemplo n.º 12
0
        public void Update(Guid id, BookCommand bookCommand)
        {
            Book book = _booksRepository.Find(id);

            if (book == null)
            {
                throw new Exception();
            }

            book.Update(bookCommand);
            _booksValidator.Validate(book);
            _booksRepository.Update(book);
        }
Ejemplo n.º 13
0
        public ActionResult UpdateBook(string title, string author, string cost, string totalCount, int id)
        {
            Book  foundBook = Book.Find(id);
            float costFloat = float.Parse(cost);
            int   totalInt  = int.Parse(totalCount);

            foundBook.Update(title, totalInt, costFloat);
            if (author != null)
            {
                int authorId = int.Parse(author);
                foundBook.AddAuthor(authorId);
            }
            return(View("Books", foundBook));
        }
Ejemplo n.º 14
0
        public ActionResult BookDetailsUpdate(int id)
        {
            Book foundBook = Book.Find(id);

            foundBook.AddCopies(int.Parse(Request.Form["copies"]));

            string   newTitle   = Request.Form["title"];
            string   newGenre   = Request.Form["genre"];
            DateTime newPubDate = DateTime.Parse(Request.Form["publish-date"]);

            foundBook.Update(newTitle, newGenre, newPubDate);

            return(View("Books", Book.GetAll()));
        }
Ejemplo n.º 15
0
        public void Update_UpdatesBookInformationInDatabase_Book()
        {
            DateTime publishDate = DateTime.Now;
            Book     newBook     = new Book("Eye of the World", "Fantasy", publishDate);

            newBook.Save();

            newBook.Update("The Name of the Wind", "Fantasy", publishDate);

            Book expected = newBook;
            Book actual   = Book.Find(newBook.GetId());

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 16
0
        public void Update_ReturnsAllBooksMatchingUpdateTerm_BookList()
        {
            //Arrange
            Book testBook = new Book("db");

            testBook.Save();

            testBook.Update("rdbms");
            Book expected = new Book("rdbms", testBook.GetId());
            //Act
            Book actual = Book.GetAll()[0];

            //Assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 17
0
        public void Update_UpdatesBookInDatabase_String()
        {
            //Arrange
            Book testBook = new Book("The Alchemist");

            testBook.Save();
            string secondName = "The Zahir";

            //Act
            testBook.Update("title", secondName);
            string result = Book.Find(testBook.GetId()).GetTitle();

            //Assert
            Assert.AreEqual(secondName, result);
        }
Ejemplo n.º 18
0
        public void Update_UpdatesBookTitle_Book()
        {
            Book newBook = new Book("Harry Potter");

            newBook.Save();

            newBook.Update("Harry Potter and the Sorcerers Stone");

            Book newBook2 = new Book("Harry Potter and the Sorcerers Stone");

            var expected = newBook2.GetTitle();
            var actual   = Book.Find(newBook.GetId()).GetTitle();

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 19
0
        public void Update_UpdatesBookInDatabase_String()
        {
            //arrange
            string firstTitle = "Consider";
            Book   testBook   = new Book(firstTitle);

            testBook.Save();
            string secondTitle = "Consider Phlebas";

            //act
            testBook.Update(secondTitle);
            string result = Book.Find(testBook.GetId()).GetTitle();

            //Assert
            Assert.AreEqual(secondTitle, result);
        }
Ejemplo n.º 20
0
        public async Task <int> Handle(UpdateBookCommand request, CancellationToken cancellationToken)
        {
            Book book = await _db.Books.FindAsync(request.BookId);

            if (book == null)
            {
                throw new NotFoundException(nameof(UpdateBookCommand), request.BookId);
            }
            else
            {
                book.Update(request.Title, request.Author, request.PublishedDate, request.BookFormat);

                await _db.SaveChangesAsync(cancellationToken);

                return(book.BookId);
            }
        }
Ejemplo n.º 21
0
        public ICommandResult Handler(UpdateBookCommand command)
        {
            Book book = _bookRepository.GetById(command.BookId);

            if (!(book.User.Id == command.UserId))
            {
                AddNotification("User", "O usuário não tem permissão para alterar essa reserva.");
            }
            book.Update(command.BookDate);
            AddNotifications(book.Notifications);
            if (!IsValid())
            {
                return(null);
            }
            _bookRepository.Update(book);
            return(new StandardBookCommandResult(book.Id, DateTime.Now));
        }
Ejemplo n.º 22
0
        public RedirectToRouteResult Update()
        {
            List <Author> Authors = new List <Author>();

            if (TempData["authors"] != null)
            {
                foreach (var au in TempData["authors"] as List <string> )
                {
                    Authors.Add(new Author
                    {
                        Aid = Convert.ToInt32(au)
                    });
                }
            }

            Book.Update(Convert.ToString(TempData["title"]), Convert.ToString(TempData["isbn"]),
                        Convert.ToString(TempData["pubYear"]), Convert.ToString(TempData["info"]),
                        Convert.ToInt16(TempData["pages"]), Authors);
            return(RedirectToAction("Index", "Books"));
        }
Ejemplo n.º 23
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Button btn     = ((Button)sender);
            var    command = btn.CommandName;

            if (command != "Update")
            {
                Book book = new Book();
                book.Name     = tbxName.Text;
                book.Price    = tbxPrice.Text;
                book.Amount   = tbxAmount.Text;
                book.Status   = rblStatus.SelectedValue;
                book.Date     = DateTime.Parse(tbxDate.Text);
                book.Pay      = rblPay.SelectedValue;
                book.Transfer = tbxTransfer.Text;
                book.Deliver  = rblDeliver.SelectedValue;

                int count = book.Insert();
                if (count > 0)
                {
                    Response.Redirect("List.aspx");
                }
            }
            else
            {
                Book book = new Book(int.Parse(btn.CommandArgument));
                book.Name     = tbxName.Text;
                book.Price    = tbxPrice.Text;
                book.Amount   = tbxAmount.Text;
                book.Status   = rblStatus.SelectedValue;
                book.Date     = DateTime.Parse(tbxDate.Text);
                book.Pay      = rblPay.SelectedValue;
                book.Transfer = tbxTransfer.Text;
                book.Deliver  = rblDeliver.SelectedValue;
                int count = book.Update();
                if (count > 0)
                {
                    Response.Redirect("List.aspx");
                }
            }
        }
Ejemplo n.º 24
0
        public void UpdateBookFromBookCommand()
        {
            var book = new Book(Guid.NewGuid(), "Wrong Title", "368–22–987–3658–5", 1990, "Wrong Author", "Wrong Category");

            var bookCommand = new BookCommand()
            {
                Title      = "Book",
                ISBN       = "978–85–333–0227–3",
                LaunchYear = DateTime.Now.Year,
                Author     = "Author",
                Category   = "Category"
            };

            book.Update(bookCommand);

            Assert.Equal(book.Title, bookCommand.Title);
            Assert.Equal(book.ISBN, bookCommand.ISBN);
            Assert.Equal(book.LaunchYear, bookCommand.LaunchYear);
            Assert.Equal(book.Author, bookCommand.Author);
            Assert.Equal(book.Category, bookCommand.Category);
        }
Ejemplo n.º 25
0
 public string JSONData(string id)
 {
     Book knjiga = new Book("Knjiga test", "Desa", 1990, "sloven", "poezi", "dostopno na spletu");
     string ret = "";
     if (id == "DODAJ")
     {
         ret = knjiga.AddNewBook();
     }
     else if (id == "UREDI")
     {
         ret = knjiga.Update("Knjiga test", "Desa", 2000, "sloven", "poezi", "dostopno na spletu");
     }
     else if(id=="IZPIS")
     {
         ret = knjiga.ToString();
     }
     else if(id=="DELETE")
     {
         ret = knjiga.Delete(5);
     }
     return ret;
 }
Ejemplo n.º 26
0
        public Book JSONData(string id,string naslov, string avtor, string gradivo, string leto, string jezik, string zalozba)
        {
            Book knjiga = new Book(naslov, avtor, leto, jezik, gradivo, zalozba);
            string ret = "";
            if (id == "DODAJ")
            {
                ret = knjiga.AddNewBook();
            }
            else if (id == "UREDI")
            {
                ret = knjiga.Update(naslov, avtor, leto, jezik, gradivo, zalozba);
            }
            else if (id == "IZPIS")
            {
                ret = knjiga.ToString();
            }
            else if (id == "DELETE")
            {
                ret = knjiga.Delete(5);
            }

            return knjiga;
        }
Ejemplo n.º 27
0
 public IActionResult UpdateBook(int id, string newName)
 {
     Book.Update(newName, id);
     return(RedirectToAction("LibrarianIndex"));
 }
Ejemplo n.º 28
0
 public ActionResult Update(Book b)
 {
     b.Update();
     return(RedirectToAction("ShowAll"));
 }