Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("DexNumber,Name,TypeOne,TypeTwo,Nature")] Fakemon fakemon)
        {
            if (ModelState.IsValid)
            {
                fakemon.DexNumber = Guid.NewGuid();
                _context.Add(fakemon);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fakemon));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("StatsId,HitPoints,Attack,Defense,SpecialAttack,SpecialDefense,Speed")] Stats stats)
        {
            if (ModelState.IsValid && !StatsExists(stats.StatsId))
            {
                //stats.StatsId = Guid.NewGuid();
                _context.Add(stats);
                await _context.SaveChangesAsync();

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

            // Set flag if user tries to enter stats that already exist
            if (StatsExists(stats.StatsId))
            {
                ViewData["Flag"] = true;
            }

            ViewData["StatsId"] = new SelectList(_context.Fakemons, "DexNumber", "Name", stats.StatsId);

            return(View(stats));
        }