Skip to content

Instantly share code, notes, and snippets.

@stdray
Created June 21, 2014 11:46
Show Gist options
  • Save stdray/9c85a85350ac7a594361 to your computer and use it in GitHub Desktop.
Save stdray/9c85a85350ac7a594361 to your computer and use it in GitHub Desktop.
public abstract class UsersRepositoryAsyncDaoBase<TItem, TListItem, TKey> : UsersDaoBase, IUsersRepositoryAsyncDao<TItem, TListItem, TKey>
{
/// <summary>
/// Контекст безопастности
/// </summary>
protected IPrivateSecurityContext SecurityContext { get; set; }
protected int CurrentUserId { get { return SecurityContext.CurrentUser.WrObj.Id; }}
public Task<IPageable<TListItem>> ListAsync(PagingParams? pagingParams)
{
return Task.Factory.StartNewLong(() => List(pagingParams));
}
public Task<TKey> AddAsync(TItem item)
{
return Task.Factory.StartNewLong(() => Add(item));
}
public Task<TItem> GetAsync(TKey key)
{
return Task.Factory.StartNewLong(() => Get(key));
}
public Task<TItem> UpdateAsync(TItem item)
{
return Task.Factory.StartNewLong(() => Update(item));
}
public Task DeleteAsync(TKey key)
{
return Task.Factory.StartNewLong(() => Delete(key));
}
#region abstract
protected abstract IPageable<TListItem> List(PagingParams? pagingParams);
protected abstract TKey Add(TItem item);
protected abstract TItem Get(TKey key);
protected abstract TItem Update(TItem item);
protected abstract void Delete(TKey key);
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment