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:
25
OptixServe.Core/Services/UserService.cs
Normal file
25
OptixServe.Core/Services/UserService.cs
Normal 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" }
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user