survey-webapp/SurveyBackend/SurveyBackend.Services/Services/UserService.cs
shept 55e82425a9 say NO to try-catch in controllers
- added ExceptionsMiddleware.cs
- added more Exception types
- removed all exceptions logic in controllers
2025-04-18 15:15:32 +05:00

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);
}
}