Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
        }