Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Mobile,Language,CommunicationPrefrence,SponsoredKids")] Sponsor sponsor)
        {
            if (id != sponsor.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sponsor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SponsorExists(sponsor.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(sponsor));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,DateOfBirth,Description")] Kid kid)
        {
            if (id != kid.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(kid);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KidExists(kid.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(kid));
        }