chatbot/Chatbot.Api.Application/Services/UserService.cs

35 lines
1000 B
C#
Raw Normal View History

2020-06-06 18:29:20 +03:00
using Chatbot.Api.Domain.Entities;
using Chatbot.Api.Domain.Services;
using System.Threading.Tasks;
namespace Chatbot.Api.Application.Services
{
public interface IUserService
{
Task<User> Authenticate(string username, string password);
}
public class UserService : IUserService
{
private readonly IParamProvider _paramProvider;
public UserService(IParamProvider paramProvider)
{
_paramProvider = paramProvider;
}
public async Task<User> Authenticate(string username, string password)
{
return await Task.Run(() => CheckCredentials(username, password));
}
private User CheckCredentials(string username, string password)
{
if (_paramProvider.Credentials.UserName == username && _paramProvider.Credentials.Password == password)
return new User() { UserName = username, Id = 1 };
else
return null;
}
}
}