Make mission -> mission launches one-to-many
This commit is contained in:
@@ -15,7 +15,7 @@ public record MissionResponse
|
||||
|
||||
public required DateTimeOffset CreatedAt { get; init; }
|
||||
|
||||
public MissionLaunchResponse? MissionLaunch { get; set; }
|
||||
public IReadOnlyList<MissionLaunchResponse> MissionLaunches { get; set; } = [];
|
||||
|
||||
public static MissionResponse FromDomain(Mission mission) =>
|
||||
new()
|
||||
@@ -25,6 +25,6 @@ public record MissionResponse
|
||||
Description = mission.Description,
|
||||
Status = mission.Status,
|
||||
CreatedAt = mission.CreatedAt,
|
||||
MissionLaunch = mission.MissionLaunch != null ? MissionLaunchResponse.FromDomain(mission.MissionLaunch) : null,
|
||||
MissionLaunches = mission.MissionLaunches.Select(MissionLaunchResponse.FromDomain).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ListMissions(MissionControlContext dbContext)
|
||||
{
|
||||
var missions = await dbContext.Missions
|
||||
.AsNoTracking()
|
||||
.Include(m => m.MissionLaunch)
|
||||
.Include(m => m.MissionLaunches)
|
||||
.OrderByDescending(m => m.CreatedAt)
|
||||
.ToListAsync(ct);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MissionControl.Data;
|
||||
using MissionControl.Domain.Entities;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user