Implement endpoints with Services Dependency Injection.

**Note: This implementation is not in minimalAPI way and not optimized, expected to be changed soon.**

Add: `UserService` and its interface `IUserService`.

Fix: `UserEndpoint` is now in instance class style with DI to work.

Fix: change main program to work with above design.
This commit is contained in:
2025-07-07 15:54:44 +08:00
parent 1e4aaf33f9
commit 39b28386ae
3 changed files with 84 additions and 30 deletions

View File

@ -0,0 +1,25 @@
using OptixServe.Core.Models;
namespace OptixServe.Core.Services;
public interface IUserService
{
IEnumerable<User> GetUsers();
User? GetUserById(string Id);
}
public class UserService : IUserService
{
public User? GetUserById(string Id)
{
throw new NotImplementedException();
}
public IEnumerable<User> GetUsers()
{
return [
new() { Id = "1234", UserName = "xxx", Password = "pass1" },
new() { Id = "5678", UserName = "yyy", Password = "pass2" }
];
}
}