feat: implement archive code retrieval for workshops in registration workflow

This commit is contained in:
2025-10-13 12:43:53 +03:30
parent 92fd8d6b0e
commit ecfb7af386
4 changed files with 34 additions and 1 deletions

View File

@@ -70,6 +70,7 @@ public interface IWorkshopRepository : IRepository<long, Workshop>
Task<List<WorkshopWithLeftWorkTempEmployeesDto>> GetWorkshopsForLeftWorkTemp(long accountId);
Task<int> GetWorkshopsForLeftWorkTempCount(long accountId);
Task<List<WorkshopSelectListViewModel>> GetSelectList(string search, long id);
int GetLastArchiveCode();
#endregion

View File

@@ -3,4 +3,6 @@ namespace CompanyManagment.App.Contracts.InstitutionContract;
public class InstitutionContractWorkshopDetailViewModel
{
public WorkshopServicesViewModel ServicesViewModel { get; set; }
public string WorkshopName { get; set; }
public int ArchiveCode { get; set; }
}

View File

@@ -1259,6 +1259,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
{
var details = await _institutionContractRepository.GetInstitutionWorkshopInitialDetails(workshopDetailsId);
var services = details.Services;
var newArchiveCode = _workshopRepository.GetLastArchiveCode() + 1;
var res = new InstitutionContractWorkshopDetailViewModel()
{
@@ -1271,7 +1272,9 @@ public class InstitutionContractApplication : IInstitutionContractApplication
InsuranceInPerson = services.InsuranceInPerson,
RollCall = services.RollCall,
RollCallInPerson = services.RollCallInPerson
}
},
WorkshopName = details.WorkshopName,
ArchiveCode =newArchiveCode
};
return res;
}

View File

@@ -1181,6 +1181,33 @@ public class WorkshopRepository : RepositoryBase<long, Company.Domain.WorkshopAg
return list.DistinctBy(x => x.Id).ToList();
}
public int GetLastArchiveCode()
{
var archiveCodes = _context.Workshops
.Where(x => !string.IsNullOrEmpty(x.ArchiveCode))
.Select(x => x.ArchiveCode)
.ToList();
int maxArchiveCode = 0;
foreach (var code in archiveCodes)
{
// Remove "b-" prefix if exists
string cleanCode = code.StartsWith("b-") ? code.Substring(2) : code;
// Try to parse the clean code to an integer
if (int.TryParse(cleanCode, out int codeValue))
{
if (codeValue > maxArchiveCode)
{
maxArchiveCode = codeValue;
}
}
}
return maxArchiveCode;
}
#endregion
#region NewByHeydari
//public List<WorkshopViewModel> GetWorkshopByWorkshopIds(List<long> workshopIds)