Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("PlayerId,FullName,Age,Contry,SportId")] Players players)
        {
            if (id != players.PlayerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(players);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlayersExists(players.PlayerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SportId"] = new SelectList(_context.Sport, "SportId", "SportId", players.SportId);
            return(View(players));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("SportId,SportName,Description")] Sport sport)
        {
            if (id != sport.SportId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sport);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SportExists(sport.SportId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(sport));
        }
Ejemplo n.º 3
0
        public async Task UpdateAddress(Person person, Address address)
        {
            if (person.AddressId != null)
            {
                address.AddressId = (int)person.AddressId;
                _context.Addresses.Update(address);
            }
            else
            {
                person.Address = address;
                _context.Add(address);
                _context.Update(person);
            }

            await _context.SaveChangesAsync();
        }