public async Task <InsertAndGetIdOutput> InsertAndGetId(InsertAndGetIdInput input) { await _context.People.AddAsync(new Person { Name = input.Name, PhoneNumber = input.PhoneNumber }); await _context.SaveChangesAsync(); var person = await _context.People.Where(p => p.Name == input.Name && p.PhoneNumber == input.PhoneNumber).FirstOrDefaultAsync(); return(new InsertAndGetIdOutput() { Id = person.Id }); }
public async Task <InsertAndGetIdOutput> InsertAndGetId(InsertAndGetIdInput input) { var person = new Person { Name = input.Name, PhoneNumber = input.PhoneNumber }; await _context.People.AddAsync(person); await _context.SaveChangesAsync(); return(new InsertAndGetIdOutput { Id = person.Id }); }