Exemplo n.º 1
0
        public IActionResult Edit(Person person)
        {
            if (person.Id != null)
            {
                var found = _context.Person.Find(person.Id);
                if (ModelState.IsValid)
                {
                    found.Name    = person.Name;
                    found.Dob     = person.Dob;
                    found.Gender  = person.Gender;
                    found.Country = person.Country;
                    found.State   = person.State;
                    _context.Entry(found).State = EntityState.Modified;
                    _context.Update(found);
                    _context.SaveChanges();
                }
            }
            //var found = _context.Person.Find(person.Id);
            //if (ModelState.IsValid && found != null)
            //{

            //    _context.Entry(found).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            //    _context.Update(found);
            //    _context.SaveChanges();
            //}
            return(RedirectToAction("Edit"));
        }