WorkingHoursTemp CleanUp Code
This commit is contained in:
@@ -4,11 +4,8 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.WorkingHoursAgg;
|
||||
using Company.Domain.WorkingHoursTempAgg;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
using CompanyManagment.App.Contracts.WorkingHours;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursItems;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@@ -21,24 +18,24 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
public WorkingHoursTempRepository(CompanyContext context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
|
||||
}
|
||||
|
||||
public WorkingHoursTempViewModel GetDetails(long id)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public CreateWorkingHoursTemp GetByWorkshopIdAndEmployeeId(long workshopId, long employeeId)
|
||||
{
|
||||
var workingHoursAndItems = _context.WorkingHoursTemps
|
||||
.Include(x => x.WorkingHoursTempItemList)
|
||||
.FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||
.Include(x => x.WorkingHoursTempItemList)
|
||||
.FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||
|
||||
|
||||
if (workingHoursAndItems == null)
|
||||
{
|
||||
var contract = _context.Contracts.Where(x => x.EmployeeId == employeeId && x.WorkshopIds == workshopId && x.IsActiveString == "true")
|
||||
var contract = _context.Contracts.Where(x =>
|
||||
x.EmployeeId == employeeId && x.WorkshopIds == workshopId && x.IsActiveString == "true")
|
||||
.OrderByDescending(x => x.ContarctStart)
|
||||
.FirstOrDefault();
|
||||
if (contract != null)
|
||||
@@ -173,7 +170,7 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
? items.FirstOrDefault(x => x.DayOfWork == "6")?.End2
|
||||
: null;
|
||||
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHours.id,
|
||||
ShiftWork = "4",
|
||||
@@ -519,9 +516,10 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
result.WorkshopAddress2 = contract.WorkshopAddress2;
|
||||
return result;
|
||||
}
|
||||
else if (workingHours.ShiftWork == "4")
|
||||
|
||||
if (workingHours.ShiftWork == "4")
|
||||
{
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHours.id,
|
||||
ShiftWork = workingHours.ShiftWork,
|
||||
@@ -1013,7 +1011,7 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
: null,
|
||||
TowShifts2Jome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4")
|
||||
? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "4")?.End2
|
||||
: null,
|
||||
: null
|
||||
};
|
||||
//تفکیک ساعت استراحت
|
||||
|
||||
@@ -1124,34 +1122,31 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
result.WorkshopAddress2 = contract.WorkshopAddress2;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHours.id,
|
||||
ShiftWork = workingHours.ShiftWork,
|
||||
StartComplex = items.FirstOrDefault()?.ComplexStart,
|
||||
EndComplex = items.FirstOrDefault()?.ComplexEnd,
|
||||
WeeklyWorkingTime = workingHours.WeeklyWorkingTime,
|
||||
WeeklyWorkingTime = workingHours.WeeklyWorkingTime
|
||||
};
|
||||
result.WorkshopAddress2 = contract.WorkshopAddress2;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CreateWorkingHoursTemp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return new CreateWorkingHoursTemp();
|
||||
}
|
||||
|
||||
return new CreateWorkingHoursTemp();
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
var items = workingHoursAndItems?.WorkingHoursTempItemList;
|
||||
if (workingHoursAndItems.ShiftWork == "1" || workingHoursAndItems.ShiftWork == "2")
|
||||
@@ -1277,7 +1272,7 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
? items.FirstOrDefault(x => x.DayOfWork == "6")?.End2
|
||||
: null;
|
||||
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHoursAndItems.id,
|
||||
ShiftWork = "4",
|
||||
@@ -1623,9 +1618,10 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
result.WorkshopAddress2 = workingHoursAndItems.WorkShopAddress2;
|
||||
return result;
|
||||
}
|
||||
else if (workingHoursAndItems.ShiftWork == "4")
|
||||
|
||||
if (workingHoursAndItems.ShiftWork == "4")
|
||||
{
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHoursAndItems.id,
|
||||
ShiftWork = "4",
|
||||
@@ -2117,7 +2113,7 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
: null,
|
||||
TowShifts2Jome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4")
|
||||
? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "4")?.End2
|
||||
: null,
|
||||
: null
|
||||
};
|
||||
//تفکیک ساعت استراحت
|
||||
|
||||
@@ -2228,36 +2224,35 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
result.WorkshopAddress2 = workingHoursAndItems.WorkShopAddress2;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHoursAndItems.id,
|
||||
ShiftWork = workingHoursAndItems.ShiftWork,
|
||||
StartComplex = items.FirstOrDefault()?.ComplexStart,
|
||||
EndComplex = items.FirstOrDefault()?.ComplexEnd,
|
||||
|
||||
EndComplex = items.FirstOrDefault()?.ComplexEnd
|
||||
};
|
||||
result.WorkshopAddress2 = workingHoursAndItems.WorkShopAddress2;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CreateWorkingHoursTemp GetByContractId(long contractId)
|
||||
{
|
||||
var workingHours = _context.WorkingHoursSet
|
||||
.Include(x => x.WorkingHoursItemsList)
|
||||
.FirstOrDefault(x => x.ContractId == contractId);
|
||||
.Include(x => x.WorkingHoursItemsList)
|
||||
.FirstOrDefault(x => x.ContractId == contractId);
|
||||
|
||||
if (workingHours != null)
|
||||
{
|
||||
var items = workingHours?.WorkingHoursItemsList;
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHours.id,
|
||||
ShiftWork = workingHours.ShiftWork,
|
||||
@@ -2887,7 +2882,7 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
: null,
|
||||
TowShifts2Jome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4")
|
||||
? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "4")?.End2
|
||||
: null,
|
||||
: null
|
||||
};
|
||||
|
||||
//تفکیک ساعات استراحت
|
||||
@@ -3032,16 +3027,14 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CreateWorkingHoursTemp();
|
||||
}
|
||||
|
||||
return new CreateWorkingHoursTemp();
|
||||
}
|
||||
|
||||
public CreateWorkingHoursTemp GetByContractIdConvertToShiftwork4(long contractId)
|
||||
{
|
||||
var workingHours = _context.WorkingHoursSet
|
||||
.Include(x => x.WorkingHoursItemsList)
|
||||
.Include(x => x.WorkingHoursItemsList)
|
||||
.FirstOrDefault(x => x.ContractId == contractId);
|
||||
|
||||
if (workingHours != null)
|
||||
@@ -3171,11 +3164,12 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
? items.FirstOrDefault(x => x.DayOfWork == "6")?.End2
|
||||
: null;
|
||||
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHours.id,
|
||||
ShiftWork = "4",
|
||||
ShiftWorkTemp = "1",
|
||||
|
||||
#region week1
|
||||
|
||||
//week1
|
||||
@@ -3516,9 +3510,10 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
|
||||
return result;
|
||||
}
|
||||
else if (workingHours.ShiftWork == "4")
|
||||
|
||||
if (workingHours.ShiftWork == "4")
|
||||
{
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHours.id,
|
||||
ShiftWork = workingHours.ShiftWork,
|
||||
@@ -4011,7 +4006,7 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
: null,
|
||||
TowShifts2Jome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4")
|
||||
? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "4")?.End2
|
||||
: null,
|
||||
: null
|
||||
};
|
||||
//تفکیک ساعت استراحت
|
||||
|
||||
@@ -4127,29 +4122,27 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHours.id,
|
||||
ShiftWork = workingHours.ShiftWork,
|
||||
ShiftWorkTemp = "5",
|
||||
StartComplex = items.FirstOrDefault()?.ComplexStart,
|
||||
EndComplex = items.FirstOrDefault()?.ComplexEnd,
|
||||
WeeklyWorkingTime = workingHours.WeeklyWorkingTime,
|
||||
WeeklyWorkingTime = workingHours.WeeklyWorkingTime
|
||||
};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CreateWorkingHoursTemp();
|
||||
}
|
||||
|
||||
return new CreateWorkingHoursTemp();
|
||||
}
|
||||
|
||||
public CreateWorkingHoursTemp GetByWorkshopIdAndEmployeeIdToShiftwork4(long workshopId, long employeeId)
|
||||
{
|
||||
var contract = _context.Contracts.Where(x => x.EmployeeId == employeeId && x.WorkshopIds == workshopId)
|
||||
.OrderByDescending(x => x.ContarctStart)
|
||||
.FirstOrDefault();
|
||||
.OrderByDescending(x => x.ContarctStart)
|
||||
.FirstOrDefault();
|
||||
if (contract != null)
|
||||
{
|
||||
var workingHours = _context.WorkingHoursSet
|
||||
@@ -4282,7 +4275,7 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
? items.FirstOrDefault(x => x.DayOfWork == "6")?.End2
|
||||
: null;
|
||||
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHours.id,
|
||||
ShiftWork = "4",
|
||||
@@ -4624,12 +4617,14 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
result.WorkshopAddress2 = contract.WorkshopAddress2;
|
||||
return result;
|
||||
}
|
||||
else if (workingHours.ShiftWork == "4")
|
||||
|
||||
if (workingHours.ShiftWork == "4")
|
||||
{
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHours.id,
|
||||
ShiftWork = workingHours.ShiftWork,
|
||||
@@ -5121,7 +5116,7 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
: null,
|
||||
TowShifts2Jome4 = items.Any(x => x.DayOfWork == "6" && x.WeekNumber == "4")
|
||||
? items.FirstOrDefault(x => x.DayOfWork == "6" && x.WeekNumber == "4")?.End2
|
||||
: null,
|
||||
: null
|
||||
};
|
||||
//تفکیک ساعت استراحت
|
||||
|
||||
@@ -5232,33 +5227,30 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
result.WorkshopAddress2 = contract.WorkshopAddress2;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = new CreateWorkingHoursTemp()
|
||||
var result = new CreateWorkingHoursTemp
|
||||
{
|
||||
WorknigHoursId = workingHours.id,
|
||||
ShiftWork = workingHours.ShiftWork,
|
||||
ShiftWorkTemp = "5",
|
||||
StartComplex = items.FirstOrDefault()?.ComplexStart,
|
||||
EndComplex = items.FirstOrDefault()?.ComplexEnd,
|
||||
WeeklyWorkingTime = workingHours.WeeklyWorkingTime,
|
||||
WeeklyWorkingTime = workingHours.WeeklyWorkingTime
|
||||
};
|
||||
result.WorkshopAddress2 = contract.WorkshopAddress2;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CreateWorkingHoursTemp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return new CreateWorkingHoursTemp();
|
||||
}
|
||||
|
||||
return new CreateWorkingHoursTemp();
|
||||
}
|
||||
|
||||
public async Task<List<EditContract>> Correct()
|
||||
@@ -5268,38 +5260,32 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
|
||||
#region correctContractsAndChekouts
|
||||
|
||||
|
||||
var contracts = _context.Contracts.Where(x => x.WorkingHoursWeekly != "44" &&
|
||||
x.WorkingHoursWeekly != "48 - 24"
|
||||
&& x.WorkingHoursWeekly != "36 - 12" &&
|
||||
x.WorkingHoursWeekly != "24 - 24" &&
|
||||
x.WorkingHoursWeekly != "24 - 12")
|
||||
.Where(x => x.CreationDate >= startTime && x.AgreementSalary == "0" && x.IsActiveString == "true").Select(x => new EditContract()
|
||||
{
|
||||
Id = x.id,
|
||||
EmployeeId = x.EmployeeId,
|
||||
WorkshopIds = x.WorkshopIds,
|
||||
DayliWage = x.DayliWage,
|
||||
ConsumableItems = x.ConsumableItems,
|
||||
FamilyAllowance = x.FamilyAllowance,
|
||||
HousingAllowance = x.HousingAllowance,
|
||||
AgreementSalary = x.AgreementSalary,
|
||||
WeeklyWorkingTime = x.WorkingHoursWeekly,
|
||||
ContractNo = x.ContractNo,
|
||||
ContarctStart = x.ContarctStart.ToFarsi(),
|
||||
ContractEnd = x.ContractEnd.ToFarsi(),
|
||||
GetWorkDate = x.GetWorkDate.ToFarsi(),
|
||||
GetWorkDateHide = x.GetWorkDate.ToFarsi()
|
||||
|
||||
|
||||
});
|
||||
.Where(x => x.CreationDate >= startTime && x.AgreementSalary == "0" && x.IsActiveString == "true").Select(
|
||||
x => new EditContract
|
||||
{
|
||||
Id = x.id,
|
||||
EmployeeId = x.EmployeeId,
|
||||
WorkshopIds = x.WorkshopIds,
|
||||
DayliWage = x.DayliWage,
|
||||
ConsumableItems = x.ConsumableItems,
|
||||
FamilyAllowance = x.FamilyAllowance,
|
||||
HousingAllowance = x.HousingAllowance,
|
||||
AgreementSalary = x.AgreementSalary,
|
||||
WeeklyWorkingTime = x.WorkingHoursWeekly,
|
||||
ContractNo = x.ContractNo,
|
||||
ContarctStart = x.ContarctStart.ToFarsi(),
|
||||
ContractEnd = x.ContractEnd.ToFarsi(),
|
||||
GetWorkDate = x.GetWorkDate.ToFarsi(),
|
||||
GetWorkDateHide = x.GetWorkDate.ToFarsi()
|
||||
});
|
||||
return contracts.OrderBy(x => x.Id).Take(100).ToList();
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public void RemoveWorkingHoursTempAndItems(long workshopId, long employeeId)
|
||||
@@ -5320,6 +5306,4 @@ public class WorkingHoursTempRepository : RepositoryBase<long, WorkingHoursTemp>
|
||||
_context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user