public async Task Update( string projectId, IKvpItem kvp, CancellationToken cancellationToken = default(CancellationToken) ) { if (kvp == null) { throw new ArgumentException("kvp can't be null"); } var kvpItem = KvpItem.FromIKvpItem(kvp); using (var db = _contextFactory.Create()) { bool tracking = db.ChangeTracker.Entries <KvpItem>().Any(x => x.Entity.Id == kvpItem.Id); if (!tracking) { db.KvpItems.Update(kvpItem); } var rowsAffected = await db.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); } }
public async Task Update( string projectId, IKvpItem kvp, CancellationToken cancellationToken = default(CancellationToken) ) { await _commands.Update(projectId, kvp, cancellationToken).ConfigureAwait(false); }
public async Task Update( string projectId, IKvpItem kvp, CancellationToken cancellationToken = default(CancellationToken) ) { var item = KvpItem.FromIKvpItem(kvp); await _kvpCommands.UpdateAsync( projectId, item.Id, item, cancellationToken).ConfigureAwait(false); }
public static KvpItem FromIKvpItem(IKvpItem i) { var k = new KvpItem(); k.CreatedUtc = i.CreatedUtc; k.Custom1 = i.Custom1; k.Custom2 = i.Custom2; k.FeatureId = i.FeatureId; k.Id = i.Id; k.Key = i.Key; k.ModifiedUtc = i.ModifiedUtc; k.SetId = i.SetId; k.SubSetId = i.SubSetId; k.Value = i.Value; return(k); }
public async Task Create( string projectId, IKvpItem kvp, CancellationToken cancellationToken = default(CancellationToken) ) { if (kvp == null) { throw new ArgumentException("kvp can't be null"); } var kvpItem = KvpItem.FromIKvpItem(kvp); _db.KvpItems.Add(kvpItem); var rowsAffected = await _db.SaveChangesAsync(cancellationToken) .ConfigureAwait(false); }