public async Task <IActionResult> Create([Bind("UserName,Email")] User user)
        {
            if (ModelState.IsValid)
            {
                user.Id                   = Guid.NewGuid().ToString();
                user.Token                = Guid.NewGuid().ToString();
                user.Archived             = false;
                user.NormalizedEmail      = user.Email.ToUpper();
                user.NormalizedUserName   = user.UserName.ToUpper();
                user.SpelId               = null;
                user.PasswordHash         = Guid.NewGuid().ToString();
                user.AccessFailedCount    = 0;
                user.LockoutEnabled       = true;
                user.LockoutEnd           = null;
                user.TwoFactorEnabled     = false;
                user.PhoneNumberConfirmed = false;
                user.Kleur                = Kleur.Geen;

                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SpelId"] = new SelectList(_context.Spel, "ID", "ID", user.SpelId);
            return(View(user));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("ID,Omschrijving,")] Spel spel)
        {
            if (ModelState.IsValid)
            {
                System.Security.Claims.ClaimsPrincipal currentUser = this.User;
                var user = await _userManager.GetUserAsync(currentUser);

                user.Kleur = Kleur.Wit;

                spel.Spelers.Add(user);

                spel.Token      = Guid.NewGuid().ToString();
                spel.AandeBeurt = Kleur.Wit;
                spel.Beurt      = 1;

                _context.Add(spel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(spel));
        }