This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
NG_2023_Kanban/NG_2023_Kanban.BusinessLayer/Service/UserService.cs

34 lines
973 B
C#
Raw Normal View History

2023-05-17 12:36:49 +03:00
using NG_2023_Kanban.BusinessLayer.Interfaces;
using NG_2023_Kanban.DataLayer.Repositories;
using NG_2023_Kanban.DataLayer.Entities;
using NG_2023_Kanban.DataLayer.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace NG_2023_Kanban.BusinessLayer.Services
{
public class UserService : IUserService
{
private readonly IUserRepository _userRepository;
public UserService(IUserRepository userRepository)
{
_userRepository = userRepository;
}
public async Task<User?> LoginAsync(User user)
{
var data = await _userRepository.FindAsync(x => x.Username == user.Username && x.Password == user.Password);
if (data.Any())
return data.First();
else
return null;
}
public async Task<User> RegisterAsync(User user)
{
await _userRepository.CreateAsync(user);
return user;
}
}
}