Ejemplo n.º 1
0
        public IActionResult Books(int numBooks, bool wipeDatabase,
                                   [FromServices] SqlDbContext context,
                                   [FromServices] DbContextOptions <SqlDbContext> options,
                                   [FromServices] IHostingEnvironment env)
        {
            if (numBooks == 0)
            {
                return(View((object)"Error: should contain the number of books to generate."));
            }


            if (wipeDatabase)
            {
                context.DevelopmentWipeCreated(env.WebRootPath);
            }
            options.GenerateBooks(numBooks, env.WebRootPath, numWritten =>
            {
                _progress = numWritten * 100.0 / numBooks;
                return(_cancel);
            });

            SetupTraceInfo();

            return
                (View((object)((_cancel ? "Cancelled" : "Successful") +
                               $" generate. Num books in database = {context.Books.Count()}.")));
        }