Code refactoring + tests

This commit is contained in:
2025-03-04 00:42:20 +01:00
parent a0c93ea587
commit f73fe748ed
8 changed files with 299 additions and 86 deletions

View File

@@ -8,6 +8,8 @@ namespace BasicDotnetTemplate.MainProject.Services;
public interface IUserService
{
User? GetUserById(int id);
User? GetUserByGuid(string guid);
Task<User?> GetUserByUsernameAndPassword(string username, string password);
}
@@ -28,10 +30,19 @@ public class UserService : BaseService, IUserService
private IQueryable<User> GetUserByUsername(string username)
{
return this.GetUsers().Where(x =>
String.Equals(x.Username, username, StringComparison.CurrentCultureIgnoreCase)
);
x.Username.ToString() == username.ToString()
);
}
public User? GetUserById(int id)
{
return this.GetUsers().Where(x => x.Id == id).FirstOrDefault();
}
public User? GetUserByGuid(string guid)
{
return this.GetUsers().Where(x => x.Guid == guid).FirstOrDefault();
}
public async Task<User?> GetUserByUsernameAndPassword(string username, string password)
{