Пример #1
0
        public async Task SeedAllAsync(CancellationToken cancellation)
        {
            #region SeedData

            var adminRole = new Role
            {
                Name        = "Admin",
                Description = "System Admin Role",
                IsVital     = true,
            };
            if (!_roleRepository.GetAll().Any())
            {
                await _roleRepository.AddAsync(adminRole);

                await _roleRepository.AddAsync(new Role
                {
                    Name        = "Manager",
                    Description = "Mange User",
                    IsVital     = true,
                });

                await _roleRepository.AddAsync(new Role
                {
                    Name        = "User",
                    Description = "System Admin Role",
                    IsVital     = true,
                });
            }

            if (!_userRepository.GetAll().Any())
            {
                await _userRepository.AddAsync(new User
                {
                    FirstName       = "نیما",
                    LastName        = "نصرتی",
                    Email           = "*****@*****.**",
                    Password        = PasswordManagement.HashPass("nima1234!"),
                    ActiveCode      = Guid.NewGuid().ToString("N"),
                    Mobile          = "09107602786",
                    IsEmailConfirm  = true,
                    IsMobileConfirm = true,
                    RegisterDate    = DateTime.Now,
                    ModifiedDate    = DateTime.Now.AddDays(2),
                    Roles           = new List <Role>
                    {
                        adminRole
                    }
                });
            }

            #endregion
        }