public override async Task <GetActorsResponse> GetActors(ActorEmpty a, ServerCallContext context) { try { var actors = await _actor.GetAll(); if (actors is null) { throw new Exception("Neuspesno uzeti glumci!"); } List <ActorAdd> actorsAdd = new List <ActorAdd>(); foreach (var actor in actors) { ActorAdd act = _mapper.Map <Actor, ActorAdd>(actor); actorsAdd.Add(act); } return(new GetActorsResponse() { Actors = { actorsAdd } }); } catch (Exception e) { _logger.LogError(e, "ERROR"); return(new GetActorsResponse() { }); } }
public async Task <IEnumerable <ActorDomainModel> > GetAllAsync() { var actors = await _actorsRepository.GetAll(); List <ActorDomainModel> actorList = new List <ActorDomainModel>(); foreach (var actor in actors) { ActorDomainModel actorModel = new ActorDomainModel { Id = actor.Id, FirstName = actor.FirstName, LastName = actor.LastName }; actorList.Add(actorModel); } return(actorList); }
public List <Actor> GetAllActors() { return(_actorsRepository.GetAll().ToList()); }
public List <ActorResponse> GetAll() { return(_actorsRepository.GetAll()); }