Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,City,bestPlayer")] Teams teams)
        {
            if (id != teams.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teams);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeamsExists(teams.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(teams));
        }
        public async Task <IActionResult> AddOrEdit([Bind("TeamsId,TeamName,LeaderName,CallNumber,TeamLocation")] Teams teams)
        {
            if (ModelState.IsValid)
            {
                if (teams.TeamsId == 0)
                {
                    _context.Add(teams);
                }
                else
                {
                    _context.Update(teams);
                }
                await _context.SaveChangesAsync();

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