Location fixes
All checks were successful
Deploy Promiscuity Auth API / deploy (push) Successful in 43s
Deploy Promiscuity Character API / deploy (push) Successful in 42s
Deploy Promiscuity Locations API / deploy (push) Successful in 56s
k8s smoke test / test (push) Successful in 6s

This commit is contained in:
hz 2026-01-21 17:43:39 -06:00
parent fc647890a6
commit 900951b1a7
3 changed files with 11 additions and 0 deletions

View File

@ -42,6 +42,10 @@ public class LocationsController : ControllerBase
{ {
return Conflict("Coord must be unique"); return Conflict("Coord must be unique");
} }
catch (MongoWriteException ex) when (ex.WriteError.Code == 121)
{
return BadRequest("Location document failed validation");
}
return Ok(location); return Ok(location);
} }

View File

@ -1,8 +1,12 @@
using MongoDB.Bson.Serialization.Attributes;
namespace LocationsApi.Models; namespace LocationsApi.Models;
public class Coord public class Coord
{ {
[BsonElement("x")]
public int X { get; set; } public int X { get; set; }
[BsonElement("y")]
public int Y { get; set; } public int Y { get; set; }
} }

View File

@ -9,9 +9,12 @@ public class Location
[BsonRepresentation(BsonType.ObjectId)] [BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; } public string? Id { get; set; }
[BsonElement("name")]
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
[BsonElement("coord")]
public required Coord Coord { get; set; } public required Coord Coord { get; set; }
[BsonElement("createdUtc")]
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow; public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
} }