コード例 #1
0
        public override async Task <GetCountryResponse> GetAllCountry(SeriesEmpty request, ServerCallContext context)
        {
            try
            {
                var response = await _series.GetAllCountries();

                if (response is null)
                {
                    throw new Exception("SeriesRep - GetAllRoles");
                }
                var full = new List <CountryFull>();
                response.ToList().ForEach((country) =>
                {
                    var coun = _mapper.Map <Country, CountryFull>(country);
                    full.Add(coun);
                });
                return(new GetCountryResponse()
                {
                    Countries = { full }
                });
            }
            catch (Exception e)
            {
                _logger.LogError(e, "ERROR");
                List <CountryFull> full = null;
                return(new GetCountryResponse()
                {
                    Countries = { full }
                });
            }
        }