mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-26 15:08:39 +00:00
Store location in seperate table
This commit is contained in:
parent
e95f3a0439
commit
b2428b6ba8
6 changed files with 62 additions and 15 deletions
|
@ -13,12 +13,20 @@ namespace ProjectLighthouse.Controllers {
|
|||
public class UserController : ControllerBase {
|
||||
[HttpGet("user/{username}")]
|
||||
public async Task<IActionResult> GetUser(string username) {
|
||||
User user = await new Database().Users.FirstOrDefaultAsync(u => u.Username == username);
|
||||
await using Database database = new();
|
||||
|
||||
User user = await database.Users.FirstOrDefaultAsync(u => u.Username == username);
|
||||
|
||||
if(user == null) return this.NotFound();
|
||||
return this.Ok(user.Serialize());
|
||||
}
|
||||
|
||||
[HttpPost("user/{username}")]
|
||||
public async Task<IActionResult> CreateUser(string username) {
|
||||
await new Database().CreateUser(username);
|
||||
return await GetUser(username);
|
||||
}
|
||||
|
||||
[HttpPost("updateUser")]
|
||||
public async Task<IActionResult> UpdateUser() {
|
||||
await using Database database = new();
|
||||
|
@ -52,7 +60,7 @@ namespace ProjectLighthouse.Controllers {
|
|||
}
|
||||
}
|
||||
|
||||
await database.SaveChangesAsync();
|
||||
if(database.ChangeTracker.HasChanges()) await database.SaveChangesAsync();
|
||||
return this.Ok();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue