Skip to content

Commit

Permalink
Start userservice application layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddie4k-code committed Nov 16, 2024
1 parent 9c8bafc commit a155c6e
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 2 deletions.
12 changes: 12 additions & 0 deletions UserService/UserService.Application/Interfaces/ILogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace UserService.Application.Interfaces
{
public interface ILogger
{
void Log(string message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UserService.Domain.Entities;

namespace UserService.Application.Interfaces.Persistence
{

/* All concrete implementations for a user repository will implement this interface */
public interface IUserRepository
{

void CreateUser(string email, string password);

User GetUser(string email);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UserService.Domain.Entities;

namespace UserService.Application.Interfaces.Persistence
{
public interface IUserService
{

void Register(string username, string password);

User Login(string username, string password);
}
}
41 changes: 41 additions & 0 deletions UserService/UserService.Application/Services/UserService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UserService.Application.Interfaces;
using UserService.Application.Interfaces.Persistence;
using UserService.Domain.Entities;

namespace UserService.Application.Services
{
public class UserService : IUserService
{

private readonly IUserRepository _userRepository;
private readonly ILogger _logger;

public UserService(IUserRepository userRepository, ILogger logger)
{
this._userRepository = userRepository;
this._logger = logger;
}

public void Register(string username, string password)
{
try {

//logic

} catch(Exception err) {
_logger.Log(err.Message);
}
}

public User Login(string username, string password)
{

throw new NotImplementedException();

}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\UserService.Domain\UserService.Domain.csproj" />
</ItemGroup>

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
25 changes: 25 additions & 0 deletions UserService/UserService.Application/UserService.Application.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UserService.Application", "UserService.Application.csproj", "{C43A8D5F-7F20-43D7-9D6F-275641EB9147}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C43A8D5F-7F20-43D7-9D6F-275641EB9147}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C43A8D5F-7F20-43D7-9D6F-275641EB9147}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C43A8D5F-7F20-43D7-9D6F-275641EB9147}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C43A8D5F-7F20-43D7-9D6F-275641EB9147}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1E9CE0BC-CBEC-4B1D-BCEA-3E7D7FAFC1AB}
EndGlobalSection
EndGlobal
2 changes: 0 additions & 2 deletions UserService/UserService.Domain/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@ public HashSet<UserId> GetFollowers()
{
return this._followers;
}



}

0 comments on commit a155c6e

Please sign in to comment.