You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.5 KiB
44 lines
1.5 KiB
2 years ago
|
using Biskilog_Accounting.Server.POSModels;
|
||
|
using Biskilog_Accounting.Shared.CustomModels;
|
||
|
using Biskilog_Accounting.Shared.Enums;
|
||
|
using Biskilog_Accounting.Shared.Interfaces;
|
||
|
using Biskilog_Accounting.Shared.POSModels;
|
||
|
using Microsoft.EntityFrameworkCore;
|
||
|
using Microsoft.Net.Http.Headers;
|
||
|
using MySqlConnector;
|
||
|
using System.Drawing.Drawing2D;
|
||
|
|
||
|
namespace Biskilog_Accounting.Server.Services
|
||
|
{
|
||
|
public class UserService : IUser
|
||
|
{
|
||
|
private readonly BiskAcdbContext m_context;
|
||
|
private readonly ITokenService m_tokenService;
|
||
|
private readonly HttpContext m_httpContext;
|
||
|
|
||
|
public UserService(BiskAcdbContext a_context, ITokenService a_tokenService, IHttpContextAccessor a_httpContextAccessor)
|
||
|
{
|
||
|
m_context = a_context;
|
||
|
m_tokenService = a_tokenService;
|
||
|
m_httpContext = a_httpContextAccessor?.HttpContext;
|
||
|
}
|
||
|
public IEnumerable<Tbluser> FetchUsers()
|
||
|
{
|
||
|
string token = m_httpContext.Request.Headers[HeaderNames.Authorization]!;
|
||
|
|
||
|
if (AuthEnums.Valid == m_tokenService.ValidateToken(token))
|
||
|
{
|
||
|
IEnumerable<string> accessiblebranches = m_tokenService.BranchIds(token);
|
||
|
|
||
|
return m_context.Tblusers.Where(b => accessiblebranches.Contains(b.BranchId));
|
||
|
}
|
||
|
return new List<Tbluser>();
|
||
|
}
|
||
|
|
||
|
public Task<IEnumerable<Tbluser>> GetUsers()
|
||
|
{
|
||
|
throw new NotImplementedException();
|
||
|
}
|
||
|
}
|
||
|
}
|