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()); }
public async Task <IActionResult> Create(Book b) { var createBook = await _book.AddAsync(b); if (createBook) { return(RedirectToAction("Index")); } return(View()); }
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" })); } }
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()); }