private async Task GetAsync(string id, IEnumerable <DatosDefectoItemModel> entidades, CancellationToken cancellationToken, ContextService _context)
        {
            var context = _context;

            context.BaseDatos = id;
            var serviceConfiguracion = new ConfiguracionService(context);

            //serviceConfiguracion.SetCargaDatos(1);

            try
            {
                cancellationToken.ThrowIfCancellationRequested();

                using (var service = new StartupService(context, id))
                {
                    await Task.Run(() => service.CreateDatosDefecto(entidades));

                    serviceConfiguracion.SetCargaDatos(2);
                    return;
                }
            }
            catch (TaskCanceledException tce)
            {
                serviceConfiguracion.SetCargaDatos(-1);
            }
            catch (Exception ex)
            {
                serviceConfiguracion.SetCargaDatos(-1);
            }
        }
        public ActionResult DatosDefecto(string id, IEnumerable <DatosDefectoItemModel> model)
        {
            var context = new ContextService();

            context.BaseDatos = id;
            using (var service = new StartupService(context, id))
            {
                var serviceConfiguracion = new ConfiguracionService(context);
                serviceConfiguracion.SetCargaDatos(1);

                if (model != null)
                {
                    //service.CreateDatosDefecto(model);
                    HostingEnvironment.QueueBackgroundWorkItem(async token => await GetAsync(id, model, token, context));
                }



                return(RedirectToAction("Empresa", new { id }));
            }
        }