Exemplo n.º 1
0
        public async Task <IEnumerable <PetNamesbyOwnerGender> > GetListofPetsByOwnerGender(string petType)
        {
            List <PetNamesbyOwnerGender> ListofPetsByOwnerGender = new List <PetNamesbyOwnerGender>();

            try
            {
                var response = await _petProxy.GetAsync(_appSettings.BaseUrl);

                List <PetModel> petList = JsonData.DeserializeObject <List <PetModel> >(response);
                petList.Where(pets => pets.pets != null).Select(p => new PetNamesbyOwnerGender
                {
                    gender   = p.gender,
                    petnames = p.pets.Where(a => a.type.Equals(petType, StringComparison.InvariantCultureIgnoreCase))
                               .Select(b => b.name).ToList()
                }).GroupBy(g => g.gender).ToList().
                ForEach(a => ListofPetsByOwnerGender.Add(new PetNamesbyOwnerGender
                {
                    gender   = a.Key,
                    petnames = a.ToList().SelectMany(x => x.petnames).OrderBy(o => o).ToList()
                }));
            }
            catch (Exception ex)
            {
                //catch/throw/log
                return(null);
            }

            return(ListofPetsByOwnerGender);
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <string> > GetPetTypes()
        {
            try
            {
                var response = await _petProxy.GetAsync(_appSettings.BaseUrl);

                List <PetModel> petList = JsonData.DeserializeObject <List <PetModel> >(response);
                return(petList.Where(a => a.pets != null).SelectMany(c => c.pets.Select(p => p.type)).Distinct());
            }
            catch
            {
                //catch/throw/log
                return(null);
            }
        }
        private void InserirHistorico(Organizacao organizacao, string obsFimVigencia, DateTime?fimVigencia)
        {
            Organizacao organizacaoSimples = JsonData.DeserializeObject <Organizacao>(JsonData.SerializeObject(organizacao));

            organizacaoSimples.Esfera             = null;
            organizacaoSimples.OrganizacaoPai     = null;
            organizacaoSimples.OrganizacoesFilhas = null;
            organizacaoSimples.Poder           = null;
            organizacaoSimples.TipoOrganizacao = null;
            organizacaoSimples.Unidades        = null;

            string json = JsonData.SerializeObject(organizacaoSimples);

            Historico historico = new Historico
            {
                Json                   = json,
                InicioVigencia         = organizacao.InicioVigencia,
                FimVigencia            = fimVigencia.HasValue ? fimVigencia.Value : DateTime.Now,
                ObservacaoFimVigencia  = obsFimVigencia,
                IdIdentificadorExterno = organizacao.IdentificadorExterno.Id
            };

            repositorioHistoricos.Add(historico);
        }