Ejemplo n.º 1
0
 private void UpdateBook(Book book, BookViewModel viewModel)
 {
     book.Id = viewModel.Id;
     book.Author = viewModel.Author;
     book.Name = viewModel.Name;
     book.Published = viewModel.DatePublished.GetValueOrDefault();
     book.Rating = viewModel.Rating;
 }
Ejemplo n.º 2
0
 private BookViewModel ViewModelFromBook(Book book)
 {
     var viewModel = new BookViewModel
         {
             Id = book.Id,
             Name = book.Name,
             Author = book.Author,
             DatePublished = book.Published,
             Rating = book.Rating
         };
     return viewModel;
 }
Ejemplo n.º 3
0
        public ActionResult Create(BookViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                viewModel.Id = Guid.NewGuid();
                var book = new Book();
                UpdateBook(book, viewModel);
                bookRepository.Upsert(book);
                return RedirectToAction("Index");
            }

            return View(viewModel);
        }
 public void Upsert(Book book)
 {
     Books[book.Id] = book;
 }