public async Task <IActionResult> Get(int id)
        {
            using (var logger = _loggerManager.CreateLogger())
            {
                var result = await _dayService.GetByIdAsync(id);

                if (result != null)
                {
                    logger.LogInformation($"The day is retreived from database.");
                    return(Ok(result));
                }
                logger.LogInformation($"No day is retreived from database.");
                return(NoContent());
            }
        }
Esempio n. 2
0
        public async Task <IEnumerable <ClientViewDto> > GetClients()
        {
            using (var logger = _loggerManager.CreateLogger())
            {
                var clients = await _repository.GetAllAsync("Line");

                logger.LogInformation("All clients are retrieved");
                ClientViewDto[] clientViewDtos = new ClientViewDto[clients.Count()];
                for (int i = 0; i < clients.Count(); i++)
                {
                    ClientViewDto mappedLine = _mapper.Map <ClientViewDto>(clients.ElementAt(i));
                    mappedLine.Day = await _dayService.GetByIdAsync(clients.ElementAt(i).Line.DayId);

                    clientViewDtos[i] = mappedLine;
                }
                logger.LogInformation("All clients are mapped successfully");

                return(clientViewDtos);
            }
        }