Files
FA_WEB/SytelineSaAppEfDataModel/Services/LoginService.cs

27 lines
770 B
C#

using AutoMapper;
using SytelineSaAppEfDataModel.Dtos;
using SytelineSaAppEfDataModel.Entities;
namespace SytelineSaAppEfDataModel.Services;
public class LoginService(SytelineSaAppDbContext context, IMapper mapper) : ILoginService
{
public async Task<EdiUserDto> CreateUser(string userName, string password)
{
EdiUser user = new EdiUser()
{
Login = userName,
Password = password,
};
context.EdiUsers.Add(user);
await context.SaveChangesAsync();
return mapper.Map<EdiUserDto>(user);
}
public Task<bool> Login(string userName, string password)
{
return Task.FromResult(context.EdiUsers.Any(u => u.Login == userName && u.Password == password));
}
}