44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
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
|
|
{
|
|
public class ErrorMessageService
|
|
{
|
|
private readonly NonInventoryDbContext _dbContext;
|
|
public ErrorMessageService(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;
|
|
}
|
|
|
|
}
|
|
public async Task PostErrorMessage(Infrastructure.Entities.Common.ErrorMessage errorMessage)
|
|
{
|
|
await _dbContext.ErrorMessages.AddAsync(errorMessage);
|
|
await _dbContext.SaveChangesAsync();
|
|
}
|
|
}
|
|
}
|