using System.Collections.Generic; using System.Threading.Tasks; using _0_Framework.Application; using Company.Domain.WorkingHoursAgg; using Company.Domain.WorkingHoursItemsAgg; using CompanyManagment.App.Contracts.WorkingHours; using CompanyManagment.App.Contracts.WorkingHoursItems; using CompanyManagment.App.Contracts.WorkingHoursTemp; namespace CompanyManagment.Application; public class WorkingHoursApplication : IWorkingHoursApplication { private readonly IWorkingHoursRepository _workingHoursRepository; private readonly IWorkingHoursItemsApplication _workingHoursItemsApplication; public WorkingHoursApplication(IWorkingHoursRepository workingHoursRepository, IWorkingHoursItemsRepository workingHoursItemsRepository, IWorkingHoursItemsApplication workingHoursItemsApplication) { _workingHoursRepository = workingHoursRepository; _workingHoursItemsApplication = workingHoursItemsApplication; } public OperationResult Create(CreateWorkingHours command) { var op = new OperationResult(); var create = new WorkingHours(command.ShiftWork, command.ContractNo, command.NumberOfWorkingDays, command.NumberOfFriday, command.TotalHoursesH, command.TotalHoursesM, command.OverTimeWorkH, command.OverTimeWorkM, command.OverNightWorkH, command.OverNightWorkM, command.WeeklyWorkingTime, command.ContractId); _workingHoursRepository.Create(create); _workingHoursRepository.SaveChanges(); return op.Succcedded(create.id,message:$"{create.id}"); } public OperationResult CreateNew(CreateWorkingHoursTemp command) { var op = new OperationResult(); var createNew = new WorkingHours(command.ShiftWork, command.ContractNo, command.NumberOfWorkingDays, command.NumberOfFriday, command.TotalHoursesH, command.TotalHoursesM, command.OverTimeWorkH, command.OverTimeWorkM, command.OverNightWorkH, command.OverNightWorkM, command.WeeklyWorkingTime, command.ContractId); _workingHoursRepository.Create(createNew); _workingHoursRepository.SaveChanges(); #region RestTimeCorrcetion 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; 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; break; #endregion } #endregion if (command.ShiftWork == "1" || command.ShiftWork == "2") { if (command.shanbeh == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "0", Start1 = command.SingleShift1, End1 = command.SingleShift2, RestTime = $"{command.RestTime}", Start2 = command.TowShifts1, End2 = command.TowShifts2, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.yekshanbeh == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "1", Start1 = command.SingleShift1Yekshanbeh, End1 = command.SingleShift2Yekshanbeh, RestTime = $"{command.RestTimeYekshanbeh}", Start2 = command.TowShifts1Yekshanbeh, End2 = command.TowShifts2Yekshanbeh, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.doshanbeh == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "2", Start1 = command.SingleShift1Doshanbeh, End1 = command.SingleShift2Doshanbeh, RestTime = $"{command.RestTimeDoshanbeh}", Start2 = command.TowShifts1Doshanbeh, End2 = command.TowShifts2Doshanbeh, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.seshanbeh == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "3", Start1 = command.SingleShift1Seshanbeh, End1 = command.SingleShift2Seshanbeh, RestTime = $"{command.RestTimeSeshanbeh}", Start2 = command.TowShifts1Seshanbeh, End2 = command.TowShifts2Seshanbeh, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.cheharshanbeh == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "4", Start1 = command.SingleShift1Cheharshanbeh, End1 = command.SingleShift2Cheharshanbeh, RestTime = $"{command.RestTimeSeshanbeh}", Start2 = command.TowShifts1Cheharshanbeh, End2 = command.TowShifts2Cheharshanbeh, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.pangshanbeh == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "5", Start1 = command.SingleShift1Panjshanbeh, End1 = command.SingleShift2Panjshanbeh, RestTime = $"{command.RestTimePanjshanbeh}", Start2 = command.TowShifts1Panjshanbeh, End2 = command.TowShifts2Panjshanbeh, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.jomeh == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "6", Start1 = command.SingleShift1Jomeh, End1 = command.SingleShift2Jomeh, RestTime = $"{command.RestTimeJomeh}", Start2 = command.TowShifts1Jomeh, End2 = command.TowShifts2Jomeh, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } } else if (command.ShiftWork == "4")//weekly { //week1 #region week1 if (command.Shanbe1 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "1", DayOfWork = "0", Start1 = command.SingleShift1Shanbe1, End1 = command.SingleShift2Shanbe1, RestTime = $"{command.RestTimeShanbe1}:{command.RestTimeShanbe1Min}", Start2 = command.TowShifts1Shanbe1, End2 = command.TowShifts2Shanbe1, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.YekShanbe1 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "1", DayOfWork = "1", Start1 = command.SingleShift1YekShanbe1, End1 = command.SingleShift2YekShanbe1, RestTime = $"{command.RestTimeYekShanbe1}:{command.RestTimeYekShanbe1Min}", Start2 = command.TowShifts1YekShanbe1, End2 = command.TowShifts2YekShanbe1, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.DoShanbe1 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "1", DayOfWork = "2", Start1 = command.SingleShift1DoShanbe1, End1 = command.SingleShift2DoShanbe1, RestTime = $"{command.RestTimeDoShanbe1}:{command.RestTimeDoShanbe1Min}", Start2 = command.TowShifts1DoShanbe1, End2 = command.TowShifts2DoShanbe1, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.SeShanbe1 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "1", DayOfWork = "3", Start1 = command.SingleShift1SeShanbe1, End1 = command.SingleShift2SeShanbe1, RestTime = $"{command.RestTimeSeShanbe1}:{ command.RestTimeSeShanbe1Min}", Start2 = command.TowShifts1SeShanbe1, End2 = command.TowShifts2SeShanbe1, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.CheharShanbe1 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "1", DayOfWork = "4", Start1 = command.SingleShift1CheharShanbe1, End1 = command.SingleShift2CheharShanbe1, RestTime = $"{command.RestTimeCheharShanbe1}:{command.RestTimeCheharShanbe1Min}", Start2 = command.TowShifts1CheharShanbe1, End2 = command.TowShifts2CheharShanbe1, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.PanjShanbe1 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "1", DayOfWork = "5", Start1 = command.SingleShift1PanjShanbe1, End1 = command.SingleShift2PanjShanbe1, RestTime = $"{command.RestTimePanjShanbe1}:{command.RestTimePanjShanbe1Min}", Start2 = command.TowShifts1PanjShanbe1, End2 = command.TowShifts2PanjShanbe1, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.Jome1 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "1", DayOfWork = "6", Start1 = command.SingleShift1Jome1, End1 = command.SingleShift2Jome1, RestTime = $"{command.RestTimeJome1}:{command.RestTimeJome1Min}", Start2 = command.TowShifts1Jome1, End2 = command.TowShifts2Jome1, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } #endregion //week2 #region Week2 if (command.Shanbe2 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "2", DayOfWork = "0", Start1 = command.SingleShift1Shanbe2, End1 = command.SingleShift2Shanbe2, RestTime = $"{command.RestTimeShanbe2}:{command.RestTimeShanbe2Min}", Start2 = command.TowShifts1Shanbe2, End2 = command.TowShifts2Shanbe2, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.YekShanbe2 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "2", DayOfWork = "1", Start1 = command.SingleShift1YekShanbe2, End1 = command.SingleShift2YekShanbe2, RestTime = $"{command.RestTimeYekShanbe2}:{command.RestTimeYekShanbe2Min}", Start2 = command.TowShifts1YekShanbe2, End2 = command.TowShifts2YekShanbe2, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.DoShanbe2 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "2", DayOfWork = "2", Start1 = command.SingleShift1DoShanbe2, End1 = command.SingleShift2DoShanbe2, RestTime = $"{command.RestTimeDoShanbe2}:{command.RestTimeDoShanbe2Min}", Start2 = command.TowShifts1DoShanbe2, End2 = command.TowShifts2DoShanbe2, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.SeShanbe2 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "2", DayOfWork = "3", Start1 = command.SingleShift1SeShanbe2, End1 = command.SingleShift2SeShanbe2, RestTime = $"{command.RestTimeSeShanbe2}:{ command.RestTimeSeShanbe2Min}", Start2 = command.TowShifts1SeShanbe2, End2 = command.TowShifts2SeShanbe2, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.CheharShanbe2 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "2", DayOfWork = "4", Start1 = command.SingleShift1CheharShanbe2, End1 = command.SingleShift2CheharShanbe2, RestTime = $"{command.RestTimeCheharShanbe2}:{command.RestTimeCheharShanbe2Min}", Start2 = command.TowShifts1CheharShanbe2, End2 = command.TowShifts2CheharShanbe2, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.PanjShanbe2 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "2", DayOfWork = "5", Start1 = command.SingleShift1PanjShanbe2, End1 = command.SingleShift2PanjShanbe2, RestTime = $"{command.RestTimePanjShanbe2}:{command.RestTimePanjShanbe2Min}", Start2 = command.TowShifts1PanjShanbe2, End2 = command.TowShifts2PanjShanbe2, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.Jome2 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "2", DayOfWork = "6", Start1 = command.SingleShift1Jome2, End1 = command.SingleShift2Jome2, RestTime = $"{command.RestTimeJome2}:{command.RestTimeJome2Min}", Start2 = command.TowShifts1Jome2, End2 = command.TowShifts2Jome2, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } #endregion //week3 #region Week3 if (command.Shanbe3 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "3", DayOfWork = "0", Start1 = command.SingleShift1Shanbe3, End1 = command.SingleShift2Shanbe3, RestTime = $"{command.RestTimeShanbe3}:{command.RestTimeShanbe3Min}", Start2 = command.TowShifts1Shanbe3, End2 = command.TowShifts2Shanbe3, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.YekShanbe3 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "3", DayOfWork = "1", Start1 = command.SingleShift1YekShanbe3, End1 = command.SingleShift2YekShanbe3, RestTime = $"{command.RestTimeYekShanbe3}:{command.RestTimeYekShanbe3Min}", Start2 = command.TowShifts1YekShanbe3, End2 = command.TowShifts2YekShanbe3, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.DoShanbe3 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "3", DayOfWork = "2", Start1 = command.SingleShift1DoShanbe3, End1 = command.SingleShift2DoShanbe3, RestTime = $"{command.RestTimeDoShanbe3}:{command.RestTimeDoShanbe3Min}", Start2 = command.TowShifts1DoShanbe3, End2 = command.TowShifts2DoShanbe3, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.SeShanbe3 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "3", DayOfWork = "3", Start1 = command.SingleShift1SeShanbe3, End1 = command.SingleShift2SeShanbe3, RestTime = $"{command.RestTimeSeShanbe3}:{ command.RestTimeSeShanbe3Min}", Start2 = command.TowShifts1SeShanbe3, End2 = command.TowShifts2SeShanbe3, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.CheharShanbe3 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "3", DayOfWork = "4", Start1 = command.SingleShift1CheharShanbe3, End1 = command.SingleShift2CheharShanbe3, RestTime = $"{command.RestTimeCheharShanbe3}:{command.RestTimeCheharShanbe3Min}", Start2 = command.TowShifts1CheharShanbe3, End2 = command.TowShifts2CheharShanbe3, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.PanjShanbe3 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "3", DayOfWork = "5", Start1 = command.SingleShift1PanjShanbe3, End1 = command.SingleShift2PanjShanbe3, RestTime = $"{command.RestTimePanjShanbe3}:{command.RestTimePanjShanbe3Min}", Start2 = command.TowShifts1PanjShanbe3, End2 = command.TowShifts2PanjShanbe3, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.Jome3 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "3", DayOfWork = "6", Start1 = command.SingleShift1Jome3, End1 = command.SingleShift2Jome3, RestTime = $"{command.RestTimeJome3}:{command.RestTimeJome3Min}", Start2 = command.TowShifts1Jome3, End2 = command.TowShifts2Jome3, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } #endregion //week4 #region Week4 if (command.Shanbe4 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "4", DayOfWork = "0", Start1 = command.SingleShift1Shanbe4, End1 = command.SingleShift2Shanbe4, RestTime = $"{command.RestTimeShanbe4}:{command.RestTimeShanbe4Min}", Start2 = command.TowShifts1Shanbe4, End2 = command.TowShifts2Shanbe4, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.YekShanbe4 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "4", DayOfWork = "1", Start1 = command.SingleShift1YekShanbe4, End1 = command.SingleShift2YekShanbe4, RestTime = $"{command.RestTimeYekShanbe4}:{command.RestTimeYekShanbe4Min}", Start2 = command.TowShifts1YekShanbe4, End2 = command.TowShifts2YekShanbe4, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.DoShanbe4 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "4", DayOfWork = "2", Start1 = command.SingleShift1DoShanbe4, End1 = command.SingleShift2DoShanbe4, RestTime = $"{command.RestTimeDoShanbe4}:{command.RestTimeDoShanbe4Min}", Start2 = command.TowShifts1DoShanbe4, End2 = command.TowShifts2DoShanbe4, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.SeShanbe4 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "4", DayOfWork = "3", Start1 = command.SingleShift1SeShanbe4, End1 = command.SingleShift2SeShanbe4, RestTime = $"{command.RestTimeSeShanbe4}:{ command.RestTimeSeShanbe4Min}", Start2 = command.TowShifts1SeShanbe4, End2 = command.TowShifts2SeShanbe4, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.CheharShanbe4 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "4", DayOfWork = "4", Start1 = command.SingleShift1CheharShanbe4, End1 = command.SingleShift2CheharShanbe4, RestTime = $"{command.RestTimeCheharShanbe4}:{command.RestTimeCheharShanbe4Min}", Start2 = command.TowShifts1CheharShanbe4, End2 = command.TowShifts2CheharShanbe4, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.PanjShanbe4 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "4", DayOfWork = "5", Start1 = command.SingleShift1PanjShanbe4, End1 = command.SingleShift2PanjShanbe4, RestTime = $"{command.RestTimePanjShanbe4}:{command.RestTimePanjShanbe4Min}", Start2 = command.TowShifts1PanjShanbe4, End2 = command.TowShifts2PanjShanbe4, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } if (command.Jome4 == true) { var create = new CreateWorkingHoursItems() { WeekNumber = "4", DayOfWork = "6", Start1 = command.SingleShift1Jome4, End1 = command.SingleShift2Jome4, RestTime = $"{command.RestTimeJome4}:{command.RestTimeJome4Min}", Start2 = command.TowShifts1Jome4, End2 = command.TowShifts2Jome4, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } #endregion } else if (command.ShiftWork == "5") { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "7", ComplexStart = command.StartComplex, ComplexEnd = command.EndComplex, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } else if (command.ShiftWork == "6") { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "7", ComplexStart = command.StartComplex, ComplexEnd = command.EndComplex, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } else if (command.ShiftWork == "7") { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "7", ComplexStart = command.StartComplex, ComplexEnd = command.EndComplex, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } else if (command.ShiftWork == "8") { var create = new CreateWorkingHoursItems() { WeekNumber = "0", DayOfWork = "7", ComplexStart = command.StartComplex, ComplexEnd = command.EndComplex, WorkingHoursId = createNew.id }; _workingHoursItemsApplication.Create(create); } return op.Succcedded(); } public async Task CreateNewAsync(CreateWorkingHoursTemp command) { var res = CreateNew(command); return res; } public OperationResult Edit(EditWorkingHours command) { var op = new OperationResult(); var edit = _workingHoursRepository.Get(command.Id); edit.Edit(command.ShiftWork, command.ContractNo, command.NumberOfWorkingDays, command.NumberOfFriday, command.TotalHoursesH, command.TotalHoursesM, command.OverTimeWorkH, command.OverTimeWorkM, command.OverNightWorkH, command.OverNightWorkM, command.WeeklyWorkingTime, command.ContractId); _workingHoursRepository.SaveChanges(); return op.Succcedded(); } public EditWorkingHours GetDetails(long id) { return _workingHoursRepository.GetDetails(id); } public List GetWorkingHours() { return _workingHoursRepository.GetWorkingHours(); } public WorkingHoursViewModel GetByContractId(long id) { return _workingHoursRepository.GetByContractId(id); } public void removeWorkingHours(long id) { _workingHoursRepository.removeWorkingHours(id); } public async Task removeWorkingHoursAsync(long id) { _workingHoursRepository.removeWorkingHours(id); } }