Location fixes
All checks were successful
All checks were successful
This commit is contained in:
parent
fc647890a6
commit
900951b1a7
@ -42,6 +42,10 @@ public class LocationsController : ControllerBase
|
||||
{
|
||||
return Conflict("Coord must be unique");
|
||||
}
|
||||
catch (MongoWriteException ex) when (ex.WriteError.Code == 121)
|
||||
{
|
||||
return BadRequest("Location document failed validation");
|
||||
}
|
||||
|
||||
return Ok(location);
|
||||
}
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
|
||||
namespace LocationsApi.Models;
|
||||
|
||||
public class Coord
|
||||
{
|
||||
[BsonElement("x")]
|
||||
public int X { get; set; }
|
||||
|
||||
[BsonElement("y")]
|
||||
public int Y { get; set; }
|
||||
}
|
||||
|
||||
@ -9,9 +9,12 @@ public class Location
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string? Id { get; set; }
|
||||
|
||||
[BsonElement("name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[BsonElement("coord")]
|
||||
public required Coord Coord { get; set; }
|
||||
|
||||
[BsonElement("createdUtc")]
|
||||
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user