public async Task <IActionResult> Get() { try { BooksContext context = HttpContext.RequestServices.GetService(typeof(BooksContext)) as BooksContext; List <Book> list = await context.GetAllBooks(); return(Ok(list)); } catch (Exception e) { return(BadRequest(new BadRequestResponse("Error getting list of moods from database"))); } }