Adding character coords
This commit is contained in:
parent
900951b1a7
commit
241312b0be
@ -28,12 +28,13 @@ public class CharactersController : ControllerBase
|
|||||||
if (string.IsNullOrWhiteSpace(userId))
|
if (string.IsNullOrWhiteSpace(userId))
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var character = new Character
|
var character = new Character
|
||||||
{
|
{
|
||||||
OwnerUserId = userId,
|
OwnerUserId = userId,
|
||||||
Name = req.Name.Trim(),
|
Name = req.Name.Trim(),
|
||||||
CreatedUtc = DateTime.UtcNow
|
Coord = new Coord { X = 0, Y = 0 },
|
||||||
};
|
CreatedUtc = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
await _characters.CreateAsync(character);
|
await _characters.CreateAsync(character);
|
||||||
return Ok(character);
|
return Ok(character);
|
||||||
|
|||||||
@ -18,6 +18,10 @@ Stored documents (MongoDB)
|
|||||||
"id": "string (ObjectId)",
|
"id": "string (ObjectId)",
|
||||||
"ownerUserId": "string",
|
"ownerUserId": "string",
|
||||||
"name": "string",
|
"name": "string",
|
||||||
|
"coord": {
|
||||||
|
"x": "number",
|
||||||
|
"y": "number"
|
||||||
|
},
|
||||||
"createdUtc": "string (ISO-8601 datetime)"
|
"createdUtc": "string (ISO-8601 datetime)"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@ -11,7 +11,9 @@ public class Character
|
|||||||
|
|
||||||
public string OwnerUserId { get; set; } = string.Empty;
|
public string OwnerUserId { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
|
public Coord Coord { get; set; } = new();
|
||||||
}
|
|
||||||
|
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|||||||
8
microservices/CharacterApi/Models/Coord.cs
Normal file
8
microservices/CharacterApi/Models/Coord.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace CharacterApi.Models;
|
||||||
|
|
||||||
|
public class Coord
|
||||||
|
{
|
||||||
|
public int X { get; set; }
|
||||||
|
|
||||||
|
public int Y { get; set; }
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user