protected override async Task AddTransaction(long transactionId, byte[] mutationHash, Mutation mutation) { foreach (Record record in mutation.Records) { RecordKey key = RecordKey.Parse(record.Key); var dbRecord = await Records.Where(r => r.Key == record.Key.ToByteArray()).FirstOrDefaultAsync(); //TODO: check if dbrecord is null dbRecord.Type = key.RecordType; dbRecord.Name = key.Name; Context.Update(dbRecord); await Context.SaveChangesAsync(); var newMutation = new Models.RecordMutation { RecordKey = record.Key.ToByteArray(), TransactionId = transactionId, MutationHash = mutationHash }; RecordMutations.Add(newMutation); await Context.SaveChangesAsync(); } }
public async Task <IReadOnlyList <ByteString> > GetRecordMutations(ByteString recordKey) { var mutations = await RecordMutations.Where(m => m.RecordKey == recordKey.ToByteArray()).ToListAsync(); return(mutations.Select(m => { return new ByteString(m.MutationHash); }).ToList().AsReadOnly()); }