Adding user CRUD methods and controller + automapper

This commit is contained in:
2025-03-13 00:19:29 +01:00
parent 0b354988fd
commit 61b9c732bc
21 changed files with 639 additions and 90 deletions

View File

@@ -8,8 +8,8 @@ namespace BasicDotnetTemplate.MainProject.Services;
public interface IUserService
{
User? GetUserById(int id);
User? GetUserByGuid(string guid);
Task<User?> GetUserByIdAsync(int id);
Task<User?> GetUserByGuidAsync(string guid);
Task<User?> GetUserByUsernameAndPassword(string username, string password);
}
@@ -34,14 +34,14 @@ public class UserService : BaseService, IUserService
);
}
public User? GetUserById(int id)
public async Task<User?> GetUserByIdAsync(int id)
{
return this.GetUsers().Where(x => x.Id == id).FirstOrDefault();
return await this.GetUsers().Where(x => x.Id == id).FirstOrDefaultAsync();
}
public User? GetUserByGuid(string guid)
public async Task<User?> GetUserByGuidAsync(string guid)
{
return this.GetUsers().Where(x => x.Guid == guid).FirstOrDefault();
return await this.GetUsers().Where(x => x.Guid == guid).FirstOrDefaultAsync();
}
public async Task<User?> GetUserByUsernameAndPassword(string username, string password)
@@ -64,5 +64,12 @@ public class UserService : BaseService, IUserService
return user;
}
// public async Task<User?> CreateUser(CreateUserRequestData data)
// {
// }
}