mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-20 00:02:28 +00:00
Implement DatabaseTests and SlotTests
This commit is contained in:
parent
15e3870620
commit
bbeb7d980e
3 changed files with 71 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
@ -22,11 +23,15 @@ namespace ProjectLighthouse {
|
|||
);
|
||||
|
||||
public async Task<User> CreateUser(string username) {
|
||||
User user;
|
||||
if((user = await Users.Where(u => u.Username == username).FirstOrDefaultAsync()) != null)
|
||||
return user;
|
||||
|
||||
Location l = new(); // store to get id after submitting
|
||||
this.Locations.Add(l); // add to table
|
||||
await this.SaveChangesAsync(); // saving to the database returns the id and sets it on this entity
|
||||
|
||||
User user = new() {
|
||||
user = new() {
|
||||
Username = username,
|
||||
LocationId = l.Id,
|
||||
Biography = username + " hasn't introduced themselves yet.",
|
||||
|
@ -36,7 +41,6 @@ namespace ProjectLighthouse {
|
|||
await this.SaveChangesAsync();
|
||||
|
||||
return user;
|
||||
|
||||
}
|
||||
|
||||
#nullable enable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue