-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add json constructor for robotResponse.cs
- Loading branch information
Showing
2 changed files
with
49 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,70 @@ | ||
using Api.Database.Models; | ||
#pragma warning disable CS8618 | ||
using System.Text.Json.Serialization; | ||
using Api.Database.Models; | ||
namespace Api.Controllers.Models | ||
{ | ||
public class RobotResponse(Robot robot) | ||
public class RobotResponse | ||
{ | ||
public string Id { get; } = robot.Id; | ||
public string Id { get; set; } | ||
|
||
public string Name { get; } = robot.Name; | ||
public string Name { get; set; } | ||
|
||
public string IsarId { get; } = robot.IsarId; | ||
public string IsarId { get; set; } | ||
|
||
public virtual RobotModel Model { get; } = robot.Model; | ||
public virtual RobotModel Model { get; set; } | ||
|
||
public string SerialNumber { get; } = robot.SerialNumber; | ||
public string SerialNumber { get; set; } | ||
|
||
public string CurrentInstallation { get; } = robot.CurrentInstallation; | ||
public string CurrentInstallation { get; set; } | ||
|
||
public AreaResponse? CurrentArea { get; } = robot.CurrentArea != null ? new AreaResponse(robot.CurrentArea) : null; | ||
public AreaResponse? CurrentArea { get; set; } | ||
|
||
public float BatteryLevel { get; } = robot.BatteryLevel; | ||
public float BatteryLevel { get; set; } | ||
|
||
public float? PressureLevel { get; } = robot.PressureLevel; | ||
public float? PressureLevel { get; set; } | ||
|
||
public IList<VideoStream> VideoStreams { get; } = robot.VideoStreams; | ||
public IList<VideoStream> VideoStreams { get; set; } | ||
|
||
public string Host { get; } = robot.Host; | ||
public string Host { get; set; } | ||
|
||
public int Port { get; } = robot.Port; | ||
public int Port { get; set; } | ||
|
||
public bool Enabled { get; } = robot.Enabled; | ||
public bool Enabled { get; set; } | ||
|
||
public bool MissionQueueFrozen { get; } = robot.MissionQueueFrozen; | ||
public bool MissionQueueFrozen { get; set; } | ||
|
||
public RobotStatus Status { get; } = robot.Status; | ||
public RobotStatus Status { get; set; } | ||
|
||
public Pose Pose { get; } = robot.Pose; | ||
public Pose Pose { get; set; } | ||
|
||
public string? CurrentMissionId { get; } = robot.CurrentMissionId; | ||
public string? CurrentMissionId { get; set; } | ||
|
||
public string IsarUri { get; } = robot.IsarUri; | ||
public string IsarUri { get; set; } | ||
|
||
[JsonConstructor] | ||
#nullable disable | ||
public RobotResponse() { } | ||
#nullable enable | ||
|
||
public RobotResponse(Robot robot) | ||
{ | ||
Id = robot.Id; | ||
Name = robot.Name; | ||
IsarId = robot.IsarId; | ||
Model = robot.Model; | ||
SerialNumber = robot.SerialNumber; | ||
CurrentInstallation = robot.CurrentInstallation; | ||
CurrentArea = robot.CurrentArea != null ? new AreaResponse(robot.CurrentArea) : null; | ||
BatteryLevel = robot.BatteryLevel; | ||
PressureLevel = robot.PressureLevel; | ||
VideoStreams = robot.VideoStreams; | ||
Host = robot.Host; | ||
Port = robot.Port; | ||
Enabled = robot.Enabled; | ||
MissionQueueFrozen = robot.MissionQueueFrozen; | ||
Status = robot.Status; | ||
Pose = robot.Pose; | ||
CurrentMissionId = robot.CurrentMissionId; | ||
IsarUri = robot.IsarUri; | ||
} | ||
} | ||
} |