NonInventPurchasingSystem/CPRNIMS.Domain/Services/Account/ControllerAccess.cs
2026-01-20 07:44:30 +08:00

40 lines
1.1 KiB
C#

using CPRNIMS.Domain.Contracts.Account;
using CPRNIMS.Infrastructure.Database;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Account
{
public class ControllerAccess : IControllerAccess
{
private readonly NonInventoryDbContext _dbContext;
public ControllerAccess(NonInventoryDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<List<Infrastructure.Entities.Account.ControllerAccess>> GetControllerAccessByUserId(string userId)
{
try
{
var getMyControllerAccess = await _dbContext.ControllerAccess
.FromSqlRaw($"EXEC GetElementAccessByUserId @UserId = '{userId}'")
.ToListAsync();
return getMyControllerAccess ?? new List<Infrastructure.Entities.Account.ControllerAccess>();
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
}
}