public async Task EnsureSeedDataAsync()
        {
            if (await _userManager.FindByEmailAsync("*****@*****.**") == null)
            {
                var user = new RentalUser()
                {
                    UserName = "******",
                    Email    = "*****@*****.**"
                };

                await _userManager.CreateAsync(user, "DDdd@1234");
            }

            if (!_context.Cars.Any())
            {
                var cars = new List <Car>()
                {
                    // Info: No need to add Id -- Aitomatically added
                    new Car()
                    {
                        Color = "Blue", Description = "Merc", RentalPrice = 100, Year = 2000, CurrentlyRented = false
                    },
                    new Car()
                    {
                        Color = "Red", Description = "Rolls Royce", RentalPrice = 200, Year = 2001, CurrentlyRented = false
                    },
                    new Car()
                    {
                        Color = "Silver", Description = "BMW", RentalPrice = 400, Year = 2002, CurrentlyRented = false
                    }
                };
                _context.Cars.AddRange(cars);
                await _context.SaveChangesAsync();
            }
        }
Example #2
0
        public async Task <IActionResult> Register(RegisterViewModel vm)
        {
            var user = new RentalUser()
            {
                UserName = vm.UserName,
                Email    = "*****@*****.**"
            };
            await _userManager.CreateAsync(user, vm.Password);

            return(View());
        }