public void Throw_Exception_About_Required_ShadowProperty() { //TODO: 02 - Inserto una entidad con shadow property requerida en null var eventMeetup = new MeetupEvent(DateTime.Now.AddDays(5), DateTime.Now.AddDays(5)); _context.Meetups.Add(eventMeetup); var timesTamp = DateTime.Now; _context.Entry(eventMeetup).Property("Created").CurrentValue = null; _context.Entry(eventMeetup).Property("LastModified").CurrentValue = timesTamp; Action act = () => _context.SaveChanges(); act.Should().Throw <InvalidOperationException>(); }
public async Task <IActionResult> PutPerson(int id, Person person) { if (id != person.ID) { return(BadRequest()); } _context.Entry(person).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PersonExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }