mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 00:08:50 -07:00
autofill common payload instead of saving to db
This commit is contained in:
parent
60cc00dc66
commit
d9d35c47a8
@ -219,8 +219,12 @@ public class MissionService {
|
|||||||
|
|
||||||
Schema.Task? t = mission.Tasks.Find(x => x.TaskID == task.Id);
|
Schema.Task? t = mission.Tasks.Find(x => x.TaskID == task.Id);
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
if (task.Completed) t.Completed = 1;
|
if (task.Completed) {
|
||||||
t.Payload = task.Payload;
|
t.Completed = 1;
|
||||||
|
t.Payload = task.Payload ?? "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Data>\r\n <S>true</S>\r\n</Data>";
|
||||||
|
} else {
|
||||||
|
t.Payload = task.Payload;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,9 +253,14 @@ public class MissionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetTaskProgressDB(int missionId, int taskId, int userId, bool completed, string xmlPayload) {
|
private void SetTaskProgressDB(int missionId, int taskId, int userId, bool completed, string? xmlPayload) {
|
||||||
Model.TaskStatus? status = ctx.TaskStatuses.FirstOrDefault(task => task.Id == taskId && task.MissionId == missionId && task.VikingId == userId);
|
Model.TaskStatus? status = ctx.TaskStatuses.FirstOrDefault(task => task.Id == taskId && task.MissionId == missionId && task.VikingId == userId);
|
||||||
|
|
||||||
|
// Based on the observation that no payloads on completed missions are null
|
||||||
|
// This is the most common task payload, so if the mission is completed with this payload we can set the payload to null and let the server autofill
|
||||||
|
if (completed && xmlPayload == "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Data>\r\n <S>true</S>\r\n</Data>")
|
||||||
|
xmlPayload = null;
|
||||||
|
|
||||||
if (status is null) {
|
if (status is null) {
|
||||||
status = new Model.TaskStatus {
|
status = new Model.TaskStatus {
|
||||||
Id = taskId,
|
Id = taskId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user