Na most működik az API + adatbázis
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user