Esempio n. 1
0
        public static async Task SeedDBAsync(IServiceProvider serviceProvider, bd_lesContext context, string uid)
        {
            var roleManager = serviceProvider.GetService <RoleManager <IdentityRole> >();

            foreach (KeyValuePair <string, string> entry in Constants.CategoryRoles)
            {
                if (!await roleManager.RoleExistsAsync(entry.Key))
                {
                    await roleManager.CreateAsync(new IdentityRole(entry.Key));
                }
            }

            //if (context.Contact.Any())
            //{
            //    return;   // DB has been seeded
            //}

            //context.Contact.AddRange(
            //#region snippet_Contact
            //    new Contact
            //    {
            //        Name = "Debra Garcia",
            //        Address = "1234 Main St",
            //        City = "Redmond",
            //        State = "WA",
            //        Zip = "10999",
            //        Email = "*****@*****.**",
            //        Status = ContactStatus.Approved,
            //        OwnerID = adminID
            //    },
            //#endregion
            // );

            if (context.RegNovosAnimais.Any())
            {
                return; //DB already seeded
            }

            //var userManager = serviceProvider.GetService<UserManager<ApplicationUsers>>();

            //var user = await userManager.FindByIdAsync(uid);

            //context.RegNovosAnimais.AddRange(
            //    new RegNovosAnimais
            //    {
            //        NroExemplares = 2,
            //        NroMachos = 1,
            //        NroFemeas = 1,
            //        Imaturos = 0,
            //        Juvenis = 0,
            //        Larvas = 0,
            //        Ovos = 0,
            //        DataNasc = new DateTime(2017, 08, 22),
            //        Idade = 22,
            //        PesoMedio = 1,
            //        CompMedio = 45,
            //        DuracaoViagem = new TimeSpan(1220),
            //        TempPartida = 2,
            //        TempChegada = 3,
            //        NroContentores = 3,
            //        TipoContentor = "sakura",
            //        VolContentor = (float)2.3,
            //        VolAgua = (float)1.2,
            //        NroCaixasIsoter = 2,
            //        NroMortosCheg = 0,
            //        SatO2transp = (float)0.11,
            //        Anestesico = 1,
            //        Gelo = 0,
            //        AdicaoO2 = 0,
            //        Arejamento = 0,
            //        Refrigeracao = 1,
            //        sedacao = 0,
            //        RespTransporte = "DHL",
            //        EspecieIdEspecie = 1,
            //        FornecedorIdFornColect = 1,
            //        TOrigemIdTOrigem = 1,
            //        LocalCapturaIdLocalCaptura = 1,
            //        TipoEstatutoGeneticoIdTipoEstatutoGenetico = 1,
            //        FuncionarioIdFuncionario = user.FuncionarioIdFuncionario,
            //        FuncionarioIdFuncionario1 = user.FuncionarioIdFuncionario
            //    }
            //    );

            context.SaveChanges();
        }