public async Task <PageDto <AgentDto> > GetPageAsync(int pageSize, int pageNumber) { var page = new PageDto <AgentDto>(pageSize, pageNumber); var items = await _unitOfWork.Agents.GetPageAsync(pageSize, pageNumber); page.SetData(items.Item2, items.Item1.Select(i => AgentDto.FromDomain(i)).ToList()); return(page); }
public async Task <AgentDto> DeleteAsync(int id) { var agent = await Get(id); await Task.WhenAll(_unitOfWork.CompleteAsync((ctx) => ctx.Agents.Remove(agent)), _cacheStore.RemoveAsync(GetCacheKey(id))); return(AgentDto.FromDomain(agent)); }
public async Task <AgentDto> GetAsync(int id) { var agentDto = await _cacheStore.StoreAndGetAsync(GetCacheKey(id), async() => { var agent = await Get(id); return(AgentDto.FromDomain(agent)); }); return(agentDto); }