public override async Task <GetRolesResponse> GetAllRoles(SeriesEmpty request, ServerCallContext context) { try { var response = await _series.GetAllRoles(); if (response is null || response.Count() == 0) { throw new Exception("SeriesRep - GetAllRoles"); } var full = new List <RoleAdd>(); response.ToList().ForEach((role) => { var r = _mapper.Map <Role, RoleAdd>(role); full.Add(r); }); return(new GetRolesResponse() { Roles = { full } }); } catch (Exception e) { _logger.LogError(e, "ERROR"); List <RoleAdd> full = null; return(new GetRolesResponse() { Roles = { full } }); } }
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 } }); } }
public override async Task <GetGenresResponse> GetAllGenre(SeriesEmpty request, ServerCallContext context) { try { var response = await _series.GetAllGenre(); if (response is null || response.Count() == 0) { throw new Exception("SeriesRep - GetAllGenre"); } var full = new List <GenreFull>(); response.ToList().ForEach((genre) => { var coun = _mapper.Map <Genre, GenreFull>(genre); full.Add(coun); }); return(new GetGenresResponse() { Genres = { full } }); } catch (Exception e) { _logger.LogError(e, "ERROR"); return(new GetGenresResponse() { }); } }
public override async Task <GetSeriesResponse> GetAllSeries(SeriesEmpty request, ServerCallContext context) { try { var series = await _series.GetAllSeries(); if (series is null || series.Count() == 0) { throw new Exception("SeriesRep - GetSeries"); } List <SeriesFull> seriesFull = new List <SeriesFull>(); series.ToList().ForEach((ser) => { var sFull = _mapper.Map <Series2, SeriesFull>(ser); seriesFull.Add(sFull); }); return(new GetSeriesResponse() { Series = { seriesFull }, Signal = true }); } catch (Exception e) { _logger.LogError(e, "ERROR"); return(new GetSeriesResponse() { Signal = false }); } }