public async Task <IActionResult> PutAdult(int id, Adult adult) { if (id != adult.Id) { return(BadRequest()); } _context.Entry(adult).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdultExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private static void AddUsers(IList <User> users) { foreach (User user in users) { using (AdultContext fctxt = new AdultContext()) { Console.WriteLine(user.ToString()); fctxt.Users.AddAsync(user); fctxt.Entry(user).State = EntityState.Added; //fctxt.Entry(user).State = EntityState.Detached; fctxt.SaveChangesAsync(); } } }
private static void AddAdults(IList <Adult> adults) { foreach (Adult adult in adults) { using (AdultContext fctxt = new AdultContext()) { Console.WriteLine(adult.ToString()); fctxt.Adults.AddAsync(adult); fctxt.Entry(adult).State = EntityState.Added; //fctxt.Entry(adult).State = EntityState.Detached; fctxt.SaveChangesAsync(); } } }