All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 5m30s
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Models.Interfaces;
|
|
using Models.Models;
|
|
|
|
namespace Models.Repositories
|
|
{
|
|
public class PhSFormSeriesRepository(PhronCareOperationsHubContext context) : IPhSFormSeriesRepository
|
|
{
|
|
#region Declaraciones
|
|
private readonly PhronCareOperationsHubContext _context = context;
|
|
#endregion
|
|
|
|
#region Métodos
|
|
|
|
public async Task<int> GetNextInternalNumberAsync(int formSeriesId)
|
|
{
|
|
var nextNumberParam = new Microsoft.Data.SqlClient.SqlParameter
|
|
{
|
|
ParameterName = "@NextNumber",
|
|
SqlDbType = System.Data.SqlDbType.Int,
|
|
Direction = System.Data.ParameterDirection.Output
|
|
};
|
|
|
|
await _context.Database.ExecuteSqlRawAsync(
|
|
"EXEC dbo.PhS_FormSeries_GetNextNumber @FormSeriesId = {0}, @NextNumber = @NextNumber OUTPUT",
|
|
formSeriesId,
|
|
nextNumberParam
|
|
);
|
|
|
|
return (int)nextNumberParam.Value;
|
|
}
|
|
public async Task<PhSFormSeries?> GetByIdAsync(int formSeriesId)
|
|
{
|
|
return await _context.PhSFormSeries
|
|
.AsNoTracking()
|
|
.FirstOrDefaultAsync(s => s.Id == formSeriesId);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|