Пример #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Gender,OwnerId,CreatedAt,UpdatedAt,RaceId")] Character character)
        {
            // TODO move to User's Character controller
            // var user = await _userManager.GetUserAsync(User);
            // character.OwnerId = user.Id;

            character = await _characterManager.Prepare(character, true);

            if (ModelState.IsValid)
            {
                _context.Add(character);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OwnerId"] = new SelectList(_context.Users, "Id", "Id", character.OwnerId);
            ViewData["RaceId"]  = new SelectList(_context.Races, "Id", "Name", character.RaceId);
            return(View(character));
        }