public async Task <IActionResult> Create([Bind("Id,Name,Alias,Image")] Guild guild)
        {
            if (ModelState.IsValid)
            {
                guild.Id = Guid.NewGuid();
                _context.Add(guild);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(guild));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,CharacterId,Date,Ranking")] Rank rank)
        {
            if (ModelState.IsValid)
            {
                rank.Id = Guid.NewGuid();
                _context.Add(rank);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CharacterId"] = new SelectList(_context.Characters, "Id", "Id", rank.CharacterId);
            return(View(rank));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,GuildId,GuildPosition,IsActivated")] Character character)
        {
            if (ModelState.IsValid)
            {
                character.Id = Guid.NewGuid();
                _context.Add(character);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GuildId"] = new SelectList(_context.Guilds, "Id", "Name", character.GuildId);
            var guildPositions = EnumHelper <GuildPositions> .GetValues().Select(GP => new { Key = GP, Value = EnumHelper <GuildPositions> .GetDisplayValue(GP) });

            ViewData["GuildPosition"] = new SelectList(guildPositions, "Key", "Value", character.GuildPosition);
            return(View(character));
        }