public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (IServiceScope scope = host.Services.GetRequiredService <IServiceScopeFactory>().CreateScope()) { var provider = scope.ServiceProvider; try { IPasswordHasher <User> hasher = provider.GetService <IPasswordHasher <User> >(); ETutorContext context = provider.GetService <ETutorContext>(); ApplicationDbInitializer.SeedUsers(hasher, context); Task.WaitAll(); } catch (Exception e) { Console.Clear(); Console.WriteLine(e.Message); return; } } host.Run(); }
public ChangePasswordRepository(ETutorContext context) : base(context) { }
public SubjectRepository(ETutorContext context) : base(context) { }
public RoleRepository(ETutorContext context) : base(context) { }
public ParentStudentRepository(ETutorContext context) : base(context) { }
public DeviceRepository(ETutorContext context) : base(context) { }
public ParentAuthorizationRepository(ETutorContext context) : base(context) { }
public UserRepository(ETutorContext context) : base(context) { _context = context; }
public static void SeedUsers(IPasswordHasher <User> hasher, ETutorContext context) { string password = hasher.HashPassword(new User(), "123456"); string adminEmail = "*****@*****.**"; string tutorEmail = "*****@*****.**"; string studentEmail = "*****@*****.**"; string parentEmail = "*****@*****.**"; User admin = context.Users .FirstOrDefault(u => u.Email == adminEmail); User tutor = context.Users .FirstOrDefault(u => u.Email == tutorEmail); User student = context.Users .FirstOrDefault(u => u.Email == studentEmail); User parent = context.Users .FirstOrDefault(u => u.Email == parentEmail); if (admin == null) { User user = new User { Email = adminEmail, EmailConfirmed = true, Gender = Gender.Male, IsEmailValidated = true, IsTemporaryPassword = false, Name = "Admin", SecurityStamp = "n57iIauoLM1JW9PaV6ZM", LastName = "eTutor", UserName = adminEmail, NormalizedEmail = adminEmail.ToUpper(), NormalizedUserName = adminEmail.ToUpper(), AboutMe = "Escribe algo sobre ti", CreatedDate = DateTime.Now, PersonalId = "000-0000000-4", UpdatedDate = DateTime.Now, IsActive = true, AccessFailedCount = 0, PasswordHash = hasher.HashPassword(new User(), "123456") }; context.Add(user); context.SaveChanges(); UserRole role = new UserRole { UserId = user.Id, RoleId = (int)RoleTypes.Admin }; context.Add(role); context.SaveChanges(); } if (tutor == null) { User user = new User { Email = tutorEmail, EmailConfirmed = true, Gender = Gender.Male, IsEmailValidated = true, IsTemporaryPassword = false, Name = "Tutor", LastName = "eTutor", SecurityStamp = "xATyuXy4vgUC9JZ833ja", UserName = tutorEmail, NormalizedEmail = tutorEmail.ToUpper(), NormalizedUserName = tutorEmail.ToUpper(), AboutMe = "Escribe algo sobre ti", CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, PersonalId = "000-0000000-2", AccessFailedCount = 0, IsActive = true, PasswordHash = hasher.HashPassword(new User(), "123456"), }; context.Add(user); context.SaveChanges(); UserRole role = new UserRole { UserId = user.Id, RoleId = (int)RoleTypes.Tutor }; context.Add(role); context.SaveChanges(); } if (student == null) { User user = new User { Email = studentEmail, EmailConfirmed = true, Gender = Gender.Male, IsEmailValidated = true, IsTemporaryPassword = false, Name = "Student", LastName = "eTutor", SecurityStamp = "V0kjQ4wR2Zi9Z2Z2mvwz", UserName = studentEmail, NormalizedEmail = studentEmail.ToUpper(), NormalizedUserName = studentEmail.ToUpper(), AboutMe = "Escribe algo sobre ti", CreatedDate = DateTime.Now, BirthDate = new DateTime(2002, 2, 23), IsActive = true, UpdatedDate = DateTime.Now, PersonalId = "000-0000000-0", AccessFailedCount = 0, PasswordHash = hasher.HashPassword(new User(), "123456"), }; context.Add(user); context.SaveChanges(); UserRole role = new UserRole { UserId = user.Id, RoleId = (int)RoleTypes.Student }; context.Add(role); context.SaveChanges(); } if (parent == null) { User user = new User { Email = parentEmail, EmailConfirmed = true, Gender = Gender.Male, IsEmailValidated = true, IsTemporaryPassword = false, Name = "Student", LastName = "eTutor", SecurityStamp = "gJJTwcxqoSgZ66zH3vPM", UserName = parentEmail, AboutMe = "Escribe algo sobre ti", NormalizedEmail = parentEmail.ToUpper(), NormalizedUserName = parentEmail.ToUpper(), CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, IsActive = true, PersonalId = "000-0000000-1", AccessFailedCount = 0, PasswordHash = hasher.HashPassword(new User(), "123456"), }; context.Add(user); context.SaveChanges(); UserRole role = new UserRole { UserId = user.Id, RoleId = (int)RoleTypes.Parent }; context.Add(role); context.SaveChanges(); } student = context.Users .Include(s => s.UserRoles) .Include(s => s.Parents) .FirstOrDefault(u => u.Email == studentEmail); if (student != null && !student.Parents.Any()) { parent = context.Users .Include(u => u.UserRoles) .Include(u => u.Students) .FirstOrDefault(u => u.Email == parentEmail); var relationship = new ParentStudent { ParentId = parent.Id, StudentId = student.Id, Relationship = ParentRelationship.Father }; context.Add(relationship); context.SaveChanges(); } }
public EmailValidationRepository(ETutorContext context) : base(context) { }
public RatingRepository(ETutorContext context) : base(context) { }
public RejectedMeetingRepository(ETutorContext context) : base(context) { }
public MeetingRepository(ETutorContext context) : base(context) { _context = context; }