示例#1
0
        private static IEnumerable <ApPerson> AddPerson(this SQLServerContext _context)
        {
            // Create Person ( 1 People)
            var people = new List <ApPerson>
            {
                new ApPerson
                {
                    Id           = _context.Users.Single(u => u.UserName == Startup.Configuration[defaultAdminUserName]).Id,
                    LastName     = "Islam",
                    FirstMidName = "Rejwanul",
                    BirthDate    = DateTime.Parse("1989-11-02"),
                    // ProfileImages = new List<ProfileImage>()
                }
            };

            return(people);
        }
示例#2
0
        /// <summary>
        /// Creates a store manager user who can manage the inventory.
        /// </summary>
        /// <param name="hostingEnv">IHosting Environment</param>
        /// <param name="sfContext">AspNetCore2Angular5Context</param>
        private static async Task InsertTestData(this IServiceProvider serviceProvider, IHostingEnvironment environment, SQLServerContext context)
        {
            var _context = context;

            using (_context)
            {
                await _context.AddOrUpdateAsync(c => c.Id, _context.AddPerson());
            }
        }
示例#3
0
        /// <summary>
        /// Initial data entry to the database.
        /// </summary>
        /// <param name="serviceProvider">IService provider </param>
        /// <param name="env">IHosting environment</param>
        /// <param name="createUsers">If true to create default admin user</param>
        public static async Task InitializeDatabaseAsync(this IServiceProvider serviceProvider, IHostingEnvironment environment, SQLServerContext context, bool CreateUser = true)
        {
            if (CreateUser)
            {
                var u = await CreateAdminUserAsync(serviceProvider);

                if (u.Succeeded)
                {
                    await serviceProvider.InsertTestData(environment, context);
                }
            }
        }