public IActionResult GetMandanteOfAnEvent(int eventoId)
        {
            if (!_eventoRepository.EventoExists(eventoId))
            {
                return(NotFound());
            }

            var mandante = _mandanteRepository.GetMandanteOfAnEvent(eventoId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var mandanteDto = new MandanteDto()
            {
                MandanteId   = mandante.MandanteId,
                NomeMandante = mandante.NomeMandante
            };

            return(Ok(mandanteDto));
        }
Exemple #2
0
        public MandanteDto GetMandanteOfAnEvent(int eventoId)
        {
            MandanteDto mandante = new MandanteDto();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://localhost:44357/api/");

                var response = client.GetAsync($"mandanti/eventi/{eventoId}");
                response.Wait();

                var result = response.Result;

                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <MandanteDto>();
                    readTask.Wait();

                    mandante = readTask.Result;
                }
            }

            return(mandante);
        }