public virtual async Task <string> CreateEventSubscription(EventSubscription subscription) { subscription.Id = _guidGenerator.Create().ToString(); var persistable = subscription.ToPersistable(); await _eventSubscriptionRepository.InsertAsync(persistable); return(subscription.Id); }
public async Task <string> CreateEventSubscription(EventSubscription subscription) { subscription.Id = Guid.NewGuid().ToString(); var persistable = subscription.ToPersistable(); var result = Set <PersistedSubscription>().Add(persistable); SaveChanges(); Entry(persistable).State = EntityState.Detached; return(subscription.Id); }
public async Task <string> CreateEventSubscription(EventSubscription subscription) { using (var db = ConstructDbContext()) { subscription.Id = Guid.NewGuid().ToString(); var persistable = subscription.ToPersistable(); var result = db.Set <PersistedSubscription>().Add(persistable); await db.SaveChangesAsync(); return(subscription.Id); } }
public async Task <string> CreateEventSubscription(EventSubscription subscription) { _mutex.WaitOne(); try { subscription.Id = Guid.NewGuid().ToString(); var persistable = subscription.ToPersistable(); var result = Set <PersistedSubscription>().Add(persistable); await SaveChangesAsync(); Entry(persistable).State = EntityState.Detached; return(subscription.Id); } finally { _mutex.Set(); } }