using System.Diagnostics; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; using Bookstore.Web.ViewModel; using Bookstore.Domain.Books; using System.Threading.Tasks; using Bookstore.Web.ViewModel.Home; namespace Bookstore.Web.Controllers { [AllowAnonymous] public class HomeController : Controller { private readonly IBookService bookService; public HomeController(IBookService bookService) { this.bookService = bookService; } public async Task Index() { var books = await bookService.ListBestSellingBooksAsync(4); return View(new HomeIndexViewModel(books)); } public IActionResult Privacy() { return View(); } public IActionResult Search() { return RedirectToAction("Index", "Search"); } public IActionResult Cart() { return RedirectToAction("Index", "ShoppingCart"); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } } }