public Task <Person> UpdateAsync(int id, PersonStatusEnum status) { Person person = null; using (var context = new EFCore_GraphQLDbContext()) { person = context.Persons.Include(p => p.PhoneNumbers) .SingleOrDefault(p => p.Id == id); person.Status = status; context.SaveChanges(); } //add event var personEvent = new PersonEvent() { Id = 2, Name = person.Name, Status = person.Status, Timestamp = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") }; _eventsService.AddEvent(personEvent); return(Task.FromResult(person)); }
public Task <Person> CreateAsync(Person person) { using (var context = new EFCore_GraphQLDbContext()) { context.Persons.Add(person); context.SaveChanges(); } //add event var personEvent = new PersonEvent() { Id = 1, Name = person.Name, Status = person.Status, Timestamp = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") }; _eventsService.AddEvent(personEvent); return(Task.FromResult(person)); }