Ejemplo n.º 1
0
        public ActionResult Create(BookViewModel viewModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(viewModel));
                }

                using (var uOw = new UnitOfWork())
                {
                    uOw.BeginTransaction();
                    var bookRepository = new BookRepository(uOw);
                    var bookService    = new BookService(bookRepository);
                    bookService.CreateNewBook(viewModel.GetBookRequest());
                    uOw.Commit();
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.Exception = ex.Message;
                return(View(viewModel));
            }
        }