feat: added docker stuff, started working on login system
This commit is contained in:
parent
c2d40c172a
commit
7c0cef6f65
15 changed files with 216 additions and 143 deletions
|
@ -1,53 +0,0 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace ImageBoardServerApp.Data.Repository;
|
||||
|
||||
public static class AccountsRepository
|
||||
{
|
||||
public static async Task<List<AccountData>> getAccountsAsync()
|
||||
{
|
||||
await using var db = new AppDBContext();
|
||||
return await db.Accounts.ToListAsync();
|
||||
}
|
||||
|
||||
public static async Task<List<AccountData>> getAccountsByMailAsync(string email)
|
||||
{
|
||||
await using var db = new AppDBContext();
|
||||
return await db.Accounts
|
||||
.Where(acc => acc.Email.Equals(email))
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public static async Task<AccountData> getAccountByIdAsync(int accountId)
|
||||
{
|
||||
await using var db = new AppDBContext();
|
||||
return await db.Accounts.FirstOrDefaultAsync(post => post.AccountID == accountId);
|
||||
}
|
||||
|
||||
public static async Task<int> createAccountAsync(AccountData accountToCreate)
|
||||
{
|
||||
await using var db = new AppDBContext();
|
||||
await db.Accounts.AddAsync(accountToCreate);
|
||||
if (await db.SaveChangesAsync() >= 1)
|
||||
{
|
||||
Console.WriteLine($"Created post with ID: {accountToCreate.AccountID}");
|
||||
return accountToCreate.AccountID;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static async Task<bool> updateAccountAsync(AccountData accountToUpdate)
|
||||
{
|
||||
await using var db = new AppDBContext();
|
||||
db.Accounts.Update(accountToUpdate);
|
||||
return await db.SaveChangesAsync() >= 1;
|
||||
}
|
||||
|
||||
public static async Task<bool> deleteAccountAsync(int postId)
|
||||
{
|
||||
await using var db = new AppDBContext();
|
||||
AccountData accountToDelete = await getAccountByIdAsync(postId);
|
||||
db.Remove(accountToDelete);
|
||||
return await db.SaveChangesAsync() >= 1;
|
||||
}
|
||||
}
|
|
@ -16,10 +16,10 @@ public static class UsersRepository
|
|||
return await db.Users.FirstOrDefaultAsync(user => user.UserID == userId);
|
||||
}
|
||||
|
||||
public static async Task<UserData> getUserByIPAsync(string userIp)
|
||||
public static async Task<UserData> getUserByEmailAsync(string email)
|
||||
{
|
||||
await using var db = new AppDBContext();
|
||||
return await db.Users.FirstOrDefaultAsync(user => user.Ipv4Address == userIp);
|
||||
return await db.Users.FirstOrDefaultAsync(user => user.Email == email);
|
||||
}
|
||||
|
||||
public static async Task<int> createUserAsync(UserData userToCreate)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue