Пример #1
0
        public async Task <IActionResult> Create(AuthorCreateVm vm)
        {
            if (ModelState.IsValid)
            {
                var newAuthor = new Author();
                newAuthor.Name = vm.Name;

                authorservice.AddAuthor(newAuthor);

                return(RedirectToAction(nameof(Index)));
            }

            return(RedirectToAction("Error", "Home", ""));
        }
        //// GET: Books/Details/5
        //public async Task<IActionResult> Details(int? id)
        //{
        //    if (id == null)
        //    {
        //        return NotFound();
        //    }

        //    var bookDetails = await _context.BookDetails
        //        .Include(b => b.Author)
        //        .FirstOrDefaultAsync(m => m.ID == id);
        //    if (bookDetails == null)
        //    {
        //        return NotFound();
        //    }

        //    return View(bookDetails);
        //}

        // GET: Books/Create
        public IActionResult Create()
        {
            var vm = new AuthorCreateVm();

            return(View(vm));
        }