- added ExceptionsMiddleware.cs - added more Exception types - removed all exceptions logic in controllers
26 lines
No EOL
688 B
C#
26 lines
No EOL
688 B
C#
using SurveyBackend.Core.Models;
|
|
using SurveyBackend.Core.Repositories;
|
|
using SurveyBackend.Core.Services;
|
|
using SurveyBackend.Services.Exceptions;
|
|
|
|
namespace SurveyBackend.Services.Services;
|
|
|
|
public class UserService : IUserService
|
|
{
|
|
private readonly IUserRepository _userRepository;
|
|
|
|
public UserService(IUserRepository userRepository)
|
|
{
|
|
_userRepository = userRepository;
|
|
}
|
|
|
|
public async Task<User> GetUserByEmail(string email)
|
|
{
|
|
return await _userRepository.GetUserByEmail(email) ?? throw new NotFoundException("Email not found");
|
|
}
|
|
|
|
public async Task CreateUserAsync(User user)
|
|
{
|
|
await _userRepository.AddAsync(user);
|
|
}
|
|
} |