phronCare/Models/Repositories/PhSFormSeriesRepository.cs

36 lines
1.1 KiB
C#
Raw Normal View History

2025-04-27 02:19:29 -03:00
using Microsoft.EntityFrameworkCore;
using Models.Interfaces;
using Models.Models;
namespace PhronCare.Core.Data.Repositories.Sales
{
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;
}
#endregion
}
}