public IActionResult AddNewBook(BookModel model)
        {
            if (ModelState.IsValid)
            {
                var id = _bookStation.AddNewBook(model);
                if (id > 0)
                {
                    return(RedirectToAction(nameof(AddNewBook), new { IsSuccess = true, bookId = id }));
                }
            }

            var languages = new SelectList(_languageStation.GetLanguage(), "Id", "Name");

            ViewBag.Languages = languages;
            return(View());
        }
Exemplo n.º 2
0
        public IActionResult AddNewBook(BookModel model)
        {
            if (ModelState.IsValid)
            {
                var id = _bookStation.AddNewBook(model);
                if (id > 0)
                {
                    return(RedirectToAction(nameof(AddNewBook), new { IsSuccess = true, bookId = id }));
                }

                ModelState.AddModelError("", "This is First Custom Error Message");
                ModelState.AddModelError("", "This is Second Custom Error Message");
            }

            var languages = new SelectList(_languageStation.GetLanguage(), "Id", "Name");

            ViewBag.Language = languages;

            return(View());
        }