Merge branch 'Feature/InstitutionContract/add-registration-style' into Main
# Conflicts: # CompanyManagment.EFCore/Repository/PersonalContractingPartyRepository.cs
This commit is contained in:
@@ -26,6 +26,10 @@ public interface ISmsService
|
||||
#region Mahan
|
||||
|
||||
Task<double> GetCreditAmount();
|
||||
|
||||
public Task<bool> SendInstitutionVerificationLink(string number,string fullName, Guid institutionId);
|
||||
|
||||
public Task<bool> SendInstitutionVerificationCode(string number, string code);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -330,8 +330,30 @@ public class SmsService : ISmsService
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<bool> SendInstitutionVerificationLink(string number,string fullName, Guid institutionId)
|
||||
{
|
||||
var guidStr=institutionId.ToString();
|
||||
var firstPart = guidStr.Substring(0, 15);
|
||||
var secondPart = guidStr.Substring(15);
|
||||
var verificationSendResult =await SmsIr.VerifySendAsync(number, 527519, new VerifySendParameter[]
|
||||
{
|
||||
new("#FULLNAME#", fullName),
|
||||
new("#CODE1#",firstPart),
|
||||
new("#CODE2#",secondPart)
|
||||
});
|
||||
return verificationSendResult.Status == 0;
|
||||
|
||||
}
|
||||
|
||||
public async Task<bool> SendInstitutionVerificationCode(string number, string code)
|
||||
{
|
||||
var verificationSendResult =await SmsIr.VerifySendAsync(number, 965348, new VerifySendParameter[]
|
||||
{
|
||||
new("#VERIFYCODE#", code)
|
||||
});
|
||||
return verificationSendResult.Status == 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -75,4 +75,5 @@ public interface IPersonalContractingPartyRepository :IRepository<long, Personal
|
||||
Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id);
|
||||
|
||||
Task<PersonalContractingParty> GetByNationalCode(string nationalCode);
|
||||
Task<PersonalContractingParty> GetByRegisterId(string registerId);
|
||||
}
|
||||
@@ -23,4 +23,5 @@ public interface IFinancialStatmentRepository : IRepository<long, FinancialStatm
|
||||
Task<GetFinancialStatementBalanceAmount> GetBalanceAmount(long id);
|
||||
Task<double> GetClientDebtAmount(long accountId);
|
||||
Task<FinancialStatmentDetailsByContractingPartyViewModel> GetDetailsByContractingParty(long contractingPartyId,FinancialStatementSearchModel searchModel);
|
||||
Task<FinancialStatment> GetByContractingPartyId(long contractingPartyId);
|
||||
}
|
||||
@@ -930,59 +930,87 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
var syear = command.ContractStartFa.Substring(0, 4);
|
||||
var smonth = command.ContractStartFa.Substring(5, 2);
|
||||
var sday = command.ContractStartFa.Substring(8, 2);
|
||||
|
||||
|
||||
var transaction = await _contractingPartyRepository.BeginTransactionAsync();
|
||||
|
||||
|
||||
if (command.ContractStartFa.TryToGeorgianDateTime(out var contractStartGr) == false)
|
||||
return opration.Failed("تاریخ شروع قرارداد معتبر نیست");
|
||||
|
||||
contractStartGr.AddMonthsFa((int)command.Duration, out var contractEndGr);
|
||||
contractEndGr = contractEndGr.ToFarsi().FindeEndOfMonth().ToGeorgianDateTime();
|
||||
|
||||
|
||||
PersonalContractingParty existingContractingParty = null;
|
||||
if (command.ContractingPartyLegalType == LegalType.Legal)
|
||||
{
|
||||
existingContractingParty =
|
||||
await _contractingPartyRepository.GetByRegisterId(command.LegalParty.RegisterId);
|
||||
if (_contractingPartyRepository.Exists(x =>
|
||||
x.LName == command.LegalParty.CompanyName && x.RegisterId == command.LegalParty.RegisterId) &&
|
||||
_institutionContractRepository.Exists(x=> x.IsActiveString =="true" &&
|
||||
x.ContractStartGr < contractEndGr && contractStartGr < x.ContractEndGr))
|
||||
throw new BadRequestException("امکان ایجاد قرارداد تکراری وجود ندارد");
|
||||
x.LName == command.LegalParty.CompanyName && x.RegisterId == command.LegalParty.RegisterId))
|
||||
{
|
||||
if (_institutionContractRepository.Exists(x => x.ContractStartGr < contractEndGr
|
||||
&& contractStartGr < x.ContractEndGr
|
||||
&& x.ContractingPartyId == existingContractingParty.id
|
||||
&& x.IsActiveString == "true"))
|
||||
{
|
||||
throw new BadRequestException("امکان ایجاد قرارداد تکراری وجود ندارد");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(command.ContractingPartyLegalType == LegalType.Real)
|
||||
else if (command.ContractingPartyLegalType == LegalType.Real)
|
||||
{
|
||||
existingContractingParty =
|
||||
await _contractingPartyRepository.GetByNationalCode(command.RealParty.NationalCode);
|
||||
if (_contractingPartyRepository.Exists(x =>
|
||||
x.LName == command.RealParty.LName && x.Nationalcode == command.RealParty.NationalCode)&&
|
||||
_institutionContractRepository.Exists(x=> x.IsActiveString =="true" &&
|
||||
x.ContractStartGr < contractEndGr && contractStartGr < x.ContractEndGr))
|
||||
throw new BadRequestException("امکان ایجاد قرارداد تکراری وجود ندارد");
|
||||
x.LName == command.RealParty.LName && x.Nationalcode == command.RealParty.NationalCode))
|
||||
{
|
||||
if (_institutionContractRepository.Exists(x => x.ContractStartGr < contractEndGr
|
||||
&& contractStartGr < x.ContractEndGr
|
||||
&& x.ContractingPartyId == existingContractingParty.id
|
||||
&& x.IsActiveString == "true"))
|
||||
{
|
||||
throw new BadRequestException("امکان ایجاد قرارداد تکراری وجود ندارد");
|
||||
}
|
||||
}
|
||||
}
|
||||
OperationResult<PersonalContractingParty> contractingPartyResult = command.ContractingPartyLegalType switch
|
||||
|
||||
PersonalContractingParty contractingParty;
|
||||
if (existingContractingParty != null)
|
||||
{
|
||||
LegalType.Legal => await CreateLegalContractingPartyEntity(command.LegalParty, command.RepresentativeId,command.Address,
|
||||
command.City,command.Province),
|
||||
LegalType.Real => await CreateRealContractingPartyEntity(command.RealParty, command.RepresentativeId,command.Address,
|
||||
command.City,command.Province),
|
||||
_ => throw new BadRequestException("نوع طرف قرارداد مشخص نشده است")
|
||||
};
|
||||
contractingParty = existingContractingParty;
|
||||
}
|
||||
else
|
||||
{
|
||||
OperationResult<PersonalContractingParty> contractingPartyResult = command.ContractingPartyLegalType switch
|
||||
{
|
||||
LegalType.Legal => await CreateLegalContractingPartyEntity(command.LegalParty, command.RepresentativeId,
|
||||
command.Address,
|
||||
command.City, command.Province),
|
||||
LegalType.Real => await CreateRealContractingPartyEntity(command.RealParty, command.RepresentativeId,
|
||||
command.Address,
|
||||
command.City, command.Province),
|
||||
_ => throw new BadRequestException("نوع طرف قرارداد مشخص نشده است")
|
||||
};
|
||||
|
||||
if (!contractingPartyResult.IsSuccedded)
|
||||
return opration.Failed(contractingPartyResult.Message);
|
||||
if (!contractingPartyResult.IsSuccedded)
|
||||
return opration.Failed(contractingPartyResult.Message);
|
||||
|
||||
var contractingParty = contractingPartyResult.Data;
|
||||
contractingParty = contractingPartyResult.Data;
|
||||
}
|
||||
|
||||
|
||||
var contractNo = $"{syear}{smonth}{sday}/{contractingParty.ArchiveCode}/0";
|
||||
|
||||
var representative = _representativeRepository.Get(command.RepresentativeId);
|
||||
if (representative == null)
|
||||
return opration.Failed("معرف مورد نظر یافت نشد");
|
||||
|
||||
|
||||
if (command.IsInstallment &&
|
||||
!command.Workshops.Any(x => x.HasContractPlanInPerson || x.HasInsurancePlanInPerson))
|
||||
{
|
||||
return opration.Failed("برای قراردادهای اقساطی حداقل یک کارگاه باید دارای طرح حضوری باشد");
|
||||
}
|
||||
|
||||
|
||||
|
||||
var today = DateTime.Today;
|
||||
|
||||
@@ -1004,14 +1032,25 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
contractingParty.id,
|
||||
contractingPartyFullName, contractDateGr, contractDateFa, command.Province, command.City, command.Address,
|
||||
contractStartGr,
|
||||
contractStartGr.ToFarsi(), contractEndGr, contractEndGr.ToFarsi(), command.OneMonthAmount, command.DailyCompensation,
|
||||
contractStartGr.ToFarsi(), contractEndGr, contractEndGr.ToFarsi(), command.OneMonthAmount,
|
||||
command.DailyCompensation,
|
||||
command.Obligation, command.TotalAmount, 0,
|
||||
command.Workshops.Count.ToString(),
|
||||
command.Workshops.Sum(x => x.PersonnelCount).ToString(), command.Description,
|
||||
"NotOfficial", "JobRelation", hasValueAddedTax,
|
||||
command.TaxAmount, workshopDetails);
|
||||
|
||||
var financialStatement = new FinancialStatment(contractingParty.id, contractingPartyFullName);
|
||||
|
||||
FinancialStatment financialStatement;
|
||||
if (_financialStatmentRepository.Exists(x=>x.ContractingPartyId == contractingParty.id))
|
||||
{
|
||||
financialStatement = await _financialStatmentRepository.GetByContractingPartyId(contractingParty.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
financialStatement = new FinancialStatment(contractingParty.id, contractingPartyFullName);
|
||||
await _financialStatmentRepository.CreateAsync(financialStatement);
|
||||
}
|
||||
|
||||
if (command.IsInstallment)
|
||||
{
|
||||
@@ -1045,7 +1084,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
financialStatement.AddFinancialTransaction(financialTransaction);
|
||||
}
|
||||
|
||||
await _financialStatmentRepository.CreateAsync(financialStatement);
|
||||
|
||||
await _institutionContractRepository.CreateAsync(entity);
|
||||
await _institutionContractRepository.SaveChangesAsync();
|
||||
|
||||
@@ -1094,7 +1133,8 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
|
||||
await _institutionContractRepository.SaveChangesAsync();
|
||||
|
||||
_smsService.VerifySend(contractingParty.Phone, entity.id.ToString());
|
||||
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
|
||||
entity.PublicId);
|
||||
|
||||
|
||||
await transaction.CommitAsync();
|
||||
@@ -1146,8 +1186,10 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
throw new BadRequestException("کد تایید قبلی هنوز منقضی نشده است",
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "expireTime", (int)institutionContract.ReSendTime.TotalSeconds -
|
||||
(int)(DateTime.Now - institutionContract.VerifyCodeCreation).TotalSeconds }
|
||||
{
|
||||
"expireTime", (int)institutionContract.ReSendTime.TotalSeconds -
|
||||
(int)(DateTime.Now - institutionContract.VerifyCodeCreation).TotalSeconds
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1211,7 +1253,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
|
||||
public async Task<InstitutionContractWorkshopDetailViewModel> GetWorkshopInitialDetails(long workshopDetailsId)
|
||||
{
|
||||
var details =await _institutionContractRepository.GetInstitutionWorkshopInitialDetails(workshopDetailsId);
|
||||
var details = await _institutionContractRepository.GetInstitutionWorkshopInitialDetails(workshopDetailsId);
|
||||
var services = details.Services;
|
||||
|
||||
var res = new InstitutionContractWorkshopDetailViewModel()
|
||||
@@ -1231,10 +1273,11 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
}
|
||||
|
||||
private async Task<OperationResult<PersonalContractingParty>> CreateLegalContractingPartyEntity(
|
||||
CreateInstitutionContractLegalPartyRequest request, long representativeId,string address,string city,string state)
|
||||
CreateInstitutionContractLegalPartyRequest request, long representativeId, string address, string city,
|
||||
string state)
|
||||
{
|
||||
var opration = new OperationResult<PersonalContractingParty>();
|
||||
|
||||
|
||||
|
||||
if (representativeId < 1)
|
||||
return opration.Failed("لطفا معرف را انتخاب کنید");
|
||||
@@ -1262,7 +1305,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
var legalContractingParty = new PersonalContractingParty("*", request.CompanyName,
|
||||
"*", "*", request.RegisterId, request.NationalId,
|
||||
"حقوقی",
|
||||
request.PhoneNumber, request.PhoneNumber,address, representativeId, representative.FullName,
|
||||
request.PhoneNumber, request.PhoneNumber, address, representativeId, representative.FullName,
|
||||
archiveCode, state, city, null, null, request.FName, request.LName, request.Position);
|
||||
|
||||
|
||||
@@ -1273,11 +1316,11 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
||||
}
|
||||
|
||||
private async Task<OperationResult<PersonalContractingParty>> CreateRealContractingPartyEntity(
|
||||
CreateInstitutionContractRealPartyRequest request, long representativeId,string address,
|
||||
string city,string province)
|
||||
CreateInstitutionContractRealPartyRequest request, long representativeId, string address,
|
||||
string city, string province)
|
||||
{
|
||||
var operation = new OperationResult<PersonalContractingParty>();
|
||||
|
||||
|
||||
|
||||
if (representativeId < 1)
|
||||
return operation.Failed("لطفا معرف را انتخاب کنید");
|
||||
|
||||
@@ -105,6 +105,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
result.FatherName = contractingParty.FatherName;
|
||||
result.IdNumberSerial = contractingParty.IdNumberSerial;
|
||||
result.IdNumber = contractingParty.IdNumber;
|
||||
result.NationalCode = contractingParty.Nationalcode;
|
||||
|
||||
if (contractingParty.DateOfBirth != null &&contractingParty.DateOfBirth != dateOfBirthGr)
|
||||
return op.Failed("تاریخ تولد مطابقت ندارد");
|
||||
@@ -219,6 +220,7 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
result.FatherName = createTemp.FatherName;
|
||||
result.IdNumberSerial = createTemp.IdNumberSerial;
|
||||
result.IdNumber = idNumber;
|
||||
result.NationalCode = createTemp.NationalCode;
|
||||
|
||||
|
||||
return op.Succcedded(result);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using _0_Framework.Application;
|
||||
using System;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.CustomizeWorkshopSettingsAgg;
|
||||
using Company.Domain.CustomizeWorkshopSettingsAgg.Entities;
|
||||
@@ -11,7 +12,10 @@ using System.Linq;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext, IAuthHelper authHelper, IEmployeeRepository employeeRepository)
|
||||
public class CustomizeWorkshopSettingsRepository(
|
||||
CompanyContext companyContext,
|
||||
IAuthHelper authHelper,
|
||||
IEmployeeRepository employeeRepository)
|
||||
: RepositoryBase<long, CustomizeWorkshopSettings>(companyContext), ICustomizeWorkshopSettingsRepository
|
||||
{
|
||||
private readonly CompanyContext _companyContext = companyContext;
|
||||
@@ -43,23 +47,31 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
GroupName = x.GroupName,
|
||||
RollCallWorkshopEmployeesSettings = x.CustomizeWorkshopEmployeeSettingsCollection.Select(y =>
|
||||
{
|
||||
var employee = employees.First(e => e.Id == y.EmployeeId);
|
||||
try
|
||||
{
|
||||
var employee = employees.First(e => e.Id == y.EmployeeId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
|
||||
return new CustomizeWorkshopEmployeeSettingsViewModel()
|
||||
{
|
||||
Id = y.id,
|
||||
EmployeeId = y.EmployeeId,
|
||||
IsSettingChanged = y.IsSettingChanged,
|
||||
IsShiftChanged = y.IsShiftChanged,
|
||||
Name = $"{employee}",
|
||||
RollCallWorkshopShifts = y.CustomizeWorkshopEmployeeSettingsShifts.Select(s =>
|
||||
new CustomizeWorkshopShiftViewModel()
|
||||
{
|
||||
EndTime = s.EndTime.ToString("HH:mm"),
|
||||
Placement = s.Placement,
|
||||
StartTime = s.StartTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
Name = $":",
|
||||
// RollCallWorkshopShifts = y.CustomizeWorkshopEmployeeSettingsShifts.Select(s =>
|
||||
// new CustomizeWorkshopShiftViewModel()
|
||||
// {
|
||||
// EndTime = s.EndTime.ToString("HH:mm"),
|
||||
// Placement = s.Placement,
|
||||
// StartTime = s.StartTime.ToString("HH:mm")
|
||||
// }).ToList(),
|
||||
Salary = y.Salary,
|
||||
|
||||
};
|
||||
}).ToList(),
|
||||
WorkshopShiftStatus = x.WorkshopShiftStatus,
|
||||
@@ -71,15 +83,16 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
EndTime = s.EndTime.ToString("HH:mm"),
|
||||
Placement = s.Placement,
|
||||
StartTime = s.StartTime.ToString("HH:mm")
|
||||
|
||||
}).ToList(),
|
||||
MainGroup = x.MainGroup,
|
||||
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.
|
||||
Select(r=>new CustomizeRotatingShiftsViewModel(){StartTime = r.StartTime.ToString("HH:mm"), EndTime = r.EndTime.ToString("HH:mm")}).ToList()
|
||||
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.Select(r =>
|
||||
new CustomizeRotatingShiftsViewModel()
|
||||
{ StartTime = r.StartTime.ToString("HH:mm"), EndTime = r.EndTime.ToString("HH:mm") })
|
||||
.ToList()
|
||||
}).ToList(),
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public CustomizeWorkshopSettingsViewModel GetWorkshopSettingsByWorkshopIdForAdmin(long workshopId)
|
||||
{
|
||||
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().Where(x => x.WorkshopId == workshopId)
|
||||
@@ -116,11 +129,12 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
StartTime = s.StartTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
Salary = y.Salary,
|
||||
CustomizeRotatingShiftsViewModels = y.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel
|
||||
{
|
||||
StartTime = r.StartTime.ToString("HH:mm"),
|
||||
EndTime = r.EndTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
CustomizeRotatingShiftsViewModels = y.CustomizeRotatingShifts.Select(r =>
|
||||
new CustomizeRotatingShiftsViewModel
|
||||
{
|
||||
StartTime = r.StartTime.ToString("HH:mm"),
|
||||
EndTime = r.EndTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
LeavePermittedDays = y.LeavePermittedDays,
|
||||
IrregularShift = y.IrregularShift,
|
||||
WorkshopShiftStatus = y.WorkshopShiftStatus
|
||||
@@ -133,19 +147,16 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
EndTime = s.EndTime.ToString("HH:mm"),
|
||||
Placement = s.Placement,
|
||||
StartTime = s.StartTime.ToString("HH:mm")
|
||||
|
||||
}).ToList(),
|
||||
MainGroup = x.MainGroup,
|
||||
WorkshopShiftStatus = x.WorkshopShiftStatus,
|
||||
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel
|
||||
{
|
||||
StartTime = r.StartTime.ToString("HH:mm"),
|
||||
EndTime = r.EndTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
CustomizeRotatingShiftsViewModels = x.CustomizeRotatingShifts.Select(r =>
|
||||
new CustomizeRotatingShiftsViewModel
|
||||
{
|
||||
StartTime = r.StartTime.ToString("HH:mm"),
|
||||
EndTime = r.EndTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
IrregularShift = x.IrregularShift
|
||||
|
||||
|
||||
|
||||
}).ToList(),
|
||||
};
|
||||
}
|
||||
@@ -153,8 +164,8 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
|
||||
public EditCustomizeWorkshopSettings GetWorkshopSettingsDetails(long workshopId)
|
||||
{
|
||||
|
||||
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().FirstOrDefault(x => x.WorkshopId == workshopId);
|
||||
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery()
|
||||
.FirstOrDefault(x => x.WorkshopId == workshopId);
|
||||
if (entity == null)
|
||||
return new();
|
||||
var viewModel = new EditCustomizeWorkshopSettings()
|
||||
@@ -228,23 +239,25 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
MaxMonthDays = entity.MaxMonthDays,
|
||||
Id = entity.id,
|
||||
ShiftsList = entity.CustomizeWorkshopSettingsShifts.Select(x => new CustomizeWorkshopShiftViewModel()
|
||||
{ EndTime = x.EndTime.ToString("HH:mm"), Placement = x.Placement, StartTime = x.StartTime.ToString("HH:mm") }).ToList(),
|
||||
{
|
||||
EndTime = x.EndTime.ToString("HH:mm"), Placement = x.Placement,
|
||||
StartTime = x.StartTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
BonusesPaysInEndOfMonth = entity.BonusesPaysInEndOfMonth,
|
||||
LeavePermittedDays = entity.LeavePermittedDays,
|
||||
BaseYearsPayInEndOfYear = entity.BaseYearsPayInEndOfYear,
|
||||
WorkshopId = entity.WorkshopId,
|
||||
WorkshopShiftStatus = entity.WorkshopShiftStatus,
|
||||
OffDays = entity.WeeklyOffDays.Select(x=>x.DayOfWeek).ToList()
|
||||
|
||||
OffDays = entity.WeeklyOffDays.Select(x => x.DayOfWeek).ToList()
|
||||
};
|
||||
return viewModel;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public EditCustomizeWorkshopSettings GetSimpleWorkshopSettings(long workshopId)
|
||||
{
|
||||
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery().FirstOrDefault(x => x.WorkshopId == workshopId);
|
||||
var entity = _companyContext.CustomizeWorkshopSettings.AsSplitQuery()
|
||||
.FirstOrDefault(x => x.WorkshopId == workshopId);
|
||||
if (entity == null)
|
||||
{
|
||||
return new();
|
||||
@@ -262,21 +275,20 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
WorkshopId = entity.WorkshopId,
|
||||
WorkshopShiftStatus = entity.WorkshopShiftStatus,
|
||||
HolidayWork = entity.HolidayWork,
|
||||
OffDays = entity.WeeklyOffDays.Select(x=>x.DayOfWeek).ToList()
|
||||
|
||||
OffDays = entity.WeeklyOffDays.Select(x => x.DayOfWeek).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public List<ChangedGroupedViewModel> GetShiftChangesGroupAndEmployees(long customizeWorkshopSettingsId)
|
||||
{
|
||||
|
||||
|
||||
var result = from groupSetting in _companyContext.CustomizeWorkshopGroupSettings.AsSplitQuery()
|
||||
where groupSetting.IsShiftChange // Filter parent tables where isChange is true
|
||||
join employeeSettings in _companyContext.CustomizeWorkshopEmployeeSettings on groupSetting.id equals employeeSettings.CustomizeWorkshopGroupSettingId
|
||||
where employeeSettings.IsShiftChanged// Filter child tables where isChange is true
|
||||
join employeeSettings in _companyContext.CustomizeWorkshopEmployeeSettings on groupSetting.id equals
|
||||
employeeSettings.CustomizeWorkshopGroupSettingId
|
||||
where employeeSettings.IsShiftChanged // Filter child tables where isChange is true
|
||||
join employee in _companyContext.Employees on employeeSettings.EmployeeId equals employee.id
|
||||
group new { employee.FullName, groupSetting.GroupName } by groupSetting.id into grouped
|
||||
group new { employee.FullName, groupSetting.GroupName } by groupSetting.id
|
||||
into grouped
|
||||
select new ChangedGroupedViewModel
|
||||
{
|
||||
GroupName = grouped.First().GroupName,
|
||||
@@ -284,7 +296,6 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
};
|
||||
|
||||
return result.ToList();
|
||||
|
||||
}
|
||||
|
||||
public CustomizeWorkshopSettingsViewModel GetWorkshopIncludeGroupsByWorkshopId(long workshopId)
|
||||
@@ -314,27 +325,27 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
BreakTime = g.BreakTime,
|
||||
HolidayWork = g.HolidayWork,
|
||||
FridayWork = g.FridayWork,
|
||||
CustomizeRotatingShiftsViewModels = g.CustomizeRotatingShifts.Select(r => new CustomizeRotatingShiftsViewModel()
|
||||
{
|
||||
EndTime = r.EndTime.ToString("HH:mm"),
|
||||
StartTime = r.StartTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
OffDayOfWeeks = g.WeeklyOffDays.Select(x=>x.DayOfWeek).ToList()
|
||||
|
||||
CustomizeRotatingShiftsViewModels = g.CustomizeRotatingShifts.Select(r =>
|
||||
new CustomizeRotatingShiftsViewModel()
|
||||
{
|
||||
EndTime = r.EndTime.ToString("HH:mm"),
|
||||
StartTime = r.StartTime.ToString("HH:mm")
|
||||
}).ToList(),
|
||||
OffDayOfWeeks = g.WeeklyOffDays.Select(x => x.DayOfWeek).ToList()
|
||||
}).ToList(),
|
||||
|
||||
|
||||
}).FirstOrDefault();
|
||||
|
||||
return customizeWorkshopSettings;
|
||||
}
|
||||
|
||||
public CustomizeWorkshopEmployeeSettingsViewModel GetEmployeeSettingsByWorkshopIdEmployeeId(long workshopId, long employeeId)
|
||||
public CustomizeWorkshopEmployeeSettingsViewModel GetEmployeeSettingsByWorkshopIdEmployeeId(long workshopId,
|
||||
long employeeId)
|
||||
{
|
||||
var employee = _companyContext.CustomizeWorkshopSettings
|
||||
.AsSplitQuery().Include(x => x.CustomizeWorkshopGroupSettingsCollection)
|
||||
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection)
|
||||
.FirstOrDefault(x => x.WorkshopId == workshopId)?.CustomizeWorkshopGroupSettingsCollection.SelectMany(x => x.CustomizeWorkshopEmployeeSettingsCollection)
|
||||
.FirstOrDefault(x => x.WorkshopId == workshopId)?.CustomizeWorkshopGroupSettingsCollection
|
||||
.SelectMany(x => x.CustomizeWorkshopEmployeeSettingsCollection)
|
||||
.FirstOrDefault(x => x.EmployeeId == employeeId);
|
||||
|
||||
if (employee == null)
|
||||
@@ -361,11 +372,13 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
}
|
||||
|
||||
#region Pooya
|
||||
|
||||
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingsWithMonthlySalary(long workshopId)
|
||||
{
|
||||
var query = _companyContext.CustomizeWorkshopGroupSettings.Where(x => x.MainGroup == false).Include(x => x)
|
||||
.Include(x => x.CustomizeWorkshopEmployeeSettingsCollection).Where(x => x.CustomizeWorkshopEmployeeSettingsCollection.Any(y =>
|
||||
y.WorkshopId == workshopId)).SelectMany(x => x.CustomizeWorkshopEmployeeSettingsCollection)
|
||||
.Include(x => x.CustomizeWorkshopEmployeeSettingsCollection).Where(x =>
|
||||
x.CustomizeWorkshopEmployeeSettingsCollection.Any(y =>
|
||||
y.WorkshopId == workshopId)).SelectMany(x => x.CustomizeWorkshopEmployeeSettingsCollection)
|
||||
.Where(x => x.Salary > 0).Select(x =>
|
||||
new CustomizeWorkshopEmployeeSettingsViewModel()
|
||||
{
|
||||
@@ -380,8 +393,10 @@ public class CustomizeWorkshopSettingsRepository(CompanyContext companyContext,
|
||||
|
||||
public List<CustomizeWorkshopEmployeeSettingsViewModel> GetEmployeeSettingsByWorkshopId(long workshopId)
|
||||
{
|
||||
return _companyContext.CustomizeWorkshopSettings.AsNoTracking().Where(x => x.WorkshopId == workshopId).Include(x => x.CustomizeWorkshopGroupSettingsCollection)
|
||||
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection).SelectMany(x => x.CustomizeWorkshopGroupSettingsCollection
|
||||
return _companyContext.CustomizeWorkshopSettings.AsNoTracking().Where(x => x.WorkshopId == workshopId)
|
||||
.Include(x => x.CustomizeWorkshopGroupSettingsCollection)
|
||||
.ThenInclude(x => x.CustomizeWorkshopEmployeeSettingsCollection).SelectMany(x => x
|
||||
.CustomizeWorkshopGroupSettingsCollection
|
||||
.SelectMany(y => y.CustomizeWorkshopEmployeeSettingsCollection))
|
||||
.Select(x => new CustomizeWorkshopEmployeeSettingsViewModel
|
||||
{
|
||||
|
||||
@@ -362,4 +362,9 @@ public class FinancialStatmentRepository : RepositoryBase<long, FinancialStatmen
|
||||
};
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<FinancialStatment> GetByContractingPartyId(long contractingPartyId)
|
||||
{
|
||||
return await _context.FinancialStatments.FirstOrDefaultAsync(x => x.ContractingPartyId == contractingPartyId);
|
||||
}
|
||||
}
|
||||
@@ -1019,8 +1019,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
var query = _context.InstitutionContractSet
|
||||
.Include(x => x.WorkshopGroup)
|
||||
.ThenInclude(x => x.InitialWorkshops)
|
||||
.Include(x=>x.WorkshopGroup)
|
||||
.ThenInclude(x=>x.CurrentWorkshops)
|
||||
.Include(x => x.WorkshopGroup)
|
||||
.ThenInclude(x => x.CurrentWorkshops)
|
||||
.Include(x => x.ContactInfoList);
|
||||
|
||||
var now = DateTime.Today;
|
||||
@@ -1045,20 +1045,22 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
x.contractingParty,
|
||||
x.statement,
|
||||
StatusPriority =
|
||||
x.contract.IsActiveString == "blue"
|
||||
? (int)InstitutionContractListStatus.DeactiveWithDebt
|
||||
: x.contract.ContractEndGr < now
|
||||
? (int)InstitutionContractListStatus.Deactive
|
||||
: (x.contract.ContractEndGr >= now && x.contract.ContractEndGr <= endThisMontGr)
|
||||
? (int)InstitutionContractListStatus.PendingForRenewal
|
||||
: x.contractingParty.IsBlock == "true"
|
||||
? (int)InstitutionContractListStatus.Block
|
||||
: x.contract.ContractAmount == 0
|
||||
? (int)InstitutionContractListStatus.Free
|
||||
: !x.contractingParty.Employers
|
||||
.SelectMany(e => e.WorkshopEmployers.Select(we => we.Workshop)).Any()
|
||||
? (int)InstitutionContractListStatus.WithoutWorkshop
|
||||
: (int)InstitutionContractListStatus.Active
|
||||
x.contract.VerificationStatus == InstitutionContractVerificationStatus.PendingForVerify
|
||||
? (int)InstitutionContractListStatus.PendingForVerify
|
||||
: x.contract.IsActiveString == "blue"
|
||||
? (int)InstitutionContractListStatus.DeactiveWithDebt
|
||||
: x.contract.ContractEndGr < now
|
||||
? (int)InstitutionContractListStatus.Deactive
|
||||
: (x.contract.ContractEndGr >= now && x.contract.ContractEndGr <= endThisMontGr)
|
||||
? (int)InstitutionContractListStatus.PendingForRenewal
|
||||
: x.contractingParty.IsBlock == "true"
|
||||
? (int)InstitutionContractListStatus.Block
|
||||
: x.contract.ContractAmount == 0
|
||||
? (int)InstitutionContractListStatus.Free
|
||||
: !x.contractingParty.Employers
|
||||
.SelectMany(e => e.WorkshopEmployers.Select(we => we.Workshop)).Any()
|
||||
? (int)InstitutionContractListStatus.WithoutWorkshop
|
||||
: (int)InstitutionContractListStatus.Active
|
||||
});
|
||||
|
||||
#region Search
|
||||
@@ -1234,35 +1236,37 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
var archiveCode = minArchiveCode == 10000000 ? 0 : minArchiveCode;
|
||||
var status = Enum.Parse<InstitutionContractListStatus>(x.StatusPriority.ToString());
|
||||
List<InstitutionContractWorkshopBase> currentStateWorkshops = x.contract.WorkshopGroup?.CurrentWorkshops.Cast<InstitutionContractWorkshopBase>().ToList();
|
||||
|
||||
currentStateWorkshops?.AddRange(x.contract.WorkshopGroup?.InitialWorkshops.Where(w=>!w.WorkshopCreated)??[]);
|
||||
|
||||
var workshopDetails = currentStateWorkshops?.Select(w =>
|
||||
{
|
||||
Workshop workshopSelected = null;
|
||||
Console.WriteLine(w.WorkshopId);
|
||||
if (w.WorkshopId != null && workshops.Select(ww => ww.id).Contains(w.WorkshopId.Value))
|
||||
{
|
||||
workshopSelected = workshops.First(ww => ww.id == w.WorkshopId.Value);
|
||||
}
|
||||
List<InstitutionContractWorkshopBase> currentStateWorkshops = x.contract.WorkshopGroup?.CurrentWorkshops
|
||||
.Cast<InstitutionContractWorkshopBase>().ToList();
|
||||
|
||||
return new InstitutionContractListWorkshop()
|
||||
currentStateWorkshops?.AddRange(
|
||||
x.contract.WorkshopGroup?.InitialWorkshops.Where(w => !w.WorkshopCreated) ?? []);
|
||||
|
||||
var workshopDetails = currentStateWorkshops?.Select(w =>
|
||||
{
|
||||
Workshop workshopSelected = null;
|
||||
Console.WriteLine(w.WorkshopId);
|
||||
if (w.WorkshopId != null && workshops.Select(ww => ww.id).Contains(w.WorkshopId.Value))
|
||||
{
|
||||
workshopSelected = workshops.First(ww => ww.id == w.WorkshopId.Value);
|
||||
}
|
||||
|
||||
return new InstitutionContractListWorkshop()
|
||||
{
|
||||
EmployeeCount = w.PersonnelCount,
|
||||
WorkshopName = workshopSelected?.WorkshopName ?? w.WorkshopName,
|
||||
WorkshopServices = new WorkshopServicesViewModel()
|
||||
{
|
||||
EmployeeCount = w.PersonnelCount,
|
||||
WorkshopName = workshopSelected?.WorkshopName ?? w.WorkshopName,
|
||||
WorkshopServices = new WorkshopServicesViewModel()
|
||||
{
|
||||
Contract = w.Services.Contract,
|
||||
ContractInPerson = w.Services.ContractInPerson,
|
||||
CustomizeCheckout = w.Services.CustomizeCheckout,
|
||||
Insurance = w.Services.Insurance,
|
||||
InsuranceInPerson = w.Services.InsuranceInPerson,
|
||||
RollCall = w.Services.RollCall,
|
||||
RollCallInPerson = w.Services.RollCallInPerson
|
||||
}
|
||||
};
|
||||
}).ToList() ?? [];
|
||||
Contract = w.Services.Contract,
|
||||
ContractInPerson = w.Services.ContractInPerson,
|
||||
CustomizeCheckout = w.Services.CustomizeCheckout,
|
||||
Insurance = w.Services.Insurance,
|
||||
InsuranceInPerson = w.Services.InsuranceInPerson,
|
||||
RollCall = w.Services.RollCall,
|
||||
RollCallInPerson = w.Services.RollCallInPerson
|
||||
}
|
||||
};
|
||||
}).ToList() ?? [];
|
||||
return new GetInstitutionContractListItemsViewModel()
|
||||
{
|
||||
ContractAmount = x.contract.ContractAmount,
|
||||
@@ -1502,7 +1506,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
DoneWorkshops = x.institutionContract.WorkshopGroup.InitialWorkshops.Count(w => w.WorkshopCreated),
|
||||
TotalWorkshops =
|
||||
x.institutionContract.WorkshopGroup.InitialWorkshops.Count,
|
||||
UnDoneWorkshops = x.institutionContract.WorkshopGroup.InitialWorkshops.Count(w => !w.WorkshopCreated),
|
||||
UnDoneWorkshops =
|
||||
x.institutionContract.WorkshopGroup.InitialWorkshops.Count(w => !w.WorkshopCreated),
|
||||
ContractingPartyId = x.contractingParty.id
|
||||
}).ToListAsync();
|
||||
}
|
||||
@@ -1695,10 +1700,10 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
{ "isVerified", true }
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
int installmentNumber = 1;
|
||||
|
||||
|
||||
|
||||
var res = new GetInstitutionVerificationDetailsViewModel()
|
||||
{
|
||||
@@ -1710,7 +1715,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
TotalPrice = (query.contract.TotalAmount - query.contract.ValueAddedTax).ToMoney(),
|
||||
PaymentPrice = query.contract.TotalAmount.ToMoney(),
|
||||
IsInstallment = query.contract.IsInstallment,
|
||||
Installments = query.contract.Installments.OrderBy(x=>x.InstallmentDateGr)
|
||||
Installments = query.contract.Installments.OrderBy(x => x.InstallmentDateGr)
|
||||
.Select(x =>
|
||||
{
|
||||
var res = new InstitutionContractInstallmentViewModel()
|
||||
@@ -1769,6 +1774,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private string GetInstallmentPersianNumber(int number)
|
||||
{
|
||||
return number switch
|
||||
@@ -1783,22 +1789,20 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
8 => "هشتم",
|
||||
9 => "نهم",
|
||||
10 => "دهم",
|
||||
11=>"یازدهم",
|
||||
12=>"دوازدهم",
|
||||
11 => "یازدهم",
|
||||
12 => "دوازدهم",
|
||||
_ => number.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<InstitutionContract> GetByPublicIdAsync(Guid id)
|
||||
{
|
||||
return await _context.InstitutionContractSet.FirstOrDefaultAsync(x => x.PublicId == id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CustomViewModels
|
||||
|
||||
public class WorkshopsAndEmployeeViewModel
|
||||
|
||||
@@ -15,7 +15,8 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalContractingParty>, IPersonalContractingPartyRepository
|
||||
public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalContractingParty>,
|
||||
IPersonalContractingPartyRepository
|
||||
{
|
||||
private readonly CompanyContext _context;
|
||||
private readonly AccountContext _accountContext;
|
||||
@@ -25,6 +26,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
_context = context;
|
||||
_accountContext = accountContext;
|
||||
}
|
||||
|
||||
public List<PersonalContractingPartyViewModel> GetPersonalContractingParties()
|
||||
{
|
||||
var res = _context.PersonalContractingParties.Select(x => new PersonalContractingPartyViewModel
|
||||
@@ -58,7 +60,6 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
//NationalId = x.NationalId,
|
||||
|
||||
IsLegal = x.IsLegal,
|
||||
|
||||
}).ToList();
|
||||
//var result = new List<PersonalContractingPartyViewModel>();
|
||||
//foreach (var item in res)
|
||||
@@ -71,35 +72,34 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public EditPersonalContractingParty GetDetails(long id)
|
||||
{
|
||||
var res = _context.PersonalContractingParties.Select(x => new EditPersonalContractingParty()
|
||||
{
|
||||
Id = x.id,
|
||||
{
|
||||
Id = x.id,
|
||||
|
||||
FName = x.FName,
|
||||
LName = x.IsLegal == "حقیقی" ? $"{x.FName} {x.LName}" : $"{x.LName}",
|
||||
SureName = x.SureName,
|
||||
Nationalcode = x.Nationalcode,
|
||||
IdNumber = x.IdNumber,
|
||||
RegisterId = x.RegisterId,
|
||||
NationalId = x.NationalId,
|
||||
IsLegal = x.IsLegal,
|
||||
Phone = x.Phone,
|
||||
AgentPhone = x.AgentPhone,
|
||||
Address = x.Address,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
RepresentativeFullName = x.RepresentativeFullName,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Zone = x.Zone,
|
||||
IsActiveString = x.IsActiveString,
|
||||
IsBlock = x.IsBlock,
|
||||
BlockTimes = x.BlockTimes,
|
||||
|
||||
|
||||
})
|
||||
FName = x.FName,
|
||||
LName = x.IsLegal == "حقیقی" ? $"{x.FName} {x.LName}" : $"{x.LName}",
|
||||
SureName = x.SureName,
|
||||
Nationalcode = x.Nationalcode,
|
||||
IdNumber = x.IdNumber,
|
||||
RegisterId = x.RegisterId,
|
||||
NationalId = x.NationalId,
|
||||
IsLegal = x.IsLegal,
|
||||
Phone = x.Phone,
|
||||
AgentPhone = x.AgentPhone,
|
||||
Address = x.Address,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
RepresentativeFullName = x.RepresentativeFullName,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Zone = x.Zone,
|
||||
IsActiveString = x.IsActiveString,
|
||||
IsBlock = x.IsBlock,
|
||||
BlockTimes = x.BlockTimes,
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
if (res != null)
|
||||
@@ -109,35 +109,34 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public EditPersonalContractingParty GetDetailsToEdit(long id)
|
||||
{
|
||||
return _context.PersonalContractingParties.Select(x => new EditPersonalContractingParty()
|
||||
{
|
||||
Id = x.id,
|
||||
{
|
||||
Id = x.id,
|
||||
|
||||
FName = x.FName,
|
||||
LName = x.LName,
|
||||
SureName = x.SureName,
|
||||
Nationalcode = x.Nationalcode,
|
||||
IdNumber = x.IdNumber,
|
||||
RegisterId = x.RegisterId,
|
||||
NationalId = x.NationalId,
|
||||
IsLegal = x.IsLegal,
|
||||
Phone = x.Phone,
|
||||
AgentPhone = x.AgentPhone,
|
||||
Address = x.Address,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
RepresentativeFullName = x.RepresentativeFullName,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Zone = x.Zone,
|
||||
IsActiveString = x.IsActiveString,
|
||||
IsBlock = x.IsBlock,
|
||||
BlockTimes = x.BlockTimes,
|
||||
|
||||
|
||||
})
|
||||
FName = x.FName,
|
||||
LName = x.LName,
|
||||
SureName = x.SureName,
|
||||
Nationalcode = x.Nationalcode,
|
||||
IdNumber = x.IdNumber,
|
||||
RegisterId = x.RegisterId,
|
||||
NationalId = x.NationalId,
|
||||
IsLegal = x.IsLegal,
|
||||
Phone = x.Phone,
|
||||
AgentPhone = x.AgentPhone,
|
||||
Address = x.Address,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
RepresentativeFullName = x.RepresentativeFullName,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Zone = x.Zone,
|
||||
IsActiveString = x.IsActiveString,
|
||||
IsBlock = x.IsBlock,
|
||||
BlockTimes = x.BlockTimes,
|
||||
})
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
@@ -151,25 +150,18 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
FName = x.FName,
|
||||
LName = x.IsLegal == "حقیقی" ? $"{x.FName} {x.LName}" : $"{x.LName}",
|
||||
SureName = x.SureName
|
||||
|
||||
|
||||
}).FirstOrDefault(x => x.id == id);
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
|
||||
return FullName = !string.IsNullOrWhiteSpace(res.SureName)
|
||||
? $"{res.LName} ({res.SureName})"
|
||||
: $"{res.LName}";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public List<PersonalContractingPartyViewModel> Search(PersonalContractingPartySearchModel searchModel2)
|
||||
@@ -219,12 +211,10 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
|
||||
public int GetLastNewArchiveCode()
|
||||
{
|
||||
|
||||
var res = _context.PersonalContractingParties.Max(x => x.ArchiveCode);
|
||||
|
||||
if (res > 0)
|
||||
{
|
||||
|
||||
res += 1;
|
||||
return res;
|
||||
}
|
||||
@@ -236,6 +226,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
|
||||
|
||||
#region Mahan
|
||||
|
||||
public List<string> SearchByName(string name)
|
||||
{
|
||||
var contractingParties = _context.PersonalContractingParties.Select(x => new PersonalContractingPartyViewModel()
|
||||
@@ -247,64 +238,69 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
|
||||
public AccountViewModel GetAccountByPersonalContractingParty(long contractingPartyId)
|
||||
{
|
||||
long? accId = _context.ContractingPartyAccounts.FirstOrDefault(x => x.PersonalContractingPartyId == contractingPartyId)?.AccountId;
|
||||
long? accId = _context.ContractingPartyAccounts
|
||||
.FirstOrDefault(x => x.PersonalContractingPartyId == contractingPartyId)?.AccountId;
|
||||
if (accId == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
return _accountContext.Accounts.Where(x => x.id == accId && x.IsActiveString == "true").Select(x => new AccountViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
Fullname = x.Fullname,
|
||||
Mobile = x.Mobile,
|
||||
ClientAreaPermission = x.ClientAriaPermission
|
||||
|
||||
}).FirstOrDefault();
|
||||
return _accountContext.Accounts.Where(x => x.id == accId && x.IsActiveString == "true").Select(x =>
|
||||
new AccountViewModel()
|
||||
{
|
||||
Id = x.id,
|
||||
Fullname = x.Fullname,
|
||||
Mobile = x.Mobile,
|
||||
ClientAreaPermission = x.ClientAriaPermission
|
||||
}).FirstOrDefault();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region NewByHeydari
|
||||
|
||||
public List<PersonalContractingPartyViewModel> GetPersonalContractingPartiesForNationalcode(string searchText)
|
||||
{
|
||||
var result = _context.PersonalContractingParties.Where(x => (!string.IsNullOrEmpty(x.Nationalcode) && x.Nationalcode.StartsWith(searchText)))
|
||||
var result = _context.PersonalContractingParties.Where(x =>
|
||||
(!string.IsNullOrEmpty(x.Nationalcode) && x.Nationalcode.StartsWith(searchText)))
|
||||
.Select(x => new PersonalContractingPartyViewModel
|
||||
{
|
||||
id = x.id,
|
||||
Nationalcode = x.Nationalcode,
|
||||
|
||||
}).Take(100).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<PersonalContractingPartyViewModel> SearchForMain(PersonalContractingPartySearchModel searchModel2)
|
||||
{
|
||||
var query = _context.PersonalContractingParties.Include(x => x.Employers).Select(x => new PersonalContractingPartyViewModel
|
||||
{
|
||||
id = x.id,
|
||||
var query = _context.PersonalContractingParties.Include(x => x.Employers).Select(x =>
|
||||
new PersonalContractingPartyViewModel
|
||||
{
|
||||
id = x.id,
|
||||
|
||||
FName = x.FName,
|
||||
LName = !string.IsNullOrWhiteSpace(x.SureName) ? $"{x.LName} ({x.SureName})" : $"{x.LName}",
|
||||
SureName = x.SureName,
|
||||
Nationalcode = x.Nationalcode,
|
||||
IdNumber = x.IdNumber,
|
||||
RegisterId = x.RegisterId,
|
||||
NationalId = x.NationalId,
|
||||
IsLegal = x.IsLegal,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
FullName = x.FName + " " + x.LName,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Zone = x.Zone,
|
||||
IsActiveString = x.IsActiveString,
|
||||
IsBlock = x.IsBlock,
|
||||
BlockTimes = x.BlockTimes,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
CreationDate = x.CreationDate.ToString(),
|
||||
EmployerList = x.Employers.Select(y => new EmployerViewModel() { Id = y.id, FullName = y.FullName }).ToList()
|
||||
|
||||
});
|
||||
FName = x.FName,
|
||||
LName = !string.IsNullOrWhiteSpace(x.SureName) ? $"{x.LName} ({x.SureName})" : $"{x.LName}",
|
||||
SureName = x.SureName,
|
||||
Nationalcode = x.Nationalcode,
|
||||
IdNumber = x.IdNumber,
|
||||
RegisterId = x.RegisterId,
|
||||
NationalId = x.NationalId,
|
||||
IsLegal = x.IsLegal,
|
||||
ArchiveCode = x.ArchiveCode,
|
||||
FullName = x.FName + " " + x.LName,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Zone = x.Zone,
|
||||
IsActiveString = x.IsActiveString,
|
||||
IsBlock = x.IsBlock,
|
||||
BlockTimes = x.BlockTimes,
|
||||
RepresentativeId = x.RepresentativeId,
|
||||
CreationDate = x.CreationDate.ToString(),
|
||||
EmployerList = x.Employers.Select(y => new EmployerViewModel() { Id = y.id, FullName = y.FullName })
|
||||
.ToList()
|
||||
});
|
||||
if (searchModel2.id > 0)
|
||||
query = query.Where(x => x.id == searchModel2.id);
|
||||
|
||||
@@ -322,36 +318,44 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
|
||||
if (!string.IsNullOrEmpty(searchModel2.RepresentativeName))
|
||||
{
|
||||
var representativeIds = _context.RepresentativeSet.Where(x => !string.IsNullOrEmpty(x.FullName) && x.FullName.Contains(searchModel2.RepresentativeName)).Select(x => x.id).ToList();
|
||||
var representativeIds = _context.RepresentativeSet
|
||||
.Where(x => !string.IsNullOrEmpty(x.FullName) && x.FullName.Contains(searchModel2.RepresentativeName))
|
||||
.Select(x => x.id).ToList();
|
||||
query = query.Where(x => representativeIds.Contains(x.RepresentativeId));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(searchModel2.EmployeeName))
|
||||
{
|
||||
query = query.Where(x => (x.IsLegal == "حقیقی" &&
|
||||
((!string.IsNullOrWhiteSpace(x.FName) && x.FName.StartsWith(searchModel2.EmployeeName)) ||
|
||||
(!string.IsNullOrWhiteSpace(x.LName) && x.LName.StartsWith(searchModel2.EmployeeName))))
|
||||
|| (x.IsLegal == "حقوقی" && (!string.IsNullOrWhiteSpace(x.LName) && x.LName.Contains(searchModel2.EmployeeName))));
|
||||
((!string.IsNullOrWhiteSpace(x.FName) &&
|
||||
x.FName.StartsWith(searchModel2.EmployeeName)) ||
|
||||
(!string.IsNullOrWhiteSpace(x.LName) &&
|
||||
x.LName.StartsWith(searchModel2.EmployeeName))))
|
||||
|| (x.IsLegal == "حقوقی" && (!string.IsNullOrWhiteSpace(x.LName) &&
|
||||
x.LName.Contains(searchModel2.EmployeeName))));
|
||||
}
|
||||
|
||||
return query.OrderByDescending(x => x.id).ToList();
|
||||
}
|
||||
|
||||
public OperationResult DeletePersonalContractingParties(long id)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
try
|
||||
{
|
||||
var personalContractingParties = _context.PersonalContractingParties.Where(x => x.id == id)?.FirstOrDefault();
|
||||
var personalContractingParties =
|
||||
_context.PersonalContractingParties.Where(x => x.id == id)?.FirstOrDefault();
|
||||
_context.PersonalContractingParties.Remove(personalContractingParties);
|
||||
_context.SaveChanges();
|
||||
return op.Succcedded(-1, "حذف با موفقیت انجام شد.");
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return op.Failed("حذف با خطا مواجه شد.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool GetHasContract(long id)
|
||||
{
|
||||
return _context.InstitutionContractSet.Any(x => x.IsActiveString == "true" && x.ContractingPartyId == id);
|
||||
@@ -371,7 +375,8 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
employers.ForEach(x => x.DeActive());
|
||||
|
||||
var employerIds = employers.Select(x => x.id).ToList();
|
||||
var workshopIds = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList();
|
||||
var workshopIds = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId))
|
||||
.Select(x => x.WorkshopId).ToList();
|
||||
var workshops = _context.Workshops.Where(x => workshopIds.Contains(x.id)).ToList();
|
||||
workshops.ForEach(x => x.DeActive(x.ArchiveCode));
|
||||
|
||||
@@ -410,7 +415,8 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
employers.ForEach(x => x.Active());
|
||||
|
||||
var employerIds = employers.Select(x => x.id).ToList();
|
||||
var workshopIds = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList();
|
||||
var workshopIds = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId))
|
||||
.Select(x => x.WorkshopId).ToList();
|
||||
var workshops = _context.Workshops.Where(x => workshopIds.Contains(x.id)).ToList();
|
||||
workshops.ForEach(x => x.Active(x.ArchiveCode));
|
||||
|
||||
@@ -451,6 +457,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
}
|
||||
|
||||
#region Insurance
|
||||
|
||||
public bool IsBlockCheckByWorkshopId(long workshopId)
|
||||
{
|
||||
var e = _context.WorkshopEmployers
|
||||
@@ -460,17 +467,22 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
.Select(c => c.Employer.ContractingParty);
|
||||
return e.Any(x => x.IsBlock == "true");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ForClients
|
||||
|
||||
public ContractingPartyAndStatmentIdViewModel GetContractingpartyIdByAccountId(long accountId)
|
||||
{
|
||||
var contractingPartId = _context.ContractingPartyAccounts.Any(x => x.AccountId == accountId) ?
|
||||
_context.ContractingPartyAccounts.FirstOrDefault(x => x.AccountId == accountId)!.PersonalContractingPartyId : 0;
|
||||
var contractingPartId = _context.ContractingPartyAccounts.Any(x => x.AccountId == accountId)
|
||||
? _context.ContractingPartyAccounts.FirstOrDefault(x => x.AccountId == accountId)!
|
||||
.PersonalContractingPartyId
|
||||
: 0;
|
||||
var financialStatmentId = _context.FinancialStatments
|
||||
.Any(x => x.ContractingPartyId == contractingPartId) ? _context.FinancialStatments
|
||||
.FirstOrDefault(x => x.ContractingPartyId == contractingPartId)!.id : 0;
|
||||
.Any(x => x.ContractingPartyId == contractingPartId)
|
||||
? _context.FinancialStatments
|
||||
.FirstOrDefault(x => x.ContractingPartyId == contractingPartId)!.id
|
||||
: 0;
|
||||
|
||||
var res = new ContractingPartyAndStatmentIdViewModel()
|
||||
{
|
||||
@@ -485,14 +497,15 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
|
||||
|
||||
#region Api
|
||||
public async Task<ICollection<ContractingPartyGetListViewModel>> GetList(ContractingPartyGetListSearchModel searchModel)
|
||||
|
||||
public async Task<ICollection<ContractingPartyGetListViewModel>> GetList(
|
||||
ContractingPartyGetListSearchModel searchModel)
|
||||
{
|
||||
var personalContractingPartiesQuery = _context.PersonalContractingParties
|
||||
.Include(x => x.Representative)
|
||||
.Include(x => x.Employers).AsQueryable();
|
||||
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.NationalIdOrNationalCode))
|
||||
personalContractingPartiesQuery = personalContractingPartiesQuery
|
||||
.Where(x => x.Nationalcode.Contains(searchModel.NationalIdOrNationalCode) ||
|
||||
@@ -510,8 +523,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
};
|
||||
|
||||
personalContractingPartiesQuery = personalContractingPartiesQuery
|
||||
.Where(x => x.IsLegal == type);
|
||||
|
||||
.Where(x => x.IsLegal == type);
|
||||
}
|
||||
|
||||
|
||||
@@ -539,8 +551,11 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
personalContractingPartiesQuery = personalContractingPartiesQuery.Where(x =>
|
||||
(x.FName + " " + x.LName).Contains(searchModel.FullNameOrCompanyName));
|
||||
}
|
||||
|
||||
var joinedQuery = personalContractingPartiesQuery
|
||||
.GroupJoin(_context.InstitutionContractSet.Where(x => personalContractingPartiesQuery.Any(p => p.id == x.ContractingPartyId)),
|
||||
.GroupJoin(
|
||||
_context.InstitutionContractSet.Where(x =>
|
||||
personalContractingPartiesQuery.Any(p => p.id == x.ContractingPartyId)),
|
||||
contractingParty => contractingParty.id,
|
||||
institution => institution.ContractingPartyId,
|
||||
(contractingParty, institution) => new
|
||||
@@ -555,19 +570,24 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
ArchiveCode = x.contractingParty.ArchiveCode,
|
||||
BlockTimes = x.contractingParty.BlockTimes,
|
||||
|
||||
ContractingPartyName = x.contractingParty.IsLegal == "حقیقی" ?
|
||||
x.contractingParty.SureName == null ? $"{x.contractingParty.FName} {x.contractingParty.LName}"
|
||||
ContractingPartyName = x.contractingParty.IsLegal == "حقیقی" ? x.contractingParty.SureName == null
|
||||
? $"{x.contractingParty.FName} {x.contractingParty.LName}"
|
||||
: $"{x.contractingParty.FName} {x.contractingParty.LName} {x.contractingParty.SureName}"
|
||||
: x.contractingParty.SureName == null ? $"{x.contractingParty.LName}"
|
||||
: $"{x.contractingParty.LName} {x.contractingParty.SureName}",
|
||||
: $"{x.contractingParty.LName} {x.contractingParty.SureName}",
|
||||
|
||||
ContractingPartyType = x.contractingParty.IsLegal == "حقیقی" ? LegalType.Real : LegalType.Legal,
|
||||
Employers = x.contractingParty.Employers.Take(11).Select(e => new ContractingPartyGetListEmployerViewModel(e.id, e.FullName)).ToList(),
|
||||
Employers = x.contractingParty.Employers.Take(11)
|
||||
.Select(e => new ContractingPartyGetListEmployerViewModel(e.id, e.FullName)).ToList(),
|
||||
Id = x.contractingParty.id,
|
||||
IsBlock = x.contractingParty.IsBlock == "true",
|
||||
HasInstitutionContract = x.institution.Any(i => i.IsActiveString == "true"),
|
||||
NationalIdOrNationalCode = x.contractingParty.IsLegal == "حقیقی" ? x.contractingParty.Nationalcode : x.contractingParty.NationalId,
|
||||
Status = x.contractingParty.IsActiveString == "true" ? ActivationStatus.Active : ActivationStatus.DeActive,
|
||||
NationalIdOrNationalCode = x.contractingParty.IsLegal == "حقیقی"
|
||||
? x.contractingParty.Nationalcode
|
||||
: x.contractingParty.NationalId,
|
||||
Status = x.contractingParty.IsActiveString == "true"
|
||||
? ActivationStatus.Active
|
||||
: ActivationStatus.DeActive,
|
||||
Address = x.contractingParty.Address,
|
||||
NationalId = x.contractingParty.NationalId,
|
||||
PhoneNumber = x.contractingParty.Phone,
|
||||
@@ -576,7 +596,7 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList(string search,long id)
|
||||
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList(string search, long id)
|
||||
{
|
||||
var query = _context.PersonalContractingParties.Select(x => new ContractingPartySelectListViewModel
|
||||
{
|
||||
@@ -586,13 +606,13 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
: x.FName + " " + x.LName + " " + x.SureName
|
||||
: x.SureName == null ? x.LName
|
||||
: x.LName + " " + x.SureName
|
||||
|
||||
});
|
||||
ContractingPartySelectListViewModel idSelected = null;
|
||||
if (id > 0)
|
||||
{
|
||||
idSelected = await query.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
query = query.Where(x => x.Text.Contains(search));
|
||||
@@ -607,10 +627,11 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
|
||||
public async Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId()
|
||||
{
|
||||
return await _context.PersonalContractingParties.Select(x => new GetContractingPartyNationalCodeOrNationalIdViewModel
|
||||
{
|
||||
NationalCodeOrNationalId = x.IsLegal == "true" ? x.NationalId : x.Nationalcode
|
||||
}).ToListAsync();
|
||||
return await _context.PersonalContractingParties.Select(x =>
|
||||
new GetContractingPartyNationalCodeOrNationalIdViewModel
|
||||
{
|
||||
NationalCodeOrNationalId = x.IsLegal == "true" ? x.NationalId : x.Nationalcode
|
||||
}).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<OperationResult<string>> DeactivateWithSubordinates(long id)
|
||||
@@ -747,8 +768,12 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
return await _context.PersonalContractingParties.FirstOrDefaultAsync(x => x.Nationalcode == nationalCode);
|
||||
}
|
||||
|
||||
public async Task<PersonalContractingParty> GetByRegisterId(string registerId)
|
||||
{
|
||||
return await _context.PersonalContractingParties.FirstOrDefaultAsync(x => x.RegisterId == registerId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
Reference in New Issue
Block a user