//Create [email protected] with password=Admin@123456 in the Admin role        
        public static void InitializeIdentityForEF(ApplicationDbContext db)
        {
            var userManager = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
            var roleManager = HttpContext.Current.GetOwinContext().Get<ApplicationRoleManager>();
            const string nombre = "William Gustavo";
            const string apellido = "Santisteban";
            const bool estado = true;
            const string name = "*****@*****.**";
            const string password = "******";
            const string roleName = "Admin";

            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(roleName);
            if (role == null)
            {
                role = new ApplicationRole(roleName);
                var roleresult = roleManager.Create(role);
            }

            var user = userManager.FindByName(name);
            if (user == null)
            {
                user = new ApplicationUser { UserName = name, Email = name, Nombre = nombre, Apellido = apellido, Estado = estado, EmailConfirmed = true };
                var result = userManager.Create(user, password);
                result = userManager.SetLockoutEnabled(user.Id, false);

            }

            var groupManager = new GrupoManager();
            var newGroup = new ApplicationGroup("Administradores", "Acceso General al Sistema");

            groupManager.CreateGroup(newGroup);
            groupManager.SetUserGroups(user.Id, new string[] { newGroup.Id });
            groupManager.SetGroupRoles(newGroup.Id, new string[] { role.Name });

            var PermisosUsuario = new List<ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Usuario"
                },
                new ApplicationRole {
                    Name = "Editar_Usuario"
                },
                new ApplicationRole {
                    Name = "Detalle_Usuario"
                },
                new ApplicationRole {
                    Name = "Eliminar_Usuario"
                },
                new ApplicationRole {
                    Name = "AllUsuarios"
                }
            };
            PermisosUsuario.ForEach(c => db.Roles.Add(c));


            var PermisosGrupo = new List<ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Grupo"
                },
                new ApplicationRole {
                    Name = "Editar_Grupo"
                },
                new ApplicationRole {
                    Name = "Detalle_Grupo"
                },
                new ApplicationRole {
                    Name = "Eliminar_Grupo"
                },
                new ApplicationRole {
                    Name = "AllGrupos"
                }
            };
            PermisosGrupo.ForEach(c => db.Roles.Add(c));


            var PermisosAcciones = new List<ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Permiso"
                },
                new ApplicationRole {
                    Name = "Editar_Permiso"
                },
                new ApplicationRole {
                    Name = "Detalle_Permiso"
                },
                new ApplicationRole {
                    Name = "Eliminar_Permiso"
                },
                new ApplicationRole {
                    Name = "AllPermisos"
                }
            };
            PermisosUsuario.ForEach(c => db.Roles.Add(c));

            var PermisosAutos = new List<ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Auto"
                },
                new ApplicationRole {
                    Name = "Editar_Auto"
                },
                new ApplicationRole {
                    Name = "Detalle_Auto"
                },
                new ApplicationRole {
                    Name = "Eliminar_Auto"
                },
                new ApplicationRole {
                    Name = "AllAutos"
                }
            };
            PermisosAutos.ForEach(c => db.Roles.Add(c));


            var grupos = new List<ApplicationGroup> {
                new ApplicationGroup {
                    Name = "Gestionar Usuarios",
                    Description = "Gestionar Usuarios"
                },
                new ApplicationGroup {
                    Name = "Gestionar Grupos",
                    Description = "Gestionar Grupos"
                },
                new ApplicationGroup {
                    Name = "Gestionar Acciones",
                    Description = "Gestionar Acciones"
                },
                new ApplicationGroup {
                    Name = "Gestionar Autos",
                    Description = "Gestionar Autos"
                },
             };
            grupos.ForEach(c => db.ApplicationGroups.Add(c));

            var autos = new List<Auto> {
                new Auto {
                    Marca = "BMW",
                    Modelo = "Serie 3",
                    Precio ="720.000",
                    Kilometros = 22000,
                    Imagen = "~/Content/img/bmw_auto.jpg"
                },
                new Auto {
                    Marca = "BMW",
                    Modelo = "Serie 3 Executive Premiun",
                    Precio ="830.000",
                    Kilometros = 15000,
                    Imagen = "~/Content/img/bmw_rojo.jpg"
                },
                new Auto {
                    Marca = "BMW",
                    Modelo = "Serie 1",
                    Precio ="650.000",
                    Kilometros = 86000,
                    Imagen = "~/Content/img/bmw_auto2.jpg"
                },
                new Auto {
                    Marca = "Mercedes Benz",
                    Modelo = "Clase C",
                    Precio ="975.000",
                    Kilometros = 15000,
                    Imagen = "~/Content/img/mercedes_benz.jpg"
                }
            };
            autos.ForEach(c => db.Autos.Add(c));
        }
        //Create [email protected] with password=Admin@123456 in the Admin role
        public static void InitializeIdentityForEF(ModeloContainer db)
        {
            var          userManager = HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var          roleManager = HttpContext.Current.GetOwinContext().Get <ApplicationRoleManager>();
            const string nombre      = "Sebastian";
            const string apellido    = "Zeballos";
            const bool   estado      = true;
            const string name        = "*****@*****.**";
            const string password    = "******";
            const string roleName    = "Admin";

            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(roleName);

            if (role == null)
            {
                role = new ApplicationRole(roleName);
                var roleresult = roleManager.Create(role);
            }

            var user = userManager.FindByName(name);

            if (user == null)
            {
                user = new ApplicationUser {
                    UserName = name, Email = name, Nombre = nombre, Apellido = apellido, Estado = estado, EmailConfirmed = true
                };
                var result = userManager.Create(user, password);
                result = userManager.SetLockoutEnabled(user.Id, false);
            }

            var groupManager = new GrupoManager();
            var newGroup     = new ApplicationGroup("Administradores", "Acceso General al Sistema");

            groupManager.CreateGroup(newGroup);
            groupManager.SetUserGroups(user.Id, new string[] { newGroup.Id });
            groupManager.SetGroupRoles(newGroup.Id, new string[] { role.Name });

            var PermisosUsuario = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Usuario"
                },
                new ApplicationRole {
                    Name = "Editar_Usuario"
                },
                new ApplicationRole {
                    Name = "Detalle_Usuario"
                },
                new ApplicationRole {
                    Name = "Eliminar_Usuario"
                },
                new ApplicationRole {
                    Name = "AllUsuarios"
                }
            };

            PermisosUsuario.ForEach(c => db.Roles.Add(c));


            var PermisosGrupo = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Grupo"
                },
                new ApplicationRole {
                    Name = "Editar_Grupo"
                },
                new ApplicationRole {
                    Name = "Detalle_Grupo"
                },
                new ApplicationRole {
                    Name = "Eliminar_Grupo"
                },
                new ApplicationRole {
                    Name = "AllGrupos"
                }
            };

            PermisosGrupo.ForEach(c => db.Roles.Add(c));


            var PermisosAcciones = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Permiso"
                },
                new ApplicationRole {
                    Name = "Editar_Permiso"
                },
                new ApplicationRole {
                    Name = "Detalle_Permiso"
                },
                new ApplicationRole {
                    Name = "Eliminar_Permiso"
                },
                new ApplicationRole {
                    Name = "AllPermisos"
                }
            };

            PermisosUsuario.ForEach(c => db.Roles.Add(c));


            var grupos = new List <ApplicationGroup> {
                new ApplicationGroup {
                    Name        = "Gestionar Usuarios",
                    Description = "Gestionar Usuarios"
                },
                new ApplicationGroup {
                    Name        = "Gestionar Grupos",
                    Description = "Gestionar Grupos"
                },
                new ApplicationGroup {
                    Name        = "Gestionar Acciones",
                    Description = "Gestionar Acciones"
                },
            };

            grupos.ForEach(c => db.ApplicationGroups.Add(c));
        }
        public static void InitializeIdentityForEF(ApplicationDbContext db)
        {
            var userManager = HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var roleManager = HttpContext.Current.GetOwinContext().Get <ApplicationRoleManager>();
            //Admnistrador
            const string nombre   = "William Gustavo";
            const bool   estado   = true;
            const string name     = "*****@*****.**";
            const string password = "******";
            const string roleName = "Admin";

            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(roleName);

            if (role == null)
            {
                role = new ApplicationRole(roleName);
                var roleresult = roleManager.Create(role);
            }

            var user = userManager.FindByName(name);

            if (user == null)
            {
                user = new ApplicationUser {
                    UserName = name, Email = name, Nombre = nombre, Estado = estado, EmailConfirmed = true
                };
                var result = userManager.Create(user, password);
                result = userManager.SetLockoutEnabled(user.Id, false);
            }

            var groupManager = new GrupoManager();
            var newGroup     = new ApplicationGroup("Administradores", "Acceso General al Sistema");

            groupManager.CreateGroup(newGroup);
            groupManager.SetUserGroups(user.Id, new string[] { newGroup.Id });
            groupManager.SetGroupRoles(newGroup.Id, new string[] { role.Name });
            //Fin Admnistrador

            var provincias = new List <Provincia> {
                new Provincia {
                    Description = "Buenos Aires"
                },
                new Provincia {
                    Description = "Santa Fé"
                },
                new Provincia {
                    Description = "Entre Rios"
                },
                new Provincia {
                    Description = "Cordoba"
                }
            };

            provincias.ForEach(c => db.Provincias.Add(c));

            var localidades = new List <Localidad>
            {
                new Localidad {
                    Description  = "Rosario",
                    CodigoPostal = 2000,
                    Estado       = true,
                    Provincia    = provincias[0]
                },
                new Localidad {
                    Description  = "Roldan",
                    CodigoPostal = 2010,
                    Estado       = true,
                    Provincia    = provincias[0]
                },
                new Localidad {
                    Description  = "Funes",
                    CodigoPostal = 2005,
                    Estado       = true,
                    Provincia    = provincias[0]
                }
            };

            localidades.ForEach(c => db.Localidades.Add(c));

            var categoriaasoc = new List <CategoriaAsociado>
            {
                new CategoriaAsociado {
                    DescripcionCategoria = "Ministerio de Salud",
                    Estado = true
                },
                new CategoriaAsociado {
                    DescripcionCategoria = "Ministerio de Educación",
                    Estado = true
                },
                new CategoriaAsociado {
                    DescripcionCategoria = "Ministerio de Justicia",
                    Estado = true
                },
                new CategoriaAsociado {
                    DescripcionCategoria = "Ministerio de Trabajo",
                    Estado = true
                },
            };

            categoriaasoc.ForEach(c => db.CategoriaAsociado.Add(c));

            var profesiones = new List <Profesion>
            {
                new Profesion
                {
                    Descripcion = "Ingenieria en Sistemas",
                    Estado      = true,
                },
                new Profesion
                {
                    Descripcion = "Arquitecto",
                    Estado      = true,
                },
                new Profesion
                {
                    Descripcion = "Diseñador Gráfico",
                    Estado      = true,
                },
                new Profesion
                {
                    Descripcion = "Herrero",
                    Estado      = true,
                },
            };

            profesiones.ForEach(c => db.Profesiones.Add(c));

            var sexo = new List <Sexo>
            {
                new Sexo
                {
                    Descripcion = "Hombre",
                    Estado      = true,
                },
                new Sexo
                {
                    Descripcion = "Mujer",
                    Estado      = true,
                },
                new Sexo
                {
                    Descripcion = "No Aplica",
                    Estado      = true,
                },
            };

            sexo.ForEach(c => db.Sexo.Add(c));

            var tipodocumento = new List <TipoDocumento>
            {
                new TipoDocumento
                {
                    Descripcion = "DNI",
                    Estado      = true,
                },
                new TipoDocumento
                {
                    Descripcion = "Pasaporte",
                    Estado      = true,
                },
                new TipoDocumento
                {
                    Descripcion = "Libreta Errolamiento",
                    Estado      = true,
                },
                new TipoDocumento
                {
                    Descripcion = "Cedula de Identidad",
                    Estado      = true,
                },
            };

            tipodocumento.ForEach(c => db.TipoDocumento.Add(c));

            var estadocivil = new List <EstadoCivil>
            {
                new EstadoCivil
                {
                    Descripcion = "Soltero",
                    Estado      = true
                },
                new EstadoCivil
                {
                    Descripcion = "Casado",
                    Estado      = true
                },
                new EstadoCivil
                {
                    Descripcion = "Viudo",
                    Estado      = true
                },
                new EstadoCivil
                {
                    Descripcion = "Divorciado",
                    Estado      = true
                },
            };

            estadocivil.ForEach(c => db.EstadoCivil.Add(c));

            var entidad = new List <Entidad>
            {
                new Entidad
                {
                    Descripcion = "Entidad de Prestamo 1",
                    Comision    = 35M,
                    Estado      = true
                },
                new Entidad
                {
                    Descripcion = "Entidad de Prestamo 2",
                    Comision    = 15M,
                    Estado      = true
                },
                new Entidad
                {
                    Descripcion = "Entidad de Prestamo 3",
                    Comision    = 10M,
                    Estado      = true
                }
            };

            entidad.ForEach(c => db.Entidad.Add(c));

            var tiporequisito = new List <TipoRequisito>
            {
                new TipoRequisito
                {
                    Descripcion = "Tipo de Requisito 1",
                    Estado      = true,
                },
                new TipoRequisito
                {
                    Descripcion = "Tipo de Requisito 2",
                    Estado      = true,
                },
            };

            tiporequisito.ForEach(c => db.TipoRequisito.Add(c));

            var requisitos = new List <Requisito>
            {
                new Requisito
                {
                    Descripcion      = "Requisito 1",
                    Adjunto          = true,
                    CantidadAdjuntos = 2,
                    Estado           = true,
                    TipoRequisito    = tiporequisito[1]
                },
                new Requisito
                {
                    Descripcion      = "Requisito 2",
                    Adjunto          = true,
                    CantidadAdjuntos = 1,
                    Estado           = true,
                    TipoRequisito    = tiporequisito[0]
                },
                new Requisito
                {
                    Descripcion      = "Requisito 3",
                    Adjunto          = true,
                    CantidadAdjuntos = 1,
                    Estado           = true,
                    TipoRequisito    = tiporequisito[1]
                },
            };

            requisitos.ForEach(c => db.Requisitos.Add(c));

            var prestamo = new List <TipoPrestamo>
            {
                new TipoPrestamo
                {
                    Descripcion     = "Prestamo 1",
                    EntidadPrestamo = entidad[0],
                    Estado          = true,
                    Requisitos      = null,
                    EscalaCuotas    = null,
                },
                new TipoPrestamo
                {
                    Descripcion     = "Prestamo 2",
                    EntidadPrestamo = entidad[1],
                    Estado          = true,
                    Requisitos      = requisitos,
                    EscalaCuotas    = null
                },
            };

            prestamo.ForEach(c => db.TipoPrestamos.Add(c));

            var PermisosUsuario = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Usuario"
                },
                new ApplicationRole {
                    Name = "Editar_Usuario"
                },
                new ApplicationRole {
                    Name = "Detalle_Usuario"
                },
                new ApplicationRole {
                    Name = "Eliminar_Usuario"
                },
                new ApplicationRole {
                    Name = "AllUsuarios"
                }
            };

            PermisosUsuario.ForEach(c => db.Roles.Add(c));


            var PermisosGrupo = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Grupo"
                },
                new ApplicationRole {
                    Name = "Editar_Grupo"
                },
                new ApplicationRole {
                    Name = "Detalle_Grupo"
                },
                new ApplicationRole {
                    Name = "Eliminar_Grupo"
                },
                new ApplicationRole {
                    Name = "AllGrupos"
                }
            };

            PermisosGrupo.ForEach(c => db.Roles.Add(c));


            var PermisosAcciones = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Permiso"
                },
                new ApplicationRole {
                    Name = "Editar_Permiso"
                },
                new ApplicationRole {
                    Name = "Detalle_Permiso"
                },
                new ApplicationRole {
                    Name = "Eliminar_Permiso"
                },
                new ApplicationRole {
                    Name = "AllPermisos"
                }
            };

            PermisosUsuario.ForEach(c => db.Roles.Add(c));

            var PermisosTurnos = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Vendedor"
                },
                new ApplicationRole {
                    Name = "Organizador"
                }
            };

            PermisosTurnos.ForEach(c => db.Roles.Add(c));

            var grupos = new List <ApplicationGroup> {
                new ApplicationGroup {
                    Name        = "Gestionar Usuarios",
                    Description = "Gestionar Usuarios"
                },
                new ApplicationGroup {
                    Name        = "Gestionar Grupos",
                    Description = "Gestionar Grupos"
                },
                new ApplicationGroup {
                    Name        = "Gestionar Acciones",
                    Description = "Gestionar Acciones"
                }
            };

            grupos.ForEach(c => db.ApplicationGroups.Add(c));

            ////Organizador
            //const string nombreorg = "Will Organizador";
            //const string apellidopaternoorg = "Santisteban";
            //const string apellidomaternoorg = "Crack";
            //const bool estadoorg = true;
            //const string nameorg = "*****@*****.**";
            //const string passwordorg = "Mcga@123456";
            ////const string roleNameorg = "Organizador";

            ////Create Role Organizador if it does not exist
            ////var roleorg = roleManager.FindByName(roleNameorg);
            ////if (roleorg == null)
            ////{
            ////    roleorg = new ApplicationRole(roleNameorg);
            ////    var roleresult2 = roleManager.Create(roleorg);
            ////}

            //var organizador = userManager.FindByName(nameorg);
            //if (organizador == null)
            //{
            //    organizador = new Organizador
            //    {
            //        UserName = nameorg,
            //        Email = nameorg,
            //        Nombre = nombreorg,
            //        ApellidoMaterno = apellidomaternoorg,
            //        ApellidoPaterno = apellidopaternoorg,
            //        Estado = estadoorg,
            //        EmailConfirmed = true,
            //        TipoDocumento = tipodocumento[0],
            //        Sexo = sexo[0],
            //        Localidad = localidades[1],
            //        EstadoCivil = estadocivil[0],
            //        TelefonoCelular = "341354472",
            //        TelefonoFijo = "341354417",
            //        TelefonoLaboral = "000000",
            //        TelefonoResidencia = "000000",
            //        PhoneNumber = "3413544172",
            //        NumeroDocumento = "94566808",
            //        Calle = "Presidente Roca",
            //        Altura = "976",
            //        CBU = "22225321",
            //        CUIT_CUIL = "20945668084",
            //        LugarDeTrabajo = "Twice Talent SRL",
            //        FechaDeNacimiento = DateTime.Parse("03-03-2016"),
            //        Imagen = "~/Content/img/doctor.png",
            //        Observaciones = ""
            //    };

            //    var result1 = userManager.Create(organizador, passwordorg);
            //    result1 = userManager.SetLockoutEnabled(organizador.Id, false);
            //}

            //var newGrouporg = new ApplicationGroup("Organizadores", "Acceso Roles Organizador");

            //groupManager.CreateGroup(newGrouporg);
            //groupManager.SetUserGroups(organizador.Id, new string[] { newGrouporg.Id });
            //groupManager.SetGroupRoles(newGrouporg.Id, new string[] { PermisosTurnos[0].Name });
            ////Fin Organizador

            ////Vendedor
            //const string nombrevend = "Gusti Vendedor";
            //const string apellidopaternovend = "Santis";
            //const string apellidomaternovend = "Vendedor";
            //const bool estadovend = true;
            //const string namevend = "*****@*****.**";
            //const string passwordvend = "Mcga@123456";
            ////const string roleNamevend = "Vendedor";

            ////Create Role Admin if it does not exist
            ////var rolevend = roleManager.FindByName(roleNamevend);
            ////if (rolevend == null)
            ////{
            ////    rolevend = new ApplicationRole(roleNamevend);
            ////    var roleresult3 = roleManager.Create(rolevend);
            ////}

            //var vendedor = userManager.FindByName(namevend);
            //if (vendedor == null)
            //{
            //    vendedor = new Vendedor
            //    {
            //        UserName = namevend,
            //        Email = namevend,
            //        Nombre = nombrevend,
            //        ApellidoMaterno = apellidomaternovend,
            //        ApellidoPaterno = apellidopaternovend,
            //        Estado = estadovend,
            //        EmailConfirmed = true,
            //        TipoDocumento = tipodocumento[0],
            //        Sexo = sexo[0],
            //        Localidad = localidades[1],
            //        EstadoCivil = estadocivil[0],
            //        TelefonoCelular = "3413588888",
            //        TelefonoFijo = "3413588888",
            //        PhoneNumber = "3413588888",
            //        NumeroDocumento = "94566809",
            //        Calle = "Presidente Roca",
            //        Altura = "200",
            //        CBU = "222253222",
            //        CUIT_CUIL = "20945668094",
            //        LugarDeTrabajo = "Accenture SRL",
            //        FechaDeNacimiento = DateTime.Parse("03-03-2009"),
            //        Imagen = "~/Content/img/doctor.png",
            //        Observaciones = "",
            //        IdOrganizador = organizador.Id
            //    };

            //    var result2 = userManager.Create(vendedor, passwordvend);
            //    result2 = userManager.SetLockoutEnabled(vendedor.Id, false);
            //}

            //var newGroupvend = new ApplicationGroup("Vendedores", "Acceso Roles Vendedor");

            //groupManager.CreateGroup(newGroupvend);
            //groupManager.SetUserGroups(vendedor.Id, new string[] { newGroupvend.Id });
            //groupManager.SetGroupRoles(newGroupvend.Id, new string[] { PermisosTurnos[1].Name });
            ////Fin Vendedor
            db.SaveChanges();
        }
Beispiel #4
0
        //Create [email protected] with password=Admin@123456 in the Admin role
        public static void InitializeIdentityForEF(ApplicationDbContext db)
        {
            var          userManager = HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var          roleManager = HttpContext.Current.GetOwinContext().Get <ApplicationRoleManager>();
            const string nombre      = "William Gustavo";
            const string apellido    = "Santisteban";
            const bool   estado      = true;
            const string name        = "*****@*****.**";
            const string password    = "******";
            const string roleName    = "Admin";

            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(roleName);

            if (role == null)
            {
                role = new ApplicationRole(roleName);
                var roleresult = roleManager.Create(role);
            }

            var user = userManager.FindByName(name);

            if (user == null)
            {
                user = new ApplicationUser {
                    UserName = name, Email = name, Nombre = nombre, Apellido = apellido, Estado = estado, EmailConfirmed = true
                };
                var result = userManager.Create(user, password);
                result = userManager.SetLockoutEnabled(user.Id, false);
            }

            var groupManager = new GrupoManager();
            var newGroup     = new ApplicationGroup("Administradores", "Acceso General al Sistema");

            groupManager.CreateGroup(newGroup);
            groupManager.SetUserGroups(user.Id, new string[] { newGroup.Id });
            groupManager.SetGroupRoles(newGroup.Id, new string[] { role.Name });


            var especialidades = new List <Especialidad> {
                new Especialidad {
                    NombreEspecialidad = "Dietética / Nutricion",
                    Imagen             = "~/Content/img/especialidad/nutricionista.png"
                },
                new Especialidad {
                    NombreEspecialidad = "Ginecología",
                    Imagen             = "~/Content/img/especialidad/ginecologia.png"
                },
                new Especialidad {
                    NombreEspecialidad = "Psicología",
                    Imagen             = "~/Content/img/especialidad/psicologia.png"
                },
                new Especialidad {
                    NombreEspecialidad = "Dermatología",
                    Imagen             = "~/Content/img/especialidad/dermatologia.png"
                },
                new Especialidad {
                    NombreEspecialidad = "Pediatría",
                    Imagen             = "~/Content/img/especialidad/pediatria.png"
                },
                new Especialidad {
                    NombreEspecialidad = "Neumología",
                    Imagen             = "~/Content/img/especialidad/nutricionista.png"
                                         //Imagen = "~/Content/img/especialidad/neumologia.jpg"
                },
                new Especialidad {
                    NombreEspecialidad = "Neurología",
                    Imagen             = "~/Content/img/especialidad/nutricionista.png"
                                         //Imagen = "~/Content/img/especialidad/neurologia.jpg"
                },
                new Especialidad {
                    NombreEspecialidad = "Psiquiatría",
                    Imagen             = "~/Content/img/especialidad/psiquiatria.png"
                }
            };

            especialidades.ForEach(c => db.Especialidades.Add(c));


            var PermisosUsuario = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Usuario"
                },
                new ApplicationRole {
                    Name = "Editar_Usuario"
                },
                new ApplicationRole {
                    Name = "Detalle_Usuario"
                },
                new ApplicationRole {
                    Name = "Eliminar_Usuario"
                },
                new ApplicationRole {
                    Name = "AllUsuarios"
                }
            };

            PermisosUsuario.ForEach(c => db.Roles.Add(c));


            var PermisosGrupo = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Grupo"
                },
                new ApplicationRole {
                    Name = "Editar_Grupo"
                },
                new ApplicationRole {
                    Name = "Detalle_Grupo"
                },
                new ApplicationRole {
                    Name = "Eliminar_Grupo"
                },
                new ApplicationRole {
                    Name = "AllGrupos"
                }
            };

            PermisosGrupo.ForEach(c => db.Roles.Add(c));


            var PermisosAcciones = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Permiso"
                },
                new ApplicationRole {
                    Name = "Editar_Permiso"
                },
                new ApplicationRole {
                    Name = "Detalle_Permiso"
                },
                new ApplicationRole {
                    Name = "Eliminar_Permiso"
                },
                new ApplicationRole {
                    Name = "AllPermisos"
                }
            };

            PermisosUsuario.ForEach(c => db.Roles.Add(c));

            var PermisosTurnos = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Turno"
                },
                new ApplicationRole {
                    Name = "Editar_Turno"
                },
                new ApplicationRole {
                    Name = "Detalle_Turno"
                },
                new ApplicationRole {
                    Name = "Eliminar_Turno"
                },
                new ApplicationRole {
                    Name = "AllTurnos"
                }
            };

            PermisosTurnos.ForEach(c => db.Roles.Add(c));

            var PermisosHorarios = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Horario"
                },
                new ApplicationRole {
                    Name = "Editar_Horario"
                },
                new ApplicationRole {
                    Name = "Detalle_Horario"
                },
                new ApplicationRole {
                    Name = "Eliminar_Horario"
                },
                new ApplicationRole {
                    Name = "AllHorarios"
                }
            };

            PermisosHorarios.ForEach(c => db.Roles.Add(c));

            var PermisosProfesionales = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Profesional"
                },
                new ApplicationRole {
                    Name = "Editar_Profesional"
                },
                new ApplicationRole {
                    Name = "Detalle_Profesional"
                },
                new ApplicationRole {
                    Name = "Eliminar_Profesional"
                },
                new ApplicationRole {
                    Name = "AllProfesionales"
                }
            };

            PermisosProfesionales.ForEach(c => db.Roles.Add(c));

            var grupos = new List <ApplicationGroup> {
                new ApplicationGroup {
                    Name        = "Gestionar Usuarios",
                    Description = "Gestionar Usuarios"
                },
                new ApplicationGroup {
                    Name        = "Gestionar Grupos",
                    Description = "Gestionar Grupos"
                },
                new ApplicationGroup {
                    Name        = "Gestionar Acciones",
                    Description = "Gestionar Acciones"
                },
                new ApplicationGroup {
                    Name        = "Gestionar Autos",
                    Description = "Gestionar Autos"
                },
            };

            grupos.ForEach(c => db.ApplicationGroups.Add(c));


            const string nombreesp    = "Agustin";
            const string apellidoesp  = "Stelzer";
            const bool   estadoesp    = true;
            const string nameesp      = "*****@*****.**";
            const string passwordesp  = "Mcga@123456";
            const string roleNameesp  = "Profesionales";
            const string matriculaesp = "EE2015E";
            const string telefonoesp  = "3413544172";

            //Create Role Admin if it does not exist
            var roleesp = roleManager.FindByName(roleNameesp);

            if (roleesp == null)
            {
                roleesp = new ApplicationRole(roleNameesp);
                var roleresultado = roleManager.Create(roleesp);
            }

            var especialista = userManager.FindByName(nameesp);

            if (especialista == null)
            {
                especialista = new Especialista {
                    UserName        = nameesp,
                    Email           = nameesp,
                    Nombre          = nombreesp,
                    Apellido        = apellidoesp,
                    Estado          = estadoesp,
                    PhoneNumber     = telefonoesp,
                    EmailConfirmed  = true,
                    NumeroMatricula = matriculaesp,
                    Prefijo         = Prefijo.Dr,
                    ImagenMedico    = "~/Content/img/medicos/agustin_stelzer.jpg",
                    Especialidad    = especialidades[2]
                };
                var resultadoesp = userManager.Create(especialista, passwordesp);
                resultadoesp = userManager.SetLockoutEnabled(especialista.Id, false);
            }

            var groupManageresp = new GrupoManager();
            var newGroupesp     = new ApplicationGroup("Especialistas", "Acceso Prefesionales al Sistema");

            groupManager.CreateGroup(newGroupesp);
            groupManager.SetUserGroups(especialista.Id, new string[] { newGroupesp.Id });
            groupManager.SetGroupRoles(newGroupesp.Id, new string[] { roleesp.Name });

            foreach (var horariosroles in PermisosHorarios.ToList())
            {
                userManager.AddToRoles(especialista.Id, horariosroles.Name);
            }
            foreach (var turnosroles in PermisosTurnos.ToList())
            {
                userManager.AddToRoles(especialista.Id, turnosroles.Name);
            }

            const string nombrepac   = "Pamela";
            const string apellidopac = "Sosa";
            const bool   estadopac   = true;
            const string namepac     = "*****@*****.**";
            const string passwordpac = "Mcga@123456";
            const string roleNamepac = "Paciente";
            const string telefonopac = "3413544172";

            var rolepac = roleManager.FindByName(roleNamepac);

            if (rolepac == null)
            {
                rolepac = new ApplicationRole(roleNamepac);
                var roleresultadopaciente = roleManager.Create(rolepac);
            }

            var paciente = userManager.FindByName(namepac);

            if (paciente == null)
            {
                paciente = new Paciente
                {
                    UserName          = namepac,
                    Email             = namepac,
                    Nombre            = nombrepac,
                    Apellido          = apellidopac,
                    Estado            = estadopac,
                    PhoneNumber       = telefonopac,
                    EmailConfirmed    = true,
                    ImagenPaciente    = "~/Content/img/medicos/pamela_sosa.jpg",
                    FechadeCumpleanos = Convert.ToDateTime("1990-12-12 00:00"),
                    Genero            = Sexo.Femenino,
                    HistoriaClinica   = new HistoriaClinica {
                        Anamnesis     = null,
                        FechaCreacion = DateTime.Now
                    }
                };
                var resultadoesp = userManager.Create(paciente, passwordpac);
                resultadoesp = userManager.SetLockoutEnabled(paciente.Id, false);
            }
            var newGrouppac = new ApplicationGroup("Pacientes", "Acceso Pacientes al Sistema");

            groupManager.CreateGroup(newGrouppac);
            groupManager.SetUserGroups(paciente.Id, new string[] { newGrouppac.Id });
            groupManager.SetGroupRoles(newGrouppac.Id, new string[] { rolepac.Name });


            //var paciente2 = userManager.FindByName("*****@*****.**");
            //if (paciente2 == null)
            //{
            //    paciente2 = new Paciente
            //    {
            //        UserName = "******",
            //        Email = "*****@*****.**",
            //        Nombre = "Pablo",
            //        Apellido = "Audoglio",
            //        Estado = true,
            //        PhoneNumber = "3413544172",
            //        EmailConfirmed = true,
            //        ImagenPaciente = "~/Content/img/medicos/pablo_audoglio.png",
            //        FechadeCumpleanos = Convert.ToDateTime("1990-12-12 00:00"),
            //        Genero = Sexo.Femenino,
            //        HistoriaClinica = new HistoriaClinica
            //        {
            //            Anamnesis = null,
            //            FechaCreacion = DateTime.Now
            //        }
            //    };
            //    const string clavepacient = "Mcga@123456";
            //    var resultadoesp2 = userManager.Create(paciente2, clavepacient);
            //    resultadoesp2 = userManager.SetLockoutEnabled(paciente2.Id, false);
            //}
            //groupManager.SetUserGroups(paciente2.Id, new string[] { newGrouppac.Id });
            //groupManager.SetGroupRoles(newGrouppac.Id, new string[] { rolepac.Name });

            var espe = userManager.FindByName("*****@*****.**");

            if (espe == null)
            {
                espe = new Especialista
                {
                    Prefijo         = Prefijo.Dr,
                    UserName        = "******",
                    Nombre          = "Hernán",
                    Apellido        = "Carballo",
                    Email           = "*****@*****.**",
                    Estado          = true,
                    PhoneNumber     = "3413354582",
                    ImagenMedico    = "~/Content/img/medicos/hernan_carballo.jpg",
                    Especialidad    = especialidades[3],
                    NumeroMatricula = "MEDICO156",
                    EmailConfirmed  = true,
                };

                const string claveespecialista = "Mcga@12345678";
                var          resultadootro     = userManager.Create(espe, claveespecialista);
                resultadootro = userManager.SetLockoutEnabled(espe.Id, false);
            }

            groupManager.SetUserGroups(espe.Id, new string[] { newGroupesp.Id });
            groupManager.SetGroupRoles(newGroupesp.Id, new string[] { roleesp.Name });

            foreach (var horariosroles in PermisosHorarios.ToList())
            {
                userManager.AddToRoles(especialista.Id, horariosroles.Name);
            }
            foreach (var turnosroles in PermisosTurnos.ToList())
            {
                userManager.AddToRoles(espe.Id, turnosroles.Name);
            }

            var reporteconsulta = new List <ReporteConsultaAnual>
            {
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 0,
                    CantidadConsultas30M = 0,
                    MesReporte           = Convert.ToDateTime("2016-01-01 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 0,
                    CantidadConsultas30M = 0,
                    MesReporte           = Convert.ToDateTime("2016-01-02 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 0,
                    CantidadConsultas30M = 0,
                    MesReporte           = Convert.ToDateTime("2016-01-03 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 0,
                    CantidadConsultas30M = 0,
                    MesReporte           = Convert.ToDateTime("2016-01-04 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 0,
                    CantidadConsultas30M = 0,
                    MesReporte           = Convert.ToDateTime("2016-01-05 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 0,
                    CantidadConsultas30M = 0,
                    MesReporte           = Convert.ToDateTime("2016-01-06 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 0,
                    CantidadConsultas30M = 0,
                    MesReporte           = Convert.ToDateTime("2016-01-07 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 0,
                    CantidadConsultas30M = 0,
                    MesReporte           = Convert.ToDateTime("2016-01-08 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 0,
                    CantidadConsultas30M = 0,
                    MesReporte           = Convert.ToDateTime("2016-01-09 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 56,
                    CantidadConsultas30M = 14,
                    MesReporte           = Convert.ToDateTime("2016-01-10 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 128,
                    CantidadConsultas30M = 32,
                    MesReporte           = Convert.ToDateTime("2016-01-11 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 300,
                    CantidadConsultas30M = 75,
                    MesReporte           = Convert.ToDateTime("2016-01-12 00:00")
                },
                //Segundo Año
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 576,
                    CantidadConsultas30M = 144,
                    MesReporte           = Convert.ToDateTime("2017-01-01 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 1080,
                    CantidadConsultas30M = 270,
                    MesReporte           = Convert.ToDateTime("2017-01-02 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 1600,
                    CantidadConsultas30M = 400,
                    MesReporte           = Convert.ToDateTime("2017-01-03 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 1920,
                    CantidadConsultas30M = 480,
                    MesReporte           = Convert.ToDateTime("2017-01-04 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 2464,
                    CantidadConsultas30M = 748,
                    MesReporte           = Convert.ToDateTime("2017-01-05 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 2992,
                    CantidadConsultas30M = 748,
                    MesReporte           = Convert.ToDateTime("2017-01-06 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 3520,
                    CantidadConsultas30M = 880,
                    MesReporte           = Convert.ToDateTime("2017-01-07 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 4324,
                    CantidadConsultas30M = 1081,
                    MesReporte           = Convert.ToDateTime("2017-01-08 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 4600,
                    CantidadConsultas30M = 1150,
                    MesReporte           = Convert.ToDateTime("2017-01-09 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 4784,
                    CantidadConsultas30M = 1196,
                    MesReporte           = Convert.ToDateTime("2017-01-10 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 5184,
                    CantidadConsultas30M = 1296,
                    MesReporte           = Convert.ToDateTime("2017-01-11 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 5400,
                    CantidadConsultas30M = 1350,
                    MesReporte           = Convert.ToDateTime("2017-01-12 00:00")
                },
                //Tercer Año
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 5600,
                    CantidadConsultas30M = 1400,
                    MesReporte           = Convert.ToDateTime("2018-01-01 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 5700,
                    CantidadConsultas30M = 1425,
                    MesReporte           = Convert.ToDateTime("2018-01-02 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 5700,
                    CantidadConsultas30M = 1425,
                    MesReporte           = Convert.ToDateTime("2018-01-03 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 5800,
                    CantidadConsultas30M = 1450,
                    MesReporte           = Convert.ToDateTime("2018-01-04 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 6000,
                    CantidadConsultas30M = 1500,
                    MesReporte           = Convert.ToDateTime("2018-01-05 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 6000,
                    CantidadConsultas30M = 1500,
                    MesReporte           = Convert.ToDateTime("2018-01-06 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 6000,
                    CantidadConsultas30M = 1500,
                    MesReporte           = Convert.ToDateTime("2018-01-07 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 6000,
                    CantidadConsultas30M = 1500,
                    MesReporte           = Convert.ToDateTime("2018-01-08 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 6100,
                    CantidadConsultas30M = 1525,
                    MesReporte           = Convert.ToDateTime("2018-01-09 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 6448,
                    CantidadConsultas30M = 1612,
                    MesReporte           = Convert.ToDateTime("2018-01-10 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 6696,
                    CantidadConsultas30M = 1674,
                    MesReporte           = Convert.ToDateTime("2018-01-11 00:00")
                },
                new ReporteConsultaAnual()
                {
                    CantidadConsultas20M = 6944,
                    CantidadConsultas30M = 1736,
                    MesReporte           = Convert.ToDateTime("2018-01-12 00:00")
                }
            };

            reporteconsulta.ForEach(c => db.ReporteConsulta.Add(c));
            db.SaveChanges();
        }
Beispiel #5
0
        //Create [email protected] with password=Admin@123456 in the Admin role
        public static void InitializeIdentityForEF(ApplicationDbContext db)
        {
            var          userManager = HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var          roleManager = HttpContext.Current.GetOwinContext().Get <ApplicationRoleManager>();
            const string nombre      = "William Gustavo";
            const string apellido    = "Santisteban";
            const bool   estado      = true;
            const string name        = "*****@*****.**";
            const string password    = "******";
            const string roleName    = "Admin";

            //Create Role Admin if it does not exist
            var role = roleManager.FindByName(roleName);

            if (role == null)
            {
                role = new ApplicationRole(roleName);
                var roleresult = roleManager.Create(role);
            }

            var user = userManager.FindByName(name);

            if (user == null)
            {
                user = new ApplicationUser {
                    UserName = name, Email = name, Nombre = nombre, Apellido = apellido, Estado = estado, EmailConfirmed = true
                };
                var result = userManager.Create(user, password);
                result = userManager.SetLockoutEnabled(user.Id, false);
            }

            var groupManager = new GrupoManager();
            var newGroup     = new ApplicationGroup("Administradores", "Acceso General al Sistema");

            groupManager.CreateGroup(newGroup);
            groupManager.SetUserGroups(user.Id, new string[] { newGroup.Id });
            groupManager.SetGroupRoles(newGroup.Id, new string[] { role.Name });


            var especialidades = new List <Especialidad> {
                new Especialidad {
                    NombreEspecialidad = "Dietética / Nutricion",
                    Imagen             = "~/Content/img/especialidad/nutricionista.png"
                },
                new Especialidad {
                    NombreEspecialidad = "Ginecología",
                    Imagen             = "~/Content/img/especialidad/ginecologia.png"
                },
                new Especialidad {
                    NombreEspecialidad = "Psicología",
                    Imagen             = "~/Content/img/especialidad/psicologia.png"
                },
                new Especialidad {
                    NombreEspecialidad = "Dermatología",
                    Imagen             = "~/Content/img/especialidad/dermatologia.png"
                },
                new Especialidad {
                    NombreEspecialidad = "Pediatría",
                    Imagen             = "~/Content/img/especialidad/pediatria.png"
                },
                new Especialidad {
                    NombreEspecialidad = "Neumología",
                    Imagen             = "~/Content/img/especialidad/nutricionista.png"
                                         //Imagen = "~/Content/img/especialidad/neumologia.jpg"
                },
                new Especialidad {
                    NombreEspecialidad = "Neurología",
                    Imagen             = "~/Content/img/especialidad/nutricionista.png"
                                         //Imagen = "~/Content/img/especialidad/neurologia.jpg"
                },
                new Especialidad {
                    NombreEspecialidad = "Psiquiatría",
                    Imagen             = "~/Content/img/especialidad/psiquiatria.png"
                }
            };

            especialidades.ForEach(c => db.Especialidades.Add(c));


            var PermisosUsuario = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Usuario"
                },
                new ApplicationRole {
                    Name = "Editar_Usuario"
                },
                new ApplicationRole {
                    Name = "Detalle_Usuario"
                },
                new ApplicationRole {
                    Name = "Eliminar_Usuario"
                },
                new ApplicationRole {
                    Name = "AllUsuarios"
                }
            };

            PermisosUsuario.ForEach(c => db.Roles.Add(c));


            var PermisosGrupo = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Grupo"
                },
                new ApplicationRole {
                    Name = "Editar_Grupo"
                },
                new ApplicationRole {
                    Name = "Detalle_Grupo"
                },
                new ApplicationRole {
                    Name = "Eliminar_Grupo"
                },
                new ApplicationRole {
                    Name = "AllGrupos"
                }
            };

            PermisosGrupo.ForEach(c => db.Roles.Add(c));


            var PermisosAcciones = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Permiso"
                },
                new ApplicationRole {
                    Name = "Editar_Permiso"
                },
                new ApplicationRole {
                    Name = "Detalle_Permiso"
                },
                new ApplicationRole {
                    Name = "Eliminar_Permiso"
                },
                new ApplicationRole {
                    Name = "AllPermisos"
                }
            };

            PermisosUsuario.ForEach(c => db.Roles.Add(c));

            var PermisosTurnos = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Turno"
                },
                new ApplicationRole {
                    Name = "Editar_Turno"
                },
                new ApplicationRole {
                    Name = "Detalle_Turno"
                },
                new ApplicationRole {
                    Name = "Eliminar_Turno"
                },
                new ApplicationRole {
                    Name = "AllTurnos"
                }
            };

            PermisosTurnos.ForEach(c => db.Roles.Add(c));

            var PermisosHorarios = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Horario"
                },
                new ApplicationRole {
                    Name = "Editar_Horario"
                },
                new ApplicationRole {
                    Name = "Detalle_Horario"
                },
                new ApplicationRole {
                    Name = "Eliminar_Horario"
                },
                new ApplicationRole {
                    Name = "AllHorarios"
                }
            };

            PermisosHorarios.ForEach(c => db.Roles.Add(c));

            var PermisosProfesionales = new List <ApplicationRole> {
                new ApplicationRole {
                    Name = "Agregar_Profesional"
                },
                new ApplicationRole {
                    Name = "Editar_Profesional"
                },
                new ApplicationRole {
                    Name = "Detalle_Profesional"
                },
                new ApplicationRole {
                    Name = "Eliminar_Profesional"
                },
                new ApplicationRole {
                    Name = "AllProfesionales"
                }
            };

            PermisosProfesionales.ForEach(c => db.Roles.Add(c));

            var grupos = new List <ApplicationGroup> {
                new ApplicationGroup {
                    Name        = "Gestionar Usuarios",
                    Description = "Gestionar Usuarios"
                },
                new ApplicationGroup {
                    Name        = "Gestionar Grupos",
                    Description = "Gestionar Grupos"
                },
                new ApplicationGroup {
                    Name        = "Gestionar Acciones",
                    Description = "Gestionar Acciones"
                },
                new ApplicationGroup {
                    Name        = "Gestionar Autos",
                    Description = "Gestionar Autos"
                },
            };

            grupos.ForEach(c => db.ApplicationGroups.Add(c));


            const string nombreesp    = "Agustin";
            const string apellidoesp  = "Stelzer";
            const bool   estadoesp    = true;
            const string nameesp      = "*****@*****.**";
            const string passwordesp  = "Mcga@123456";
            const string roleNameesp  = "Profesionales";
            const string matriculaesp = "EE2015E";
            const string telefonoesp  = "3413544172";

            //Create Role Admin if it does not exist
            var roleesp = roleManager.FindByName(roleNameesp);

            if (roleesp == null)
            {
                roleesp = new ApplicationRole(roleNameesp);
                var roleresultado = roleManager.Create(roleesp);
            }

            var especialista = userManager.FindByName(nameesp);

            if (especialista == null)
            {
                especialista = new Especialista {
                    UserName        = nameesp,
                    Email           = nameesp,
                    Nombre          = nombreesp,
                    Apellido        = apellidoesp,
                    Estado          = estadoesp,
                    PhoneNumber     = telefonoesp,
                    EmailConfirmed  = true,
                    NumeroMatricula = matriculaesp,
                    Prefijo         = Prefijo.Dr,
                    ImagenMedico    = "~/Content/img/medicos/agustin_stelzer.jpg",
                    Especialidad    = especialidades[2]
                };
                var resultadoesp = userManager.Create(especialista, passwordesp);
                resultadoesp = userManager.SetLockoutEnabled(especialista.Id, false);
            }

            var groupManageresp = new GrupoManager();
            var newGroupesp     = new ApplicationGroup("Especialistas", "Acceso Prefesionales al Sistema");

            groupManager.CreateGroup(newGroupesp);
            groupManager.SetUserGroups(especialista.Id, new string[] { newGroupesp.Id });
            groupManager.SetGroupRoles(newGroupesp.Id, new string[] { roleesp.Name });

            foreach (var horariosroles in PermisosHorarios.ToList())
            {
                userManager.AddToRoles(especialista.Id, horariosroles.Name);
            }
            foreach (var turnosroles in PermisosTurnos.ToList())
            {
                userManager.AddToRoles(especialista.Id, turnosroles.Name);
            }

            const string nombrepac   = "Pamela";
            const string apellidopac = "Sosa";
            const bool   estadopac   = true;
            const string namepac     = "*****@*****.**";
            const string passwordpac = "Mcga@123456";
            const string roleNamepac = "Paciente";
            const string telefonopac = "3413544172";

            var rolepac = roleManager.FindByName(roleNamepac);

            if (rolepac == null)
            {
                rolepac = new ApplicationRole(roleNamepac);
                var roleresultadopaciente = roleManager.Create(rolepac);
            }

            var paciente = userManager.FindByName(namepac);

            if (paciente == null)
            {
                paciente = new Paciente
                {
                    UserName          = namepac,
                    Email             = namepac,
                    Nombre            = nombrepac,
                    Apellido          = apellidopac,
                    Estado            = estadopac,
                    PhoneNumber       = telefonopac,
                    EmailConfirmed    = true,
                    ImagenPaciente    = "~/Content/img/medicos/pamela_sosa.jpg",
                    FechadeCumpleanos = Convert.ToDateTime("1990-12-12 00:00"),
                    Genero            = Sexo.Femenino
                };
                var resultadoesp = userManager.Create(paciente, passwordpac);
                resultadoesp = userManager.SetLockoutEnabled(paciente.Id, false);
            }
            var newGrouppac = new ApplicationGroup("Pacientes", "Acceso Pacientes al Sistema");

            groupManager.CreateGroup(newGrouppac);
            groupManager.SetUserGroups(paciente.Id, new string[] { newGrouppac.Id });
            groupManager.SetGroupRoles(newGrouppac.Id, new string[] { rolepac.Name });

            var espe = userManager.FindByName("*****@*****.**");

            if (espe == null)
            {
                espe = new Especialista
                {
                    Prefijo         = Prefijo.Dr,
                    UserName        = "******",
                    Nombre          = "Hernán",
                    Apellido        = "Carballo",
                    Email           = "*****@*****.**",
                    Estado          = true,
                    PhoneNumber     = "3413354582",
                    ImagenMedico    = "~/Content/img/medicos/hernan_carballo.jpg",
                    Especialidad    = especialidades[3],
                    NumeroMatricula = "MEDICO156",
                    EmailConfirmed  = true,
                };

                const string claveespecialista = "Mcga@12345678";
                var          resultadootro     = userManager.Create(espe, claveespecialista);
                resultadootro = userManager.SetLockoutEnabled(espe.Id, false);
            }

            groupManager.SetUserGroups(espe.Id, new string[] { newGroupesp.Id });
            groupManager.SetGroupRoles(newGroupesp.Id, new string[] { roleesp.Name });

            foreach (var horariosroles in PermisosHorarios.ToList())
            {
                userManager.AddToRoles(especialista.Id, horariosroles.Name);
            }
            foreach (var turnosroles in PermisosTurnos.ToList())
            {
                userManager.AddToRoles(espe.Id, turnosroles.Name);
            }

            db.SaveChanges();
        }