Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("PersonId,FirstName,LastName,BirthDate,IsApproved,Role")] Person person)
        {
            if (id != person.PersonId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(person);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonExists(person.PersonId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Title,Age,Address,City,Phone,Email")] Person person)
        {
            if (id != person.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(person);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonExists(person.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
 public IActionResult Edit(Person person)
 {
     _context.Update(person);
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
Example #4
0
 public bool UpdatePerson(Person person)
 {
     _context.Update(person);
     _context.SaveChanges();
     return(true);
 }