Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
languagec#
firstline1
titleWhiteHouseRepository.cs
linenumberstrue
using System.Collections.Generic;
using System.Threading.Tasks;
using Tnf.Domain.Repositories;
using Tnf.Architecture.Dto;
 
.WhiteHouse;
using Tnf.App.Dto.Response;
using Tnf.App.Dto.Request;
using Tnf.Architecture.Domain.WhiteHouse;

namespace Tnf.Architecture.Domain.Interfaces.Repositories
{
    public interface IWhiteHouseRepository : IRepository
    {
	Task<PagingDtoResponse<PresidentDto>> GetAll(GellAllPresidentsRequestDto        Task<ListDto<PresidentDto>> GetAllPresidents(GetAllPresidentsDto request);
        Task<PresidentDto> GetByIdGetPresidentById(stringRequestDto<string> idrequestDto);
        Task<List<PresidentDto>>Task<List<string>> InsertAsyncInsertPresidentsAsync(List<PresidentDto>List<President> presidents, bool sync = false);
        TaskTask<President> UpdateAsyncUpdatePresidentsAsync(PresidentDtoPresident president);
        TaskTask<bool> DeleteAsyncDeletePresidentsAsync(string id);
    }
}
Bloco de código
languagec#
firstline1
titleWhiteHouseRepository.cs
linenumberstrue
using System.Collections.Generic;
using System.Threading.Tasks;
using Tnf.App.Carol.Repositories;
using Tnf.Provider.Carol;
using System.LinqTnf.Architecture.Domain.Interfaces.Repositories;
using Tnf.Architecture.Domain.Interfaces.RepositoriesData.Entities;
using Tnf.AutoMapper;
using Tnf.Architecture.Dto.WhiteHouse;
using Tnf.App.Dto.Response;
using Tnf.App.Dto.Request;
using Tnf.Architecture.DataDomain.EntitiesWhiteHouse;
using Provider.Carol.Messages;
 System.Linq;

namespace Tnf.Architecture.Data.Repositories
{
    public class WhiteHouseRepository : CarolRepositoryBase<PresidentEntity>CarolRepositoryBase<PresidentPoco>, IWhiteHouseRepository
    {
	        public WhiteHouseRepository(ICarolClient client) :
		            base(client)
	{
	}

	        {
        }

        public async TaskTask<bool> DeleteAsyncDeletePresidentsAsync(string id) =>
        {
            return await DeleteAsync(id);
 
	       }

        public async Task<PagingDtoResponse<PresidentDto>>Task<ListDto<PresidentDto>> GetAllGetAllPresidents(GellAllPresidentsRequestDtoGetAllPresidentsDto request)
	{
		        {
            var response = new PagingDtoResponse<PresidentDto>ListDto<PresidentDto>();

		            var query = Client.Queries<PresidentEntity>Queries<PresidentPoco>().ProcessFilter()
			.Offset(request.Offset)
			.PageSize(request.PageSize)
			.IndexType(                .SkipAndTakeByRequestDto(request)
                .OrderByRequestDto(request)
                .IndexType(Provider.Carol.Messages.ProcessFilter.IndexType.STAGING)
			                .MustList((m) => m.TypeFilter()
							                                  .MatchFilter(p => p.Name, request.Name)
							                                  .TermFilter(p => p.Address.ZipCode.Number, request.ZipCode));

		            var resultData = await GetAllAsync(query);
		
            response.CountTotal = resultData.CountTotalHits;
		            response.TookItems = resultData.Hits.Took;
		response.TotalHitsMapTo<List<PresidentDto>>();
            response.HasNext = resultData.TotalHits;
		resultData.Hits.ForEach((item) => response.Data.Add(new PresidentDto(item.Id, item.Name, item.ZipCode)));

		return response;
	}

	 > ((request.Page - 1) * request.PageSize) + response.Items.Count();

            return response;
        }

        public async Task<PresidentDto> GetByIdGetPresidentById(stringRequestDto<string> idrequestDto)
	{
		        {
            var presidentData = await GetAsync(requestDto.GetId(id));
		            var president = new PresidentDto(presidentData.Id, presidentData.Name, presidentData.ZipCodeMapTo<PresidentDto>();
		

            return president;
	        }

	        public async Task<List<PresidentDto>>Task<List<string>> InsertAsyncInsertPresidentsAsync(List<PresidentDto>List<President> presidents, bool sync = false)
	{
		var presidentEntities        {
            var pocos = presidents.Select(s => new PresidentEntity()
		{
			Id = s.Id,
			Name = s.Name,
			ZipCode = s.ZipCode.Number
		}MapTo<List<PresidentPoco>>();
            var result = await InsertAsync(pocos, sync);

            return result.Select(p => p.Id).ToList();

		presidentEntities = await InsertAsync(presidentEntities, sync);
		return presidents;
	}

	        }

        public async TaskTask<President> UpdateAsyncUpdatePresidentsAsync(PresidentDtoPresident president)
	{
		await UpdateAsync(new PresidentEntity()
		{
			Id        {
            var poco = president.Id,
			Name = president.Name,
			ZipCode = president.ZipCode.Number
		});
	MapTo<PresidentPoco>();
            var result = await UpdateAsync(poco);

            return president;
        }
    }
}


Quando definimos  nosso repositório recebemos como parâmetro uma interface chamada ICarolClient. Esse tipo é injetado via dependência representando o client de conexão com o Carol.

...