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> GetControllerAccessByUserId(string userId) { try { var getMyControllerAccess = await _dbContext.ControllerAccess .FromSqlRaw($"EXEC GetElementAccessByUserId @UserId = '{userId}'") .ToListAsync(); return getMyControllerAccess ?? new List(); } catch (Exception ex) { ex.ToString(); throw; } } public async Task PostErrorMessage(Infrastructure.Entities.Common.ErrorMessage errorMessage) { await _dbContext.ErrorMessages.AddAsync(errorMessage); await _dbContext.SaveChangesAsync(); } } }