Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key"></param>
 public async Task RemoveAsync(T key)
 {
     try
     {
         IRepository <T> repository = ConnectionRepositoryFactory.Create <T>();
         await repository.DeleteAsync(x => x.ConnectionId == key.ConnectionId).ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         Logger.Exception(ex.Message, ex);
     }
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public async Task Clear()
 {
     try
     {
         IRepository <T> repository = ConnectionRepositoryFactory.Create <T>();
         await repository.DeleteAsync(await GetConnectionsAsync().ConfigureAwait(false)).ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         Logger.Exception(ex.Message, ex);
     }
 }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public async Task <IEnumerable <T> > GetConnectionsAsync(Expression <Func <T, bool> > filter)
 {
     try
     {
         IRepository <T> repository = ConnectionRepositoryFactory.Create <T>();
         return(await repository.FindAllAsync(filter).ConfigureAwait(false));
     }
     catch (Exception ex)
     {
         Logger.Exception(ex.Message, ex);
         return(new List <T>());
     }
 }
Пример #4
0
        /// <summary>
        /// Adds connection to the data store if the unique connection ID doesn't exist yet
        /// </summary>
        /// <param name="key"></param>
        public async Task AddAsync(T key)
        {
            try
            {
                IRepository <T> repository  = ConnectionRepositoryFactory.Create <T>();
                IEnumerable <T> connections = await repository.FindAllAsync(x => x.ConnectionId == key.ConnectionId).ConfigureAwait(false);

                if (!connections.Any())
                {
                    await repository.CreateAsync(key).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex.Message, ex);
            }
        }