* Added handling Login and User creation to LoginService

This commit is contained in:
2025-01-31 10:13:37 +01:00
parent 9a7920f0e7
commit e3acc0c488

View File

@@ -1,11 +1,12 @@
using AutoMapper; using AutoMapper;
using SytelineSaAppEfDataModel.Dtos;
using SytelineSaAppEfDataModel.Entities; using SytelineSaAppEfDataModel.Entities;
namespace SytelineSaAppEfDataModel.Services; namespace SytelineSaAppEfDataModel.Services;
public class LoginService(SytelineSaAppDbContext context, IMapper mapper) : ILoginService 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() EdiUser user = new EdiUser()
{ {
@@ -16,11 +17,11 @@ public class LoginService(SytelineSaAppDbContext context, IMapper mapper) : ILog
context.EdiUsers.Add(user); context.EdiUsers.Add(user);
await context.SaveChangesAsync(); 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));
} }
} }