Esempio n. 1
0
        public async Task <IEnumerable <PlayerFilterResult> > GetPlayers(PlayerFilterCriteria filterCriteria)
        {
            var players = (await _membersRepository.GetPlayersByCriteria(filterCriteria)).ToList();

            if (players.Any())
            {
                foreach (var player in players)
                {
                    var positionName = _membersRepository.GetPositionById(player.PositionId).Name;
                    var position     = (PlayerPosition?)Enum.Parse(typeof(PlayerPosition),
                                                                   positionName, true);
                    player.PreferedPosition = position;
                    byte[] imageArray = File.ReadAllBytes(player.Thumbnail);
                    string base64ImageRepresentation = Convert.ToBase64String(imageArray);
                    player.Thumbnail = base64ImageRepresentation;
                }
            }

            return(players);
        }