Beispiel #1
0
        public async Task <IActionResult> Create(Book Book)
        {
            Book.CreatedBy   = _userManager.GetUserName(User);
            Book.GenreId     = 1;
            Book.DateCreated = DateTime.Now;
            var createBook = await _book.AddAsync(Book);

            //if (createBook)
            //{
            //    return RedirectToAction("Index");
            //}

            if (createBook)
            {
                Alert("Book created successfully.", NotificationType.success);
                return(RedirectToAction("Index"));
            }
            else
            {
                Alert("Book not created!", NotificationType.error);
            }


            return(View());
        }
Beispiel #2
0
        public async Task <IActionResult> Create(Book b)
        {
            var createBook = await _book.AddAsync(b);

            if (createBook)
            {
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Beispiel #3
0
        public async Task <IActionResult> AddBook([FromBody] Book book)
        {
            var createBook = await _book.AddAsync(book);

            if (createBook)
            {
                return(Ok("Book Created"));
            }
            else
            {
                return(BadRequest(new { message = "Book details cannot be created" }));
            }
        }
Beispiel #4
0
        public async Task <IActionResult> Create(Book book)
        {
            book.CreatedBy = _userManager.GetUserName(User);

            var createBook = await _book.AddAsync(book);

            if (createBook)
            {
                Alert("Book created successfully.", NotificationType.success);
                return(RedirectToAction("Index"));
            }
            Alert("Book not created!", NotificationType.error);
            return(View());
        }
        public async Task <IActionResult> Create(Book b)
        {
            b.CreatedBy = _userManager.GetUserName(User);

            b.DateCreated = DateTime.Now;

            var createBook = await _book.AddAsync(b);

            if (createBook)
            {
                Alert("Book Created successfully.", NotificationType.success);
                return(RedirectToAction("Index"));
            }
            return(View());
        }