Skip to content
Snippets Groups Projects
Commit 9dc60e4f authored by Enzo Santangelo Dodera's avatar Enzo Santangelo Dodera
Browse files

Merge branch 'feature/CompleteName-Post-PostMessage' into 'develop'

add CompleteName to dtos Post and PostMessage

See merge request !28
parents 02a835f7 6fc1822b
No related branches found
No related tags found
2 merge requests!31Develop,!28add CompleteName to dtos Post and PostMessage
Pipeline #10399 failed
......@@ -16,5 +16,7 @@ namespace Tsi1.BusinessLayer.Dtos
public int PostId { get; set; }
public string CompleteName { get; set; }
}
}
......@@ -16,5 +16,7 @@ namespace Tsi1.BusinessLayer.Dtos
public int UserId { get; set; }
public string CompleteName { get; set; }
}
}
......@@ -72,6 +72,16 @@ namespace Tsi1.BusinessLayer.Services
var postMessageDtos = _mapper.Map<List<PostMessagePreviewDto>>(postMessages);
var userIds = postMessageDtos.Select(x => x.UserId).ToList();
var users = await _context.Users.Where(x => userIds.Contains(x.Id)).ToListAsync();
foreach (var postMessageDto in postMessageDtos)
{
var user = users.FirstOrDefault(x => x.Id == postMessageDto.UserId);
postMessageDto.CompleteName = user.FirstName + " " + user.LastName;
}
result.Data = postMessageDtos;
return result;
......
......@@ -72,6 +72,16 @@ namespace Tsi1.BusinessLayer.Services
var postDtos = _mapper.Map<List<PostPreviewDto>>(posts);
var userIds = postDtos.Select(x => x.UserId).ToList();
var users = await _context.Users.Where(x => userIds.Contains(x.Id)).ToListAsync();
foreach (var postDto in postDtos)
{
var user = users.FirstOrDefault(x => x.Id == postDto.UserId);
postDto.CompleteName = user.FirstName + " " + user.LastName;
}
result.Data = postDtos;
return result;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment