public static async Task Save([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "Books/Save")] HttpRequest req, ILogger log)
        {
            using (var reader = new StreamReader(req.Body, Encoding.UTF8))
                using (var context = (new BooksDbContextFactory()).CreateDbContext())
                {
                    var body = reader.ReadToEnd();
                    var book = JsonConvert.DeserializeObject <Book>(body);

                    context.Update(book);
                    context.SaveChanges();

                    await AzureSearchClient.IndexBook(book, log);
                }
        }
        public static async Task Delete([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "Books/Delete/{id}")] HttpRequest req, ILogger log, [FromRoute] int id)
        {
            using (var context = (new BooksDbContextFactory()).CreateDbContext())
            {
                var book = context.Books.FirstOrDefault(b => b.Id == id);
                if (book == null)
                {
                    return;
                }

                context.Books.Remove(book);
                await context.SaveChangesAsync();

                await AzureSearchClient.RemoveBook(book.Id);
            }
        }
        public static async Task <IActionResult> Search([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "Books/Search/{page}/{term}")] HttpRequest req, ILogger log, [FromRoute] string term, [FromRoute] int page)
        {
            var results = await AzureSearchClient.Search(term, page);

            return(new JsonResult(results));
        }