Na most működik az API + adatbázis

This commit is contained in:
2025-01-15 14:01:58 +01:00
parent 474dce1aa7
commit a2906cc113
17 changed files with 283 additions and 23 deletions
@@ -0,0 +1,43 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WorkFlowCheck.BL.DTO;
using WorkFlowCheck.BL.Services.Interfaces;
using WorkFlowCheck.DL;
namespace WorkFlowCheck.BL.Services
{
public class UserService : IUserService
{
private AppDbContext _dbContext;
private IMapper _mapper;
public UserService(AppDbContext dbContext, IMapper mapper)
{
_dbContext = dbContext;
_mapper = mapper;
}
public async Task<UserDTO> GetUser(int Id)
{
var retVal = new UserDTO();
try
{
var user = await _dbContext.Users.Where(w => w.Id == Id).FirstOrDefaultAsync();
if (user != null)
{
retVal = _mapper.Map<UserDTO>(user);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
}
}