* Added handling Login and User creation to LoginService
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
using AutoMapper;
|
||||
using SytelineSaAppEfDataModel.Dtos;
|
||||
using SytelineSaAppEfDataModel.Entities;
|
||||
|
||||
namespace SytelineSaAppEfDataModel.Services;
|
||||
|
||||
public class LoginService(SytelineSaAppDbContext context, IMapper mapper) : ILoginService
|
||||
{
|
||||
public async EdiUserd CreateUser(string userName, string password)
|
||||
public async Task<EdiUserDto> CreateUser(string userName, string password)
|
||||
{
|
||||
EdiUser user = new EdiUser()
|
||||
{
|
||||
@@ -16,11 +17,11 @@ public class LoginService(SytelineSaAppDbContext context, IMapper mapper) : ILog
|
||||
context.EdiUsers.Add(user);
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
return
|
||||
return mapper.Map<EdiUserDto>(user);
|
||||
}
|
||||
|
||||
public bool Login(string userName, string password)
|
||||
public Task<bool> Login(string userName, string password)
|
||||
{
|
||||
|
||||
return Task.FromResult(context.EdiUsers.Any(u => u.Login == userName && u.Password == password));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user