Esempio n. 1
0
        public async Task <ActionResult> GetPenaltiesByUser(string userId)
        {
            if (userId == null)
            {
                return(BadRequest("empty user id"));
            }

            var penalties = await _penaltyRepository.GetPenaltiesByUserId(userId);

            _logger
            .LogInformation($" penalties " +
                            $"by user id  {userId}  {penalties.Count}");

            var penaltyResponses = new List <PenaltyResponse>();

            penalties
            .ForEach(p => penaltyResponses
                     .Add(_customMapper
                          .PenaltyToPenaltyResponse(p)));

            var responsesArray = penaltyResponses.ToArray();

            _logger.LogInformation($"responsesArray length is {responsesArray.Length}");

            return(Ok(new Response <PenaltyResponse[]>(responsesArray)));
        }