fix null for dataSource
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details

pull/10/head
David D'ALMEIDA 1 year ago
parent 9cddc06343
commit 4578b9c4e3

@ -22,7 +22,7 @@ public class ResponseUserDto
public bool IsCoach { get; set; } public bool IsCoach { get; set; }
public LargeImageDto? Image { get; set; } public LargeImageDto? Image { get; set; }
public ActivityTinyDto[] Activities { get; set; } public ActivityTinyDto[] Activities { get; set; }
public DataSourceTinyDto DataSource { get; set; } public DataSourceTinyDto? DataSource { get; set; }
public FriendshipDto?[] Followers { get; set; } public FriendshipDto?[] Followers { get; set; }
public FriendshipDto?[] Followings { get; set; } public FriendshipDto?[] Followings { get; set; }
} }

@ -81,7 +81,7 @@ public static class UserMappeur
{ {
userDto.Activities = athleteEntity.Activities.ToTinyDtos().ToArray(); userDto.Activities = athleteEntity.Activities.ToTinyDtos().ToArray();
userDto.Image = athleteEntity.Image?.ToDto(); userDto.Image = athleteEntity.Image?.ToDto();
userDto.DataSource = athleteEntity.DataSource.ToTinyDto(); userDto.DataSource = athleteEntity.DataSource?.ToTinyDto();
userDto.Followers = athleteEntity.Followers.ToTinyDtos().ToArray(); userDto.Followers = athleteEntity.Followers.ToTinyDtos().ToArray();
userDto.Followings = athleteEntity.Followings.ToTinyDtos().ToArray(); userDto.Followings = athleteEntity.Followings.ToTinyDtos().ToArray();
}; };

@ -71,7 +71,7 @@ public class ActivityController : Controller
_logger.LogError("Athlete with id {id} not found", activityDto.AthleteId); _logger.LogError("Athlete with id {id} not found", activityDto.AthleteId);
return NotFound($"Athlete with id {activityDto.AthleteId} not found"); return NotFound($"Athlete with id {activityDto.AthleteId} not found");
} }
if (activityDto.DataSourceId != null && user.DataSource.Id != activityDto.DataSourceId) if (activityDto.DataSourceId != null && user.DataSource?.Id != activityDto.DataSourceId)
{ {
_logger.LogError("DataSource with id {id} not found for this user", activityDto.DataSourceId); _logger.LogError("DataSource with id {id} not found for this user", activityDto.DataSourceId);
return NotFound($"DataSource with id {activityDto.DataSourceId} not found"); return NotFound($"DataSource with id {activityDto.DataSourceId} not found");

Loading…
Cancel
Save