public ThoughtsViewModel GetThoughtsList() { List <ThoughtDto> thoughtDtoList = thoughtService.GetThoughts().ToList(); ThoughtsViewModel viewModel = new ThoughtsViewModel() { ThoughtsList = new List <ThoughtViewModel>() }; foreach (var thoughtDto in thoughtDtoList) { var thought = new ThoughtViewModel() { ThoughtId = thoughtDto.ThoughtId, UserId = thoughtDto.User.UserId, Description = thoughtDto.Description, CreatedDateTime = thoughtDto.CreatedDateTime, SortId = thoughtDto.SortId, PriorityId = thoughtDto.Priority?.PriorityId ?? 0, TimeFrameId = (int)thoughtDto.Timeframe.TimeframeType, TimeFrameDateString = thoughtDto.Timeframe.DateString, TimeFrameTimeString = thoughtDto.Timeframe.TimeString, TimeFrameWeekString = thoughtDto.Timeframe.WeekString, TimeFrameDueString = thoughtDto.Timeframe.DueString }; viewModel.ThoughtsList.Add(thought); } return(viewModel); }
public async Task <IActionResult> Index(int page = 1) { var model = _thoughtService.GetThoughts(page, 10); var ip = Request.Headers["X-Forwarded-For"]; if (!string.IsNullOrWhiteSpace(ip) && model != null && ip != "::1") { _logger.LogInformation($"Content requested by {ip}"); await _viewService.CountViewsAsync(model.Thoughts, ip); } else { _logger.LogInformation($"Content requested"); } return(View(model)); }