Files
Backend-Api/CompanyManagment.Application/WorkingHoursTempApplication.cs
2024-07-08 22:03:37 +03:30

877 lines
40 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Application;
using Company.Domain.WorkingHoursTempAgg;
using CompanyManagment.App.Contracts.Contract;
using CompanyManagment.App.Contracts.WorkingHoursTemp;
using CompanyManagment.App.Contracts.WorkingHoursTempItem;
namespace CompanyManagment.Application;
public class WorkingHoursTempApplication : IWorkingHoursTempApplication
{
private readonly IWorkingHoursTempRepository _workingHoursTempRepository;
private readonly IWorkingHoursTempItemApplication _hoursTempItemApplication;
public WorkingHoursTempApplication(IWorkingHoursTempRepository workingHoursTempRepository, IWorkingHoursTempItemApplication hoursTempItemApplication)
{
_workingHoursTempRepository = workingHoursTempRepository;
_hoursTempItemApplication = hoursTempItemApplication;
}
public OperationResult Create(CreateWorkingHoursTemp command)
{
var opration = new OperationResult();
_workingHoursTempRepository.RemoveWorkingHoursTempAndItems(command.WorkshopId, command.EmployeeId);
var createNew = new WorkingHoursTemp(command.ShiftWork, command.WorkshopId, command.EmployeeId, command.WorkshopAddress2);
_workingHoursTempRepository.Create(createNew);
_workingHoursTempRepository.SaveChanges();
#region RestTimeCurrcetion
switch (command.ShiftWork)
{
#region Case 1&2
case "1":
case "2":
command.RestTime = command.RestTime == "0" ? "00" : command.RestTime;
command.RestTimeYekshanbeh = command.RestTimeYekshanbeh == "0" ? "00" : command.RestTimeYekshanbeh;
command.RestTimeDoshanbeh = command.RestTimeDoshanbeh == "0" ? "00" : command.RestTimeDoshanbeh;
command.RestTimeSeshanbeh = command.RestTimeSeshanbeh == "0" ? "00" : command.RestTimeSeshanbeh;
command.RestTimeCheharshanbeh = command.RestTimeCheharshanbeh == "0" ? "00" : command.RestTimeCheharshanbeh;
command.RestTimePanjshanbeh = command.RestTimePanjshanbeh == "0" ? "00" : command.RestTimePanjshanbeh;
command.RestTimeJomeh = command.RestTimeJomeh == "0" ? "00" : command.RestTimeJomeh;
command.RestTimeMin = command.RestTimeMin == "0" ? "00" : command.RestTimeMin;
command.RestTimeYekshanbehMin = command.RestTimeYekshanbehMin == "0" ? "00" : command.RestTimeYekshanbehMin;
command.RestTimeDoshanbehMin = command.RestTimeDoshanbehMin == "0" ? "00" : command.RestTimeDoshanbehMin;
command.RestTimeSeshanbehMin = command.RestTimeSeshanbehMin == "0" ? "00" : command.RestTimeSeshanbehMin;
command.RestTimeCheharshanbehMin = command.RestTimeCheharshanbehMin == "0" ? "00" : command.RestTimeCheharshanbehMin;
command.RestTimePanjshanbehMin = command.RestTimePanjshanbehMin == "0" ? "00" : command.RestTimePanjshanbehMin;
command.RestTimeJomehMin = command.RestTimeJomehMin == "0" ? "00" : command.RestTimeJomehMin;
//rest0 = TimeSpan.Parse($"{command.RestTime}:{command.RestTimeMin}");
//rest1 = TimeSpan.Parse($"{command.RestTimeYekshanbeh}:{command.RestTimeYekshanbehMin}");
//rest2 = TimeSpan.Parse($"{command.RestTimeDoshanbeh}:{command.RestTimeDoshanbehMin}");
//rest3 = TimeSpan.Parse($"{command.RestTimeSeshanbeh}:{ command.RestTimeSeshanbehMin}");
//rest4 = TimeSpan.Parse($"{command.RestTimeCheharshanbeh}:{command.RestTimeCheharshanbehMin}");
//rest5 = TimeSpan.Parse($"{command.RestTimePanjshanbeh}:{command.RestTimePanjshanbehMin}");
//rest6 = TimeSpan.Parse($"{command.RestTimeJomeh}:{command.RestTimeJomehMin}");
break;
#endregion
#region Case 4
case "4":
//week1
command.RestTimeShanbe1 = command.RestTimeShanbe1 == "0" ? "00" : command.RestTimeShanbe1;
command.RestTimeShanbe1Min = command.RestTimeShanbe1Min == "0" ? "00" : command.RestTimeShanbe1Min;
command.RestTimeYekShanbe1 = command.RestTimeYekShanbe1 == "0" ? "00" : command.RestTimeYekShanbe1;
command.RestTimeYekShanbe1Min = command.RestTimeYekShanbe1Min == "0" ? "00" : command.RestTimeYekShanbe1Min;
command.RestTimeDoShanbe1 = command.RestTimeDoShanbe1 == "0" ? "00" : command.RestTimeDoShanbe1;
command.RestTimeDoShanbe1Min = command.RestTimeDoShanbe1Min == "0" ? "00" : command.RestTimeDoShanbe1Min;
command.RestTimeSeShanbe1 = command.RestTimeSeShanbe1 == "0" ? "00" : command.RestTimeSeShanbe1;
command.RestTimeSeShanbe1Min = command.RestTimeSeShanbe1Min == "0" ? "00" : command.RestTimeSeShanbe1Min;
command.RestTimeCheharShanbe1 = command.RestTimeCheharShanbe1 == "0" ? "00" : command.RestTimeCheharShanbe1;
command.RestTimeCheharShanbe1Min = command.RestTimeCheharShanbe1Min == "0" ? "00" : command.RestTimeCheharShanbe1Min;
command.RestTimePanjShanbe1 = command.RestTimePanjShanbe1 == "0" ? "00" : command.RestTimePanjShanbe1;
command.RestTimePanjShanbe1Min = command.RestTimePanjShanbe1Min == "0" ? "00" : command.RestTimePanjShanbe1Min;
command.RestTimeJome1 = command.RestTimeJome1 == "0" ? "00" : command.RestTimeJome1;
command.RestTimeJome1Min = command.RestTimeJome1Min == "0" ? "00" : command.RestTimeJome1Min;
//week2
command.RestTimeShanbe2 = command.RestTimeShanbe2 == "0" ? "00" : command.RestTimeShanbe2;
command.RestTimeShanbe2Min = command.RestTimeShanbe2Min == "0" ? "00" : command.RestTimeShanbe2Min;
command.RestTimeYekShanbe2 = command.RestTimeYekShanbe2 == "0" ? "00" : command.RestTimeYekShanbe2;
command.RestTimeYekShanbe2Min = command.RestTimeYekShanbe2Min == "0" ? "00" : command.RestTimeYekShanbe2Min;
command.RestTimeDoShanbe2 = command.RestTimeDoShanbe2 == "0" ? "00" : command.RestTimeDoShanbe2;
command.RestTimeDoShanbe2Min = command.RestTimeDoShanbe2Min == "0" ? "00" : command.RestTimeDoShanbe2Min;
command.RestTimeSeShanbe2 = command.RestTimeSeShanbe2 == "0" ? "00" : command.RestTimeSeShanbe2;
command.RestTimeSeShanbe2Min = command.RestTimeSeShanbe2Min == "0" ? "00" : command.RestTimeSeShanbe2Min;
command.RestTimeCheharShanbe2 = command.RestTimeCheharShanbe2 == "0" ? "00" : command.RestTimeCheharShanbe2;
command.RestTimeCheharShanbe2Min = command.RestTimeCheharShanbe2Min == "0" ? "00" : command.RestTimeCheharShanbe2Min;
command.RestTimePanjShanbe2 = command.RestTimePanjShanbe2 == "0" ? "00" : command.RestTimePanjShanbe2;
command.RestTimePanjShanbe2Min = command.RestTimePanjShanbe2Min == "0" ? "00" : command.RestTimePanjShanbe2Min;
command.RestTimeJome2 = command.RestTimeJome2 == "0" ? "00" : command.RestTimeJome2;
command.RestTimeJome2Min = command.RestTimeJome2Min == "0" ? "00" : command.RestTimeJome2Min;
//week3
command.RestTimeShanbe3 = command.RestTimeShanbe3 == "0" ? "00" : command.RestTimeShanbe3;
command.RestTimeShanbe3Min = command.RestTimeShanbe3Min == "0" ? "00" : command.RestTimeShanbe3Min;
command.RestTimeYekShanbe3 = command.RestTimeYekShanbe3 == "0" ? "00" : command.RestTimeYekShanbe3;
command.RestTimeYekShanbe3Min = command.RestTimeYekShanbe3Min == "0" ? "00" : command.RestTimeYekShanbe3Min;
command.RestTimeDoShanbe3 = command.RestTimeDoShanbe3 == "0" ? "00" : command.RestTimeDoShanbe3;
command.RestTimeDoShanbe3Min = command.RestTimeDoShanbe3Min == "0" ? "00" : command.RestTimeDoShanbe3Min;
command.RestTimeSeShanbe3 = command.RestTimeSeShanbe3 == "0" ? "00" : command.RestTimeSeShanbe3;
command.RestTimeSeShanbe3Min = command.RestTimeSeShanbe3Min == "0" ? "00" : command.RestTimeSeShanbe3Min;
command.RestTimeCheharShanbe3 = command.RestTimeCheharShanbe3 == "0" ? "00" : command.RestTimeCheharShanbe3;
command.RestTimeCheharShanbe3Min = command.RestTimeCheharShanbe3Min == "0" ? "00" : command.RestTimeCheharShanbe3Min;
command.RestTimePanjShanbe3 = command.RestTimePanjShanbe3 == "0" ? "00" : command.RestTimePanjShanbe3;
command.RestTimePanjShanbe3Min = command.RestTimePanjShanbe3Min == "0" ? "00" : command.RestTimePanjShanbe3Min;
command.RestTimeJome3 = command.RestTimeJome3 == "0" ? "00" : command.RestTimeJome3;
command.RestTimeJome3Min = command.RestTimeJome3Min == "0" ? "00" : command.RestTimeJome3Min;
//week4
command.RestTimeShanbe4 = command.RestTimeShanbe4 == "0" ? "00" : command.RestTimeShanbe4;
command.RestTimeShanbe4Min = command.RestTimeShanbe4Min == "0" ? "00" : command.RestTimeShanbe4Min;
command.RestTimeYekShanbe4 = command.RestTimeYekShanbe4 == "0" ? "00" : command.RestTimeYekShanbe4;
command.RestTimeYekShanbe4Min = command.RestTimeYekShanbe4Min == "0" ? "00" : command.RestTimeYekShanbe4Min;
command.RestTimeDoShanbe4 = command.RestTimeDoShanbe4 == "0" ? "00" : command.RestTimeDoShanbe4;
command.RestTimeDoShanbe4Min = command.RestTimeDoShanbe4Min == "0" ? "00" : command.RestTimeDoShanbe4Min;
command.RestTimeSeShanbe4 = command.RestTimeSeShanbe4 == "0" ? "00" : command.RestTimeSeShanbe4;
command.RestTimeSeShanbe4Min = command.RestTimeSeShanbe4Min == "0" ? "00" : command.RestTimeSeShanbe4Min;
command.RestTimeCheharShanbe4 = command.RestTimeCheharShanbe4 == "0" ? "00" : command.RestTimeCheharShanbe4;
command.RestTimeCheharShanbe4Min = command.RestTimeCheharShanbe4Min == "0" ? "00" : command.RestTimeCheharShanbe4Min;
command.RestTimePanjShanbe4 = command.RestTimePanjShanbe4 == "0" ? "00" : command.RestTimePanjShanbe4;
command.RestTimePanjShanbe4Min = command.RestTimePanjShanbe4Min == "0" ? "00" : command.RestTimePanjShanbe4Min;
command.RestTimeJome4 = command.RestTimeJome4 == "0" ? "00" : command.RestTimeJome4;
command.RestTimeJome4Min = command.RestTimeJome4Min == "0" ? "00" : command.RestTimeJome4Min;
// sumrest week1
//rest0w1 = $"{command.RestTimeShanbe1}:{command.RestTimeShanbe1Min}";
//rest1w1 = $"{command.RestTimeYekShanbe1}:{command.RestTimeYekShanbe1Min}";
//rest2w1 = $"{command.RestTimeDoShanbe1}:{command.RestTimeDoShanbe1Min}";
//rest3w1 = $"{command.RestTimeSeShanbe1}:{ command.RestTimeSeShanbe1Min}";
//rest4w1 = $"{command.RestTimeCheharShanbe1}:{command.RestTimeCheharShanbe1Min}";
//rest5w1 = $"{command.RestTimePanjShanbe1}:{command.RestTimePanjShanbe1Min}";
//rest6w1 = $"{command.RestTimeJome1}:{command.RestTimeJome1Min}";
// sumrest week2
//rest0w2 = $"{command.RestTimeShanbe2}:{command.RestTimeShanbe2Min}";
//rest1w2 = $"{command.RestTimeYekShanbe2}:{command.RestTimeYekShanbe2Min}";
//rest2w2 = $"{command.RestTimeDoShanbe2}:{command.RestTimeDoShanbe2Min}";
//rest3w2 = $"{command.RestTimeSeShanbe2}:{ command.RestTimeSeShanbe2Min}";
//rest4w2 = $"{command.RestTimeCheharShanbe2}:{command.RestTimeCheharShanbe2Min}";
//rest5w2 = $"{command.RestTimePanjShanbe2}:{command.RestTimePanjShanbe2Min}";
//rest6w2 = $"{command.RestTimeJome2}:{command.RestTimeJome2Min}";
// sumrest week3
//rest0w3 = $"{command.RestTimeShanbe3}:{command.RestTimeShanbe3Min}";
//rest1w3 = $"{command.RestTimeYekShanbe3}:{command.RestTimeYekShanbe3Min}";
//rest2w3 = $"{command.RestTimeDoShanbe3}:{command.RestTimeDoShanbe3Min}";
//rest3w3 = $"{command.RestTimeSeShanbe3}:{ command.RestTimeSeShanbe3Min}";
//rest4w3 = $"{command.RestTimeCheharShanbe3}:{command.RestTimeCheharShanbe3Min}";
//rest5w3 = $"{command.RestTimePanjShanbe3}:{command.RestTimePanjShanbe3Min}";
//rest6w3 = $"{command.RestTimeJome3}:{command.RestTimeJome3Min}";
// sumrest week4
//rest0w4 = $"{command.RestTimeShanbe4}:{command.RestTimeShanbe4Min}";
//rest1w4 = $"{command.RestTimeYekShanbe4}:{command.RestTimeYekShanbe4Min}";
//rest2w4 = $"{command.RestTimeDoShanbe4}:{command.RestTimeDoShanbe4Min}";
//rest3w4 = $"{command.RestTimeSeShanbe4}:{ command.RestTimeSeShanbe4Min}";
//rest4w4 = $"{command.RestTimeCheharShanbe4}:{command.RestTimeCheharShanbe4Min}";
//rest5w4 = $"{command.RestTimePanjShanbe4}:{command.RestTimePanjShanbe4Min}";
//rest6w4 = $"{command.RestTimeJome4}:{command.RestTimeJome4Min}";
break;
#endregion
}
#endregion
if (command.ShiftWork == "1" || command.ShiftWork == "2")
{
if (command.shanbeh == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "0",
DayOfWork = "0",
Start1 = command.SingleShift1,
End1 = command.SingleShift2,
RestTime = $"{command.RestTime}:{command.RestTimeMin}",
Start2 = command.TowShifts1,
End2 = command.TowShifts2,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.yekshanbeh == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "0",
DayOfWork = "1",
Start1 = command.SingleShift1Yekshanbeh,
End1 = command.SingleShift2Yekshanbeh,
RestTime = $"{command.RestTimeYekshanbeh}:{command.RestTimeYekshanbehMin}",
Start2 = command.TowShifts1Yekshanbeh,
End2 = command.TowShifts2Yekshanbeh,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.doshanbeh == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "0",
DayOfWork = "2",
Start1 = command.SingleShift1Doshanbeh,
End1 = command.SingleShift2Doshanbeh,
RestTime = $"{command.RestTimeDoshanbeh}:{command.RestTimeDoshanbehMin}",
Start2 = command.TowShifts1Doshanbeh,
End2 = command.TowShifts2Doshanbeh,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.seshanbeh == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "0",
DayOfWork = "3",
Start1 = command.SingleShift1Seshanbeh,
End1 = command.SingleShift2Seshanbeh,
RestTime = $"{command.RestTimeSeshanbeh}:{ command.RestTimeSeshanbehMin}",
Start2 = command.TowShifts1Seshanbeh,
End2 = command.TowShifts2Seshanbeh,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.cheharshanbeh == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "0",
DayOfWork = "4",
Start1 = command.SingleShift1Cheharshanbeh,
End1 = command.SingleShift2Cheharshanbeh,
RestTime = $"{command.RestTimeSeshanbeh}:{ command.RestTimeSeshanbehMin}",
Start2 = command.TowShifts1Cheharshanbeh,
End2 = command.TowShifts2Cheharshanbeh,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.pangshanbeh == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "0",
DayOfWork = "5",
Start1 = command.SingleShift1Panjshanbeh,
End1 = command.SingleShift2Panjshanbeh,
RestTime = $"{command.RestTimePanjshanbeh}:{command.RestTimePanjshanbehMin}",
Start2 = command.TowShifts1Panjshanbeh,
End2 = command.TowShifts2Panjshanbeh,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.jomeh == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "0",
DayOfWork = "6",
Start1 = command.SingleShift1Jomeh,
End1 = command.SingleShift2Jomeh,
RestTime = $"{command.RestTimeJomeh}:{command.RestTimeJomehMin}",
Start2 = command.TowShifts1Jomeh,
End2 = command.TowShifts2Jomeh,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
}
else if (command.ShiftWork == "4")//weekly
{
//week1
#region week1
if (command.Shanbe1 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "1",
DayOfWork = "0",
Start1 = command.SingleShift1Shanbe1,
End1 = command.SingleShift2Shanbe1,
RestTime = $"{command.RestTimeShanbe1}:{command.RestTimeShanbe1Min}",
Start2 = command.TowShifts1Shanbe1,
End2 = command.TowShifts2Shanbe1,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.YekShanbe1 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "1",
DayOfWork = "1",
Start1 = command.SingleShift1YekShanbe1,
End1 = command.SingleShift2YekShanbe1,
RestTime = $"{command.RestTimeYekShanbe1}:{command.RestTimeYekShanbe1Min}",
Start2 = command.TowShifts1YekShanbe1,
End2 = command.TowShifts2YekShanbe1,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.DoShanbe1 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "1",
DayOfWork = "2",
Start1 = command.SingleShift1DoShanbe1,
End1 = command.SingleShift2DoShanbe1,
RestTime = $"{command.RestTimeDoShanbe1}:{command.RestTimeDoShanbe1Min}",
Start2 = command.TowShifts1DoShanbe1,
End2 = command.TowShifts2DoShanbe1,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.SeShanbe1 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "1",
DayOfWork = "3",
Start1 = command.SingleShift1SeShanbe1,
End1 = command.SingleShift2SeShanbe1,
RestTime = $"{command.RestTimeSeShanbe1}:{ command.RestTimeSeShanbe1Min}",
Start2 = command.TowShifts1SeShanbe1,
End2 = command.TowShifts2SeShanbe1,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.CheharShanbe1 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "1",
DayOfWork = "4",
Start1 = command.SingleShift1CheharShanbe1,
End1 = command.SingleShift2CheharShanbe1,
RestTime = $"{command.RestTimeCheharShanbe1}:{command.RestTimeCheharShanbe1Min}",
Start2 = command.TowShifts1CheharShanbe1,
End2 = command.TowShifts2CheharShanbe1,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.PanjShanbe1 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "1",
DayOfWork = "5",
Start1 = command.SingleShift1PanjShanbe1,
End1 = command.SingleShift2PanjShanbe1,
RestTime = $"{command.RestTimePanjShanbe1}:{command.RestTimePanjShanbe1Min}",
Start2 = command.TowShifts1PanjShanbe1,
End2 = command.TowShifts2PanjShanbe1,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.Jome1 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "1",
DayOfWork = "6",
Start1 = command.SingleShift1Jome1,
End1 = command.SingleShift2Jome1,
RestTime = $"{command.RestTimeJome1}:{command.RestTimeJome1Min}",
Start2 = command.TowShifts1Jome1,
End2 = command.TowShifts2Jome1,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
#endregion
//week2
#region Week2
if (command.Shanbe2 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "2",
DayOfWork = "0",
Start1 = command.SingleShift1Shanbe2,
End1 = command.SingleShift2Shanbe2,
RestTime = $"{command.RestTimeShanbe2}:{command.RestTimeShanbe2Min}",
Start2 = command.TowShifts1Shanbe2,
End2 = command.TowShifts2Shanbe2,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.YekShanbe2 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "2",
DayOfWork = "1",
Start1 = command.SingleShift1YekShanbe2,
End1 = command.SingleShift2YekShanbe2,
RestTime = $"{command.RestTimeYekShanbe2}:{command.RestTimeYekShanbe2Min}",
Start2 = command.TowShifts1YekShanbe2,
End2 = command.TowShifts2YekShanbe2,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.DoShanbe2 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "2",
DayOfWork = "2",
Start1 = command.SingleShift1DoShanbe2,
End1 = command.SingleShift2DoShanbe2,
RestTime = $"{command.RestTimeDoShanbe2}:{command.RestTimeDoShanbe2Min}",
Start2 = command.TowShifts1DoShanbe2,
End2 = command.TowShifts2DoShanbe2,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.SeShanbe2 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "2",
DayOfWork = "3",
Start1 = command.SingleShift1SeShanbe2,
End1 = command.SingleShift2SeShanbe2,
RestTime = $"{command.RestTimeSeShanbe2}:{ command.RestTimeSeShanbe2Min}",
Start2 = command.TowShifts1SeShanbe2,
End2 = command.TowShifts2SeShanbe2,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.CheharShanbe2 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "2",
DayOfWork = "4",
Start1 = command.SingleShift1CheharShanbe2,
End1 = command.SingleShift2CheharShanbe2,
RestTime = $"{command.RestTimeCheharShanbe2}:{command.RestTimeCheharShanbe2Min}",
Start2 = command.TowShifts1CheharShanbe2,
End2 = command.TowShifts2CheharShanbe2,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.PanjShanbe2 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "2",
DayOfWork = "5",
Start1 = command.SingleShift1PanjShanbe2,
End1 = command.SingleShift2PanjShanbe2,
RestTime = $"{command.RestTimePanjShanbe2}:{command.RestTimePanjShanbe2Min}",
Start2 = command.TowShifts1PanjShanbe2,
End2 = command.TowShifts2PanjShanbe2,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.Jome2 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "2",
DayOfWork = "6",
Start1 = command.SingleShift1Jome2,
End1 = command.SingleShift2Jome2,
RestTime = $"{command.RestTimeJome2}:{command.RestTimeJome2Min}",
Start2 = command.TowShifts1Jome2,
End2 = command.TowShifts2Jome2,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
#endregion
//week3
#region Week3
if (command.Shanbe3 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "3",
DayOfWork = "0",
Start1 = command.SingleShift1Shanbe3,
End1 = command.SingleShift2Shanbe3,
RestTime = $"{command.RestTimeShanbe3}:{command.RestTimeShanbe3Min}",
Start2 = command.TowShifts1Shanbe3,
End2 = command.TowShifts2Shanbe3,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.YekShanbe3 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "3",
DayOfWork = "1",
Start1 = command.SingleShift1YekShanbe3,
End1 = command.SingleShift2YekShanbe3,
RestTime = $"{command.RestTimeYekShanbe3}:{command.RestTimeYekShanbe3Min}",
Start2 = command.TowShifts1YekShanbe3,
End2 = command.TowShifts2YekShanbe3,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.DoShanbe3 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "3",
DayOfWork = "2",
Start1 = command.SingleShift1DoShanbe3,
End1 = command.SingleShift2DoShanbe3,
RestTime = $"{command.RestTimeDoShanbe3}:{command.RestTimeDoShanbe3Min}",
Start2 = command.TowShifts1DoShanbe3,
End2 = command.TowShifts2DoShanbe3,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.SeShanbe3 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "3",
DayOfWork = "3",
Start1 = command.SingleShift1SeShanbe3,
End1 = command.SingleShift2SeShanbe3,
RestTime = $"{command.RestTimeSeShanbe3}:{ command.RestTimeSeShanbe3Min}",
Start2 = command.TowShifts1SeShanbe3,
End2 = command.TowShifts2SeShanbe3,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.CheharShanbe3 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "3",
DayOfWork = "4",
Start1 = command.SingleShift1CheharShanbe3,
End1 = command.SingleShift2CheharShanbe3,
RestTime = $"{command.RestTimeCheharShanbe3}:{command.RestTimeCheharShanbe3Min}",
Start2 = command.TowShifts1CheharShanbe3,
End2 = command.TowShifts2CheharShanbe3,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.PanjShanbe3 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "3",
DayOfWork = "5",
Start1 = command.SingleShift1PanjShanbe3,
End1 = command.SingleShift2PanjShanbe3,
RestTime = $"{command.RestTimePanjShanbe3}:{command.RestTimePanjShanbe3Min}",
Start2 = command.TowShifts1PanjShanbe3,
End2 = command.TowShifts2PanjShanbe3,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.Jome3 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "3",
DayOfWork = "6",
Start1 = command.SingleShift1Jome3,
End1 = command.SingleShift2Jome3,
RestTime = $"{command.RestTimeJome3}:{command.RestTimeJome3Min}",
Start2 = command.TowShifts1Jome3,
End2 = command.TowShifts2Jome3,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
#endregion
//week4
#region Week4
if (command.Shanbe4 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "4",
DayOfWork = "0",
Start1 = command.SingleShift1Shanbe4,
End1 = command.SingleShift2Shanbe4,
RestTime = $"{command.RestTimeShanbe4}:{command.RestTimeShanbe4Min}",
Start2 = command.TowShifts1Shanbe4,
End2 = command.TowShifts2Shanbe4,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.YekShanbe4 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "4",
DayOfWork = "1",
Start1 = command.SingleShift1YekShanbe4,
End1 = command.SingleShift2YekShanbe4,
RestTime = $"{command.RestTimeYekShanbe4}:{command.RestTimeYekShanbe4Min}",
Start2 = command.TowShifts1YekShanbe4,
End2 = command.TowShifts2YekShanbe4,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.DoShanbe4 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "4",
DayOfWork = "2",
Start1 = command.SingleShift1DoShanbe4,
End1 = command.SingleShift2DoShanbe4,
RestTime = $"{command.RestTimeDoShanbe4}:{command.RestTimeDoShanbe4Min}",
Start2 = command.TowShifts1DoShanbe4,
End2 = command.TowShifts2DoShanbe4,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.SeShanbe4 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "4",
DayOfWork = "3",
Start1 = command.SingleShift1SeShanbe4,
End1 = command.SingleShift2SeShanbe4,
RestTime = $"{command.RestTimeSeShanbe4}:{ command.RestTimeSeShanbe4Min}",
Start2 = command.TowShifts1SeShanbe4,
End2 = command.TowShifts2SeShanbe4,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.CheharShanbe4 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "4",
DayOfWork = "4",
Start1 = command.SingleShift1CheharShanbe4,
End1 = command.SingleShift2CheharShanbe4,
RestTime = $"{command.RestTimeCheharShanbe4}:{command.RestTimeCheharShanbe4Min}",
Start2 = command.TowShifts1CheharShanbe4,
End2 = command.TowShifts2CheharShanbe4,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.PanjShanbe4 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "4",
DayOfWork = "5",
Start1 = command.SingleShift1PanjShanbe4,
End1 = command.SingleShift2PanjShanbe4,
RestTime = $"{command.RestTimePanjShanbe4}:{command.RestTimePanjShanbe4Min}",
Start2 = command.TowShifts1PanjShanbe4,
End2 = command.TowShifts2PanjShanbe4,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
if (command.Jome4 == true)
{
var create = new CreateWorkingHoursTempItem()
{
WeekNumber = "4",
DayOfWork = "6",
Start1 = command.SingleShift1Jome4,
End1 = command.SingleShift2Jome4,
RestTime = $"{command.RestTimeJome4}:{command.RestTimeJome4Min}",
Start2 = command.TowShifts1Jome4,
End2 = command.TowShifts2Jome4,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
#endregion
}
else if (command.ShiftWork == "5")
{
var create = new CreateWorkingHoursTempItem()
{
DayOfWork = "7",
ComplexStart = command.Start1224,
ComplexEnd = command.End1224,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
else if (command.ShiftWork == "6")
{
var create = new CreateWorkingHoursTempItem()
{
DayOfWork = "7",
ComplexStart = command.Start2424,
ComplexEnd = command.End2424,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
else if (command.ShiftWork == "7")
{
var create = new CreateWorkingHoursTempItem()
{
DayOfWork = "7",
ComplexStart = command.Start1236,
ComplexEnd = command.End1236,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
else if (command.ShiftWork == "8")
{
var create = new CreateWorkingHoursTempItem()
{
DayOfWork = "7",
ComplexStart = command.Start2448,
ComplexEnd = command.End2448,
WorkingHoursTempId = createNew.id
};
_hoursTempItemApplication.Create(create);
}
return opration.Succcedded();
}
public WorkingHoursTempViewModel GetDetails(long id)
{
return _workingHoursTempRepository.GetDetails(id);
}
public CreateWorkingHoursTemp GetByWorkshopIdAndEmployeeId(long workshopId, long employeeId)
{
return _workingHoursTempRepository.GetByWorkshopIdAndEmployeeId(workshopId, employeeId);
}
public CreateWorkingHoursTemp GetByContractId(long contractId)
{
return _workingHoursTempRepository.GetByContractId(contractId);
}
public async Task<CreateWorkingHoursTemp> GetByContractIdAsync(long contractId)
{
var res = GetByContractId(contractId);
return res;
}
public CreateWorkingHoursTemp GetByContractIdConvertToShiftwork4(long contractId)
{
return _workingHoursTempRepository.GetByContractIdConvertToShiftwork4(contractId);
}
public CreateWorkingHoursTemp GetByWorkshopIdAndEmployeeIdToShiftwork4(long workshopId, long employeeId)
{
return _workingHoursTempRepository.GetByWorkshopIdAndEmployeeIdToShiftwork4(workshopId, employeeId);
}
public async Task<List<EditContract>> Correct()
{
return await _workingHoursTempRepository.Correct();
}
public async Task<CreateWorkingHoursTemp> GetByWorkshopIdAndEmployeeIdAsync(long workshopId, long employeeId)
{
var res = GetByWorkshopIdAndEmployeeId(workshopId, employeeId);
return res;
}
public void RemoveWorkingHoursTempAndItems(long workshopId, long employeeId)
{
_workingHoursTempRepository.RemoveWorkingHoursTempAndItems(workshopId, employeeId);
}
public ComputingViewModel GetWorkingHourSByRollCall(long workshopId, long employeeId, DateTime start, DateTime end)
{
throw new NotImplementedException();
}
}