From ed95fbd8d4c12f9184406b4ddadf1904b6759486 Mon Sep 17 00:00:00 2001 From: SamSys Date: Sat, 24 Aug 2024 19:13:34 +0330 Subject: [PATCH] TeamWork Task And ticket uploud --- 0_Framework/0_Framework.csproj | 1 + 0_Framework/Application/AuthHelper.cs | 6 + 0_Framework/Application/IAuthHelper.cs | 2 + 0_Framework/Application/Tools.cs | 149 +- 0_Framework/Application/Version.cs | 4 +- .../Account/AccountViewModel.cs | 2 + .../Account/IAccountApplication.cs | 2 +- .../Assign/AssignViewModel.cs | 34 +- .../Assign/CreateAssign.cs | 25 +- .../CameraAccount/CreateCameraAccount.cs | 1 + .../Task/CompleteTaskViewModel.cs | 2 +- .../Task/CreateTask.cs | 11 + .../Task/CreateTaskCancel.cs | 4 +- .../Task/CreateTaskModal.cs | 19 + .../Task/EditTask.cs | 10 + .../Task/ITaskApplication.cs | 40 +- .../Task/TaskViewModel.cs | 10 +- .../TaskMessage/CreateTaskMessage.cs | 9 + .../TaskMessage/EditTaskMessage.cs | 6 + .../TaskMessage/TaskMessageViewModel.cs | 14 + .../TaskSchedule/ITaskScheduleApplication.cs | 12 + .../Ticket/AdminResponseViewModel.cs | 8 +- .../Ticket/CreateTicket.cs | 7 +- .../Ticket/CreateTicketViewModel.cs | 10 + .../Ticket/EditTicket.cs | 9 +- .../Ticket/ITicketApplication.cs | 16 + .../Ticket/Response.cs | 7 + .../Ticket/ResponseTicket.cs | 1 + .../Ticket/TicketSearchModel.cs | 14 +- .../Ticket/TicketViewModel.cs | 6 + .../ITicketAccessAccountApplication.cs | 14 + .../TicketAccessAccountViewModel.cs | 9 + .../AccountApplication.cs | 39 +- .../AccountManagement.Application.csproj | 1 + .../PositionApplication.cs | 60 +- .../TaskApplication.cs | 552 +- .../TaskScheduleApplication.cs | 223 + .../TaskSubjectApplication.cs | 4 +- .../TicketAccessAccountApplication.cs | 60 + .../TicketApplication.cs | 300 +- .../AccountManagementBootstrapper.cs | 19 +- .../AccountAgg/Account.cs | 12 +- .../AccountAgg/IAccountRepository.cs | 5 +- .../AdminResponseAgg/AdminResponse.cs | 17 +- AccountManagement.Domain/AssignAgg/Assign.cs | 137 +- .../AssignAgg/IAssignRepository.cs | 10 +- .../PositionAgg/IPositionRepository.cs | 2 +- .../TaskAgg/ITaskRepository.cs | 17 +- AccountManagement.Domain/TaskAgg/Tasks.cs | 118 +- .../TaskMessageAgg/ITaskMessageRepository.cs | 11 + .../TaskMessageAgg/TaskMessage.cs | 26 + .../TaskMessageItemsAgg/TaskMessageItems.cs | 22 + .../ITaskScheduleRepository.cs | 8 + .../TaskScheduleAgg/TaskSchedule.cs | 29 + .../ITicketAccessAccountRepository.cs | 12 + .../TicketAccessAccount.cs | 13 + .../TicketAgg/ITicketRepository.cs | 8 + AccountManagement.Domain/TicketAgg/Ticket.cs | 22 +- .../AccountContext.cs | 7 + .../Mappings/AccountMapping.cs | 3 +- .../Mappings/AdminResponseMapping.cs | 1 + .../Mappings/AssignMapping.cs | 9 +- .../Mappings/TaskMapping.cs | 17 +- .../Mappings/TaskMessageItemsMapping.cs | 17 + .../Mappings/TaskMessageMapping.cs | 23 + .../Mappings/TaskScheduleMapping.cs | 22 + .../Mappings/TicketAccessAccountMapping.cs | 14 + .../Mappings/TicketMapping.cs | 5 +- ...0821152830_AccountTableChanges.Designer.cs | 772 + .../20240821152830_AccountTableChanges.cs | 29 + ...askMessageTables_AssignChanges.Designer.cs | 896 + ...1154206_taskMessageTables_AssignChanges.cs | 197 + ...40821171716_Task_TicketChanges.Designer.cs | 951 + .../20240821171716_Task_TicketChanges.cs | 270 + .../Migrations/AccountContextModelSnapshot.cs | 253 +- .../Repository/AccountRepository.cs | 46 +- .../Repository/AssignRepository.cs | 50 +- .../Repository/PositionRepository.cs | 10 +- .../Repository/TaskMessageRepository.cs | 63 + .../Repository/TaskRepository.cs | 2376 +-- .../TicketAccessAccountRepository.cs | 41 + .../Repository/TicketRepository.cs | 361 +- Company.Domain/Error/ErrorViewModel.cs | 13 + .../HolidayItem/IHolidayItemApplication.cs | 6 + .../RollCallEmployeeViewModel.cs | 20 + .../Workshop/TakePictureModel.cs | 1 + .../HolidayItemApplication.cs | 5 + .../Repository/RollCallMandatoryRepository.cs | 1 - .../Areas/Admin/Pages/Shared/_Menu.cshtml | 70 +- .../Company/ContractingParties/Index.cshtml | 469 + .../ContractingParties/Index.cshtml.cs | 239 + .../Pages/Company/Employees/Index.cshtml | 4 + .../Pages/Company/Employees/Index.cshtml.cs | 12 + .../Pages/Company/Employers/Index.cshtml | 153 + .../Pages/Company/Employers/Index.cshtml.cs | 259 + .../Pages/Company/RollCall/Index.cshtml | 88 + .../Pages/Company/RollCall/Index.cshtml.cs | 12 + .../AdminNew/Pages/Company/Task/Create.cshtml | 39 +- .../Pages/Company/Task/Create.cshtml.cs | 30 +- .../Task/CreateCRUDTaskSubjectModal.cshtml | 29 +- .../Pages/Company/Task/CreateModal.cshtml | 338 + .../Pages/Company/Task/DetailsModal.cshtml | 388 +- .../Pages/Company/Task/DetailsModalOld.cshtml | 212 + .../Task/DetailsTaskTicketsModal.cshtml | 647 + .../Company/Task/DiagramTaskModal.cshtml | 121 + .../AdminNew/Pages/Company/Task/Edit.cshtml | 572 +- .../AdminNew/Pages/Company/Task/Group.cshtml | 626 +- .../Pages/Company/Task/Group.cshtml.cs | 32 +- .../AdminNew/Pages/Company/Task/Index.cshtml | 104 +- .../Pages/Company/Task/Index.cshtml.cs | 382 +- .../Pages/Company/Task/OperationModal.cshtml | 425 +- .../Company/Task/OperationRequestModal.cshtml | 782 +- .../Task/OperationRequestModalOld.cshtml | 579 + .../Company/Ticket/DetailTicketModal.cshtml | 225 + .../Pages/Company/Ticket/Index.cshtml | 511 + .../Pages/Company/Ticket/Index.cshtml.cs | 235 + ServiceHost/Areas/AdminNew/Pages/Index.cshtml | 210 +- .../Areas/AdminNew/Pages/Index.cshtml.cs | 81 +- .../AdminNew/Pages/Shared/_Header.cshtml | 21 +- .../AdminNew/Pages/Shared/_Layout.cshtml | 1 + .../Areas/AdminNew/Pages/Shared/_Menu.cshtml | 44 +- .../Shared/_ValidationScriptsPartial.cshtml | 2 +- .../Pages/Shared/_validationAlert.cshtml | 72 +- .../Areas/AdminNew/Pages/_ViewStart.cshtml | 4 +- .../Company/Checkouts/CheckoutPrintAll.cshtml | 4563 ++--- .../Checkouts/CheckoutPrintAll.cshtml.cs | 411 +- .../Pages/Company/Checkouts/CustomSet.cshtml | 130 +- .../Pages/Company/Checkouts/Index.cshtml | 3292 ++-- .../Pages/Company/Checkouts/Index.cshtml.cs | 310 +- .../Pages/Company/Checkouts/PrintAll.cshtml | 4394 ++--- .../Pages/Company/Checkouts/PrintOne.cshtml | 5275 +++--- .../Company/Checkouts/PrintOneMobile.cshtml | 5276 +++--- .../Pages/Company/Checkouts/alert.cshtml | 341 +- .../Company/Contracts/AutoExtension.cshtml | 1264 +- .../Company/Contracts/AutoExtension.cshtml.cs | 9195 +++++----- .../Company/Contracts/ContractList.cshtml | 1009 +- .../Company/Contracts/ContractPrintAll.cshtml | 870 +- .../Contracts/ContractPrintAll.cshtml.cs | 441 +- .../Company/Contracts/ContractStatus.cshtml | 522 +- .../Pages/Company/Contracts/Index.cshtml | 3292 ++-- .../Pages/Company/Contracts/Index.cshtml.cs | 480 +- .../Pages/Company/Contracts/PrintAll.cshtml | 603 +- .../Pages/Company/Contracts/PrintOne.cshtml | 672 +- .../Company/Contracts/PrintOneMobile.cshtml | 652 +- .../Company/Contracts/WorkshopList.cshtml | 235 +- .../Company/Contracts/WorkshopList.cshtml.cs | 45 +- .../Pages/Company/Contracts/clock.cshtml | 14363 ++++++++-------- .../Pages/Company/Employees/ChangeCode.cshtml | 627 +- .../Employees/ContractCheckoutStatus.cshtml | 727 +- .../ContractCheckoutStatusPrint.cshtml | 759 +- .../Pages/Company/Employees/Create.cshtml | 2375 ++- .../Pages/Company/Employees/Details.cshtml | 229 +- .../Pages/Company/Employees/Edit.cshtml | 2007 +-- .../Pages/Company/Employees/EditSick.cshtml | 674 +- .../Company/Employees/EmployeeList.cshtml | 491 +- .../Pages/Company/Employees/Index.cshtml | 170 +- .../Pages/Company/Employees/Index.cshtml.cs | 967 +- .../Pages/Company/Employees/Leave.cshtml | 22 +- .../Pages/Company/Employees/Leave.cshtml.cs | 23 +- .../Company/Employees/LeaveCreateModal.cshtml | 14 +- .../Company/Employees/LeavePrintAll.cshtml | 430 +- .../Company/Employees/LeavePrintAll.cshtml.cs | 421 +- .../Pages/Company/Employees/LeftWork.cshtml | 3258 ++-- .../Employees/LeftWorkInsurance.cshtml | 2849 ++- .../Pages/Company/Employees/PaidLeave.cshtml | 776 +- .../Company/Employees/PaidLeaveList.cshtml | 172 +- .../Pages/Company/Employees/PrintAll.cshtml | 252 +- .../PrintAllDetailsPersonnelInfo.cshtml | 292 +- .../PrintAllDetailsPersonnelInfoMobile.cshtml | 341 +- .../Company/Employees/PrintAllList.cshtml | 358 +- .../Employees/PrintAllPersonnelInfo.cshtml | 416 +- .../PrintAllPersonnelInfoMobile.cshtml | 430 +- .../Pages/Company/Employees/PrintOne.cshtml | 286 +- .../Company/Employees/PrintOneMobile.cshtml | 296 +- .../Pages/Company/Employees/SickLeave.cshtml | 846 +- .../Company/Employees/SickLeaveList.cshtml | 182 +- .../Company/Employees/WorkshopList.cshtml | 78 +- .../Company/Employees/WorkshopList.cshtml.cs | 39 +- .../Pages/Company/Employees/alert.cshtml | 226 +- .../Pages/Company/Error/_ErrorModal.cshtml | 29 + .../InsuranceList/EmployeeDatatable.cshtml | 250 +- .../InsuranceList/EmployeeListForEdit.cshtml | 237 +- .../Pages/Company/InsuranceList/Index.cshtml | 1635 +- .../Company/InsuranceList/Index.cshtml.cs | 2151 +-- .../InsuranceList/InsuranceConfirm.cshtml | 990 +- .../Company/InsuranceList/MainSearch.cshtml | 719 +- .../Company/InsuranceList/PrintOne.cshtml | 358 +- .../InsuranceList/PrintOneMobile.cshtml | 344 +- .../Company/InsuranceList/WorkshopList.cshtml | 186 +- .../InsuranceList/WorkshopList.cshtml.cs | 45 +- .../Company/Partial/_EmptySection.cshtml | 10 + .../Company/PaymentToEmployee/Create.cshtml | 1172 +- .../Company/PaymentToEmployee/Index.cshtml | 2890 ++-- .../Company/PaymentToEmployee/Index.cshtml.cs | 365 +- .../PrintAllWithCheckout.cshtml | 506 +- .../PrintAllWithoutCheckout.cshtml | 448 +- .../Company/Profile/ChangePassword.cshtml | 491 +- .../Pages/Company/Profile/Profile.cshtml | 431 +- .../Pages/Company/Profile/Profile.cshtml.cs | 159 +- .../Company/Reports/CheckoutReport.cshtml | 1885 +- .../Company/Reports/CheckoutReport.cshtml.cs | 217 +- .../Client/Pages/Company/Reports/Index.cshtml | 379 +- .../Pages/Company/Reports/Index.cshtml.cs | 77 +- .../Reports/PrintAllCheckoutReport.cshtml | 536 +- .../Pages/Company/RollCall/CaseHistory.cshtml | 1 + .../Company/RollCall/CaseHistory.cshtml.cs | 69 + .../Pages/Company/RollCall/CurrentDay.cshtml | 1 + .../Company/RollCall/CurrentDay.cshtml.cs | 91 + .../RollCall/EmployeeUploadPicture.cshtml | 367 + .../RollCall/EmployeeUploadPicture.cshtml.cs | 334 + .../Pages/Company/RollCall/Index.cshtml | 491 +- .../Pages/Company/RollCall/Index.cshtml.cs | 152 +- .../RollCall/ModalCameraAccount.cshtml | 379 + .../Company/RollCall/ModalOTPAction.cshtml | 562 +- .../RollCall/ModalOTPActionFree.cshtml | 339 + .../Company/RollCall/ModalTakeImages.cshtml | 625 +- .../Pages/Company/RollCall/Plans.cshtml | 195 +- .../Pages/Company/RollCall/Plans.cshtml.cs | 597 +- .../Company/Ticket/DetailTicketModal.cshtml | 237 + .../Ticket/DetailTicketModalOld.cshtml | 698 + .../Client/Pages/Company/Ticket/Index.cshtml | 477 + .../Pages/Company/Ticket/Index.cshtml.cs | 212 + .../Workshop/ConnectedPersonnels.cshtml | 142 +- .../ContractCheckoutYearlyStatus.cshtml | 1598 +- .../Pages/Company/Workshop/Employees.cshtml | 932 +- .../Company/Workshop/Employees.cshtml.cs | 112 +- .../Pages/Company/Workshop/Index.cshtml | 299 +- .../Pages/Company/Workshop/Index.cshtml.cs | 1189 +- .../Company/Workshop/LeaveListAll.cshtml | 477 +- .../Workshop/PrintOnePersonnelInfo.cshtml | 332 +- .../Company/Workshop/WorkshopEmployee.cshtml | 349 +- .../Workshop/WorkshopEmployee.cshtml.cs | 48 +- .../Company/Workshop/WorkshopList.cshtml | 215 +- .../Areas/Client/Pages/Index.cshtml.cs | 705 +- .../Areas/Client/Pages/LeaveCreate.cshtml | 1176 +- .../Areas/Client/Pages/LeaveList.cshtml | 420 +- .../Pages/PaymentToPersonnelCreate.cshtml | 361 +- .../Pages/Shared/_BtnCreateTicket.cshtml | 269 + .../Client/Pages/Shared/_ClientLayout.cshtml | 210 +- .../Areas/Client/Pages/Shared/_Menu.cshtml | 556 +- .../Shared/_ValidationScriptsPartial.cshtml | 2 +- .../Pages/Shared/_headerAndFooter.cshtml | 416 +- .../Pages/Shared/_validationAlert.cshtml | 72 +- .../Areas/Client/Pages/_ViewStart.cshtml | 4 +- ServiceHost/ServiceHost.csproj | 95 +- .../462/Screenshot (5)_638598713026955129.png | Bin 0 -> 1468923 bytes .../1/Screenshot (4)_638598723225010356.png | Bin 0 -> 645858 bytes .../1/screenshot_638598722945321550.png | Bin 0 -> 385623 bytes .../2/Screenshot (5)_638598726090265935.png | Bin 0 -> 1468923 bytes .../2/screenshot_638598725890580848.png | Bin 0 -> 275252 bytes .../temp/2/pic3_638573708929965000.png | Bin 145528 -> 0 bytes .../AssetsAdminNew/Tasks/css/DetailModal.css | 319 +- .../Tasks/css/DiagramTaskModal.css | 190 + .../wwwroot/AssetsAdminNew/Tasks/css/Edit.css | 3 - .../AssetsAdminNew/Tasks/css/Index.css | 14 + .../Tasks/css/OperationRequestModal.css | 52 + .../AssetsAdminNew/Tasks/css/create.css | 4 +- .../Tasks/css/task-manager-create.css | 293 +- .../Tasks/css/task-manager-list.css | 25 +- .../AssetsAdminNew/Tasks/css/taskgroup.css | 170 +- .../Tasks/js/CreateCRUDTaskSubjectModal.js | 56 +- .../AssetsAdminNew/Tasks/js/DetailModal.js | 1138 +- .../AssetsAdminNew/Tasks/js/DetailModalOld.js | 779 + .../Tasks/js/DetailModalSender.js | 472 + .../Tasks/js/DiagramTaskModal.js | 120 + .../wwwroot/AssetsAdminNew/Tasks/js/Edit.js | 1422 +- .../wwwroot/AssetsAdminNew/Tasks/js/Index.js | 414 +- .../AssetsAdminNew/Tasks/js/OperationModal.js | 5 +- .../Tasks/js/OperationRequestModal.js | 718 +- .../Tasks/js/OperationRequestModalOld.js | 474 + .../wwwroot/AssetsAdminNew/Tasks/js/create.js | 948 +- .../AssetsAdminNew/Ticket/css/Index.css | 375 + .../Ticket/css/ticket-create.css | 447 + .../AssetsAdminNew/Ticket/css/ticket-list.css | 314 + .../Ticket/css/ticket-message.css | 577 + .../Ticket/js/detailTicketModal.js | 1294 ++ .../libs/SweetAlert2/sweetalert2.all.min.js | 6 + .../libs/SweetAlert2/sweetalert2.min.css | 1 + .../wwwroot/AssetsClient/css/style.css | 16 +- .../AssetsClient/css/ticket-create.css | 341 +- .../ticket-global/ticket-create-global.css | 516 + .../wwwroot/AssetsClient/css/ticket-list.css | 26 +- .../AssetsClient/css/ticket-message.css | 463 +- .../wwwroot/AssetsClient/images/Chat.png | Bin 0 -> 1893 bytes .../AssetsClient/images/Rectangle 4226.png | Bin 0 -> 7989 bytes .../AssetsClient/images/User_alt_fill.png | Bin 0 -> 479 bytes .../AssetsClient/images/group-task.png | Bin 0 -> 1725 bytes .../wwwroot/AssetsClient/js/Ticket/Index.js | 191 + .../js/Ticket/detailTicketModal.js | 1141 ++ .../AssetsClient/js/html2canvas.min.js | 20 + .../wwwroot/AssetsClient/js/tickets_action.js | 1032 ++ ServiceHost/wwwroot/Common/fileSvg/AI.svg | 12 + ServiceHost/wwwroot/Common/fileSvg/AVI.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/BMP.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/CRD.svg | 17 + ServiceHost/wwwroot/Common/fileSvg/CSV.svg | 16 + ServiceHost/wwwroot/Common/fileSvg/DLL.svg | 37 + ServiceHost/wwwroot/Common/fileSvg/DOC.svg | 15 + ServiceHost/wwwroot/Common/fileSvg/DOCX.svg | 16 + ServiceHost/wwwroot/Common/fileSvg/DWG.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/EPS.svg | 18 + ServiceHost/wwwroot/Common/fileSvg/EXE.svg | 24 + ServiceHost/wwwroot/Common/fileSvg/FLV.svg | 13 + ServiceHost/wwwroot/Common/fileSvg/GIFF.svg | 15 + ServiceHost/wwwroot/Common/fileSvg/HTML.svg | 15 + ServiceHost/wwwroot/Common/fileSvg/ISO.svg | 15 + ServiceHost/wwwroot/Common/fileSvg/JAVA.svg | 17 + ServiceHost/wwwroot/Common/fileSvg/JPG.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/MDB.svg | 12 + ServiceHost/wwwroot/Common/fileSvg/MID.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/MOV.svg | 13 + ServiceHost/wwwroot/Common/fileSvg/MP3.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/MP4.svg | 13 + ServiceHost/wwwroot/Common/fileSvg/MPEG.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/PDF.svg | 17 + ServiceHost/wwwroot/Common/fileSvg/PNG.svg | 29 + ServiceHost/wwwroot/Common/fileSvg/PPT.svg | 17 + ServiceHost/wwwroot/Common/fileSvg/PS.svg | 11 + ServiceHost/wwwroot/Common/fileSvg/PSD.svg | 12 + ServiceHost/wwwroot/Common/fileSvg/PUB.svg | 18 + ServiceHost/wwwroot/Common/fileSvg/RAR.svg | 20 + ServiceHost/wwwroot/Common/fileSvg/RAW.svg | 17 + ServiceHost/wwwroot/Common/fileSvg/RSS.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/SVG.svg | 18 + ServiceHost/wwwroot/Common/fileSvg/TIFF.svg | 15 + ServiceHost/wwwroot/Common/fileSvg/TXT.svg | 15 + ServiceHost/wwwroot/Common/fileSvg/WAV.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/WMA.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/XML.svg | 14 + ServiceHost/wwwroot/Common/fileSvg/XSL.svg | 16 + ServiceHost/wwwroot/Common/fileSvg/ZIP.svg | 16 + ServiceHost/wwwroot/Common/fileSvg/unknow.svg | 47 + 332 files changed, 83402 insertions(+), 59336 deletions(-) create mode 100644 AccountManagement.Application.Contracts/Task/CreateTaskModal.cs create mode 100644 AccountManagement.Application.Contracts/TaskMessage/CreateTaskMessage.cs create mode 100644 AccountManagement.Application.Contracts/TaskMessage/EditTaskMessage.cs create mode 100644 AccountManagement.Application.Contracts/TaskMessage/TaskMessageViewModel.cs create mode 100644 AccountManagement.Application.Contracts/TaskSchedule/ITaskScheduleApplication.cs create mode 100644 AccountManagement.Application.Contracts/Ticket/CreateTicketViewModel.cs create mode 100644 AccountManagement.Application.Contracts/TicketAccessAccount/ITicketAccessAccountApplication.cs create mode 100644 AccountManagement.Application.Contracts/TicketAccessAccount/TicketAccessAccountViewModel.cs create mode 100644 AccountManagement.Application/TaskScheduleApplication.cs create mode 100644 AccountManagement.Application/TicketAccessAccountApplication.cs create mode 100644 AccountManagement.Domain/TaskMessageAgg/ITaskMessageRepository.cs create mode 100644 AccountManagement.Domain/TaskMessageAgg/TaskMessage.cs create mode 100644 AccountManagement.Domain/TaskMessageItemsAgg/TaskMessageItems.cs create mode 100644 AccountManagement.Domain/TaskScheduleAgg/ITaskScheduleRepository.cs create mode 100644 AccountManagement.Domain/TaskScheduleAgg/TaskSchedule.cs create mode 100644 AccountManagement.Domain/TicketAccessAccountAgg/ITicketAccessAccountRepository.cs create mode 100644 AccountManagement.Domain/TicketAccessAccountAgg/TicketAccessAccount.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Mappings/TaskMessageItemsMapping.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Mappings/TaskMessageMapping.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Mappings/TaskScheduleMapping.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Mappings/TicketAccessAccountMapping.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Migrations/20240821152830_AccountTableChanges.Designer.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Migrations/20240821152830_AccountTableChanges.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Migrations/20240821154206_taskMessageTables_AssignChanges.Designer.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Migrations/20240821154206_taskMessageTables_AssignChanges.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Migrations/20240821171716_Task_TicketChanges.Designer.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Migrations/20240821171716_Task_TicketChanges.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Repository/TaskMessageRepository.cs create mode 100644 AccountMangement.Infrastructure.EFCore/Repository/TicketAccessAccountRepository.cs create mode 100644 Company.Domain/Error/ErrorViewModel.cs create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/ContractingParties/Index.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/ContractingParties/Index.cshtml.cs create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Employees/Index.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Employees/Index.cshtml.cs create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Employers/Index.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Employers/Index.cshtml.cs create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/RollCall/Index.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/RollCall/Index.cshtml.cs create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateModal.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Task/DetailsModalOld.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Task/DetailsTaskTicketsModal.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Task/DiagramTaskModal.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Task/OperationRequestModalOld.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Ticket/DetailTicketModal.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Ticket/Index.cshtml create mode 100644 ServiceHost/Areas/AdminNew/Pages/Company/Ticket/Index.cshtml.cs create mode 100644 ServiceHost/Areas/Client/Pages/Company/Error/_ErrorModal.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/Partial/_EmptySection.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/CaseHistory.cshtml.cs create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/CurrentDay.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/CurrentDay.cshtml.cs create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/EmployeeUploadPicture.cshtml.cs create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/ModalCameraAccount.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/RollCall/ModalOTPActionFree.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/Ticket/DetailTicketModal.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/Ticket/DetailTicketModalOld.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/Ticket/Index.cshtml create mode 100644 ServiceHost/Areas/Client/Pages/Company/Ticket/Index.cshtml.cs create mode 100644 ServiceHost/Areas/Client/Pages/Shared/_BtnCreateTicket.cshtml create mode 100644 ServiceHost/Storage/Task/462/Screenshot (5)_638598713026955129.png create mode 100644 ServiceHost/Storage/Ticket/1/Screenshot (4)_638598723225010356.png create mode 100644 ServiceHost/Storage/Ticket/1/screenshot_638598722945321550.png create mode 100644 ServiceHost/Storage/Ticket/2/Screenshot (5)_638598726090265935.png create mode 100644 ServiceHost/Storage/Ticket/2/screenshot_638598725890580848.png delete mode 100644 ServiceHost/Storage/temp/2/pic3_638573708929965000.png create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/Tasks/css/DiagramTaskModal.css create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/DetailModalOld.js create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/DetailModalSender.js create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/DiagramTaskModal.js create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/Tasks/js/OperationRequestModalOld.js create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/Ticket/css/Index.css create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/Ticket/css/ticket-create.css create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/Ticket/css/ticket-list.css create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/Ticket/css/ticket-message.css create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/Ticket/js/detailTicketModal.js create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/libs/SweetAlert2/sweetalert2.all.min.js create mode 100644 ServiceHost/wwwroot/AssetsAdminNew/libs/SweetAlert2/sweetalert2.min.css create mode 100644 ServiceHost/wwwroot/AssetsClient/css/ticket-global/ticket-create-global.css create mode 100644 ServiceHost/wwwroot/AssetsClient/images/Chat.png create mode 100644 ServiceHost/wwwroot/AssetsClient/images/Rectangle 4226.png create mode 100644 ServiceHost/wwwroot/AssetsClient/images/User_alt_fill.png create mode 100644 ServiceHost/wwwroot/AssetsClient/images/group-task.png create mode 100644 ServiceHost/wwwroot/AssetsClient/js/Ticket/Index.js create mode 100644 ServiceHost/wwwroot/AssetsClient/js/Ticket/detailTicketModal.js create mode 100644 ServiceHost/wwwroot/AssetsClient/js/html2canvas.min.js create mode 100644 ServiceHost/wwwroot/AssetsClient/js/tickets_action.js create mode 100644 ServiceHost/wwwroot/Common/fileSvg/AI.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/AVI.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/BMP.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/CRD.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/CSV.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/DLL.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/DOC.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/DOCX.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/DWG.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/EPS.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/EXE.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/FLV.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/GIFF.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/HTML.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/ISO.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/JAVA.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/JPG.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/MDB.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/MID.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/MOV.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/MP3.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/MP4.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/MPEG.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/PDF.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/PNG.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/PPT.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/PS.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/PSD.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/PUB.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/RAR.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/RAW.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/RSS.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/SVG.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/TIFF.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/TXT.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/WAV.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/WMA.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/XML.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/XSL.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/ZIP.svg create mode 100644 ServiceHost/wwwroot/Common/fileSvg/unknow.svg diff --git a/0_Framework/0_Framework.csproj b/0_Framework/0_Framework.csproj index e8784139..eb73e124 100644 --- a/0_Framework/0_Framework.csproj +++ b/0_Framework/0_Framework.csproj @@ -11,6 +11,7 @@ + diff --git a/0_Framework/Application/AuthHelper.cs b/0_Framework/Application/AuthHelper.cs index 1c5f8349..4e46f902 100644 --- a/0_Framework/Application/AuthHelper.cs +++ b/0_Framework/Application/AuthHelper.cs @@ -91,6 +91,12 @@ public class AuthHelper : IAuthHelper } } + public string GetWorkshopSlug() + { + return CurrentAccountInfo().ClientAriaPermission == "true" + ? _contextAccessor.HttpContext.User.Claims.First(x => x.Type == "WorkshopSlug")?.Value + : ""; + } #endregion diff --git a/0_Framework/Application/IAuthHelper.cs b/0_Framework/Application/IAuthHelper.cs index e2569b53..0ae1ad48 100644 --- a/0_Framework/Application/IAuthHelper.cs +++ b/0_Framework/Application/IAuthHelper.cs @@ -20,4 +20,6 @@ public interface IAuthHelper void UpdateWorkshopSlugClaim(string workshopSlug); #endregion + + string GetWorkshopSlug(); } \ No newline at end of file diff --git a/0_Framework/Application/Tools.cs b/0_Framework/Application/Tools.cs index 98905a4a..205a3384 100644 --- a/0_Framework/Application/Tools.cs +++ b/0_Framework/Application/Tools.cs @@ -1,10 +1,16 @@ using System; using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; using System.Globalization; +using System.IO; using System.Text.RegularExpressions; using _0_Framework.Infrastructure; using PersianTools.Core; +using static System.Net.Mime.MediaTypeNames; using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; +using Image = System.Drawing.Image; namespace _0_Framework.Application; @@ -865,8 +871,109 @@ public static class Tools var day = Convert.ToInt32(persianDate.Substring(8, 2)); return new PersianDateTime(year, month, day); } + + public static string ResizeImage(string imagePath, int width, int height) + { + using (var srcImage = Image.FromFile(imagePath)) + { + var newImage = new Bitmap(width, height); + using (var graphics = Graphics.FromImage(newImage)) + { + graphics.CompositingQuality = CompositingQuality.HighQuality; + graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; + graphics.SmoothingMode = SmoothingMode.HighQuality; + graphics.DrawImage(srcImage, 0, 0, width, height); + } + + using (var memoryStream = new MemoryStream()) + { + newImage.Save(memoryStream, ImageFormat.Jpeg); + return Convert.ToBase64String(memoryStream.ToArray()); + } + } + } + + public static PersianDateTime ToFirstDayOfNextMonth(this DateTime date) + { + var pc = new PersianCalendar(); + var year = pc.GetYear(date); + var month = pc.GetMonth(date); + + if (month == 12) + { + year += 1; + month = 1; + } + else + { + month += 1; + } + + return new PersianDateTime(year, month, 1); + + } #endregion + #region Safa + + public static string GetContentTypeImage(string extension) + { + if (!extension.StartsWith(".")) + { + extension = "." + extension; + } + + return extension.ToLower() switch + { + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".png" => "image/png", + ".gif" => "image/gif", + ".bmp" => "image/bmp", + ".svg" => "image/svg+xml", + ".ico" => "image/x-icon", + _ => "", + }; + } + + public static string GetContentType(string extension) + { + + // Ensure the extension starts with a dot + if (!extension.StartsWith(".")) + { + extension = "." + extension; + } + + // Use switch expression to return the appropriate content type + return extension.ToLower() switch + { + ".txt" => "text/plain", + ".htm" => "text/html", + ".html" => "text/html", + ".css" => "text/css", + ".js" => "application/javascript", + ".json" => "application/json", + ".xml" => "application/xml", + ".pdf" => "application/pdf", + ".zip" => "application/zip", + ".rar" => "application/x-rar-compressed", + ".tar" => "application/x-tar", + ".mp3" => "audio/mpeg", + ".wav" => "audio/wav", + ".mp4" => "video/mp4", + ".avi" => "video/x-msvideo", + ".doc" => "application/msword", + ".docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + ".xls" => "application/vnd.ms-excel", + ".xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ".ppt" => "application/vnd.ms-powerpoint", + ".pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", + _ => "application/octet-stream", + }; + } + + #endregion public static string ConvertToEnglish(this string value) { if (string.IsNullOrEmpty(value)) @@ -991,6 +1098,7 @@ public static class Tools return false; return true; } + #region Mahan public static string ToFarsiDuration(this string date) { @@ -1103,6 +1211,14 @@ public static class Tools } } + #region DayOfWeekMethods + + public static DateTime GetNextDayOfWeek(this DateTime date, DayOfWeek dayOfWeek) + { + int numberOfNextDayOfWeek = ((int)dayOfWeek - (int)date.DayOfWeek + 7) % 7; + return date.AddDays(numberOfNextDayOfWeek == 0 ? 7 : numberOfNextDayOfWeek); + } + #endregion //این متد آخر همان روز را به صورت دیت تایم برمیگرداند public static DateTime ToGeorgianDateTime2(this string persianDate) @@ -1121,8 +1237,6 @@ public static class Tools return res; - - } catch (Exception e) { @@ -1158,6 +1272,37 @@ public static class Tools } + public static string DayOfWeeKToPersian(this DayOfWeek dayOfWeek) + { + return dayOfWeek switch + { + DayOfWeek.Friday => "جمعه", + DayOfWeek.Monday => "دوشنبه", + DayOfWeek.Saturday => "شنبه", + DayOfWeek.Sunday => "یکشنبه", + DayOfWeek.Thursday => "پنجشنبه", + DayOfWeek.Tuesday => "سه شنبه", + DayOfWeek.Wednesday => "چهارشنبه", + _ => "" + }; + } + + + #endregion + + #region Pooya + + + + public static DateTime GetUndefinedDateTime() + { + return new DateTime(2121, 03, 21); + } + + public static bool IsDateUndefined(this DateTime date) + { + return date == new DateTime(2121, 03, 21); + } #endregion } \ No newline at end of file diff --git a/0_Framework/Application/Version.cs b/0_Framework/Application/Version.cs index 6f239308..0984e674 100644 --- a/0_Framework/Application/Version.cs +++ b/0_Framework/Application/Version.cs @@ -10,8 +10,8 @@ public static class Version { static Version() { - StyleVersion = "2.11.34"; - AdminVersion = "2.5.19"; + StyleVersion = "2.12.00"; + AdminVersion = "2.5.20"; CameraVersion = "1.0.3"; } diff --git a/AccountManagement.Application.Contracts/Account/AccountViewModel.cs b/AccountManagement.Application.Contracts/Account/AccountViewModel.cs index 2794917e..fea1dcd8 100644 --- a/AccountManagement.Application.Contracts/Account/AccountViewModel.cs +++ b/AccountManagement.Application.Contracts/Account/AccountViewModel.cs @@ -21,6 +21,8 @@ public class AccountViewModel public int PositionValue { get; set; } public long PositionId { get; set; } + public string PositionIsActive { get; set; } + #endregion public string AdminAreaPermission { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Account/IAccountApplication.cs b/AccountManagement.Application.Contracts/Account/IAccountApplication.cs index 08f1c7ea..f071ccfb 100644 --- a/AccountManagement.Application.Contracts/Account/IAccountApplication.cs +++ b/AccountManagement.Application.Contracts/Account/IAccountApplication.cs @@ -37,7 +37,7 @@ public interface IAccountApplication OperationResult CreateNewWorkshopAccount(long currentAccountId, long newAccountId); #region Mahan - List AccountsForAssign(long accountId); + List AccountsForAssign(long taskId); List GetAccountsByPositionId(long positionId); List GetAccountLowerPositionvalue(); diff --git a/AccountManagement.Application.Contracts/Assign/AssignViewModel.cs b/AccountManagement.Application.Contracts/Assign/AssignViewModel.cs index fcb0cd54..9a60702f 100644 --- a/AccountManagement.Application.Contracts/Assign/AssignViewModel.cs +++ b/AccountManagement.Application.Contracts/Assign/AssignViewModel.cs @@ -1,9 +1,41 @@  +using System.Collections.Generic; +using System; + namespace AccountManagement.Application.Contracts.Assign; -public class AssignViewModel:EditAssign +public class AssignViewModel { + public long Id { get; set; } public string AssignedName { get; set; } public int AssignedPositionValue { get; set; } + public long AssignerId { get; set; } + public long AssignedId { get; set; } + public long TaskId { get; set; } + public int AssignerPositionValue { get; set; } + //زمان پایان وظیفه + public string EndTaskDateFa { get; set; } + public DateTime EndTaskDateGr { get; set; } + //آیا درخواست مهلت کرده است؟ + public bool TimeRequest { get; set; } + //تعداد تایید درخواست مهلت + public int AcceptedTimeRequest { get; set; } + //مهلت زمان درخواست شده + public DateTime? RequestDate { get; set; } + public string? RequestDateFa { get; set; } + //توضیحات درخواست مهلت + public string? TimeRequestDescription { get; set; } + //آیا درخواست انصراف داده شده + + //آیا کنسل شده است + public bool IsCancel { get; set; } + //توضیحات درخواست انصراف + public string? CancelDescription { get; set; } + public bool IsDone { get; set; } + public bool IsDoneRequest { get; set; } + + public string? DoneDescription { get; set; } + public bool IsCanceledRequest { get; set; } + } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Assign/CreateAssign.cs b/AccountManagement.Application.Contracts/Assign/CreateAssign.cs index ff5361c7..f3aad268 100644 --- a/AccountManagement.Application.Contracts/Assign/CreateAssign.cs +++ b/AccountManagement.Application.Contracts/Assign/CreateAssign.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace AccountManagement.Application.Contracts.Assign; @@ -8,5 +9,27 @@ public class CreateAssign public List AssignedId { get; set; } public long TaskId { get; set; } public int AssignerPositionValue { get; set; } + //زمان پایان وظیفه + public string EndTaskDateFa { get; set; } + public DateTime EndTaskDateGr { get; set; } + //آیا درخواست مهلت کرده است؟ + public bool TimeRequest { get; set; } + //تعداد تایید درخواست مهلت + public int AcceptedTimeRequest { get; set; } + //مهلت زمان درخواست شده + public DateTime? RequestDate { get; set; } + //توضیحات درخواست مهلت + public string? TimeRequestDescription { get; set; } + //آیا درخواست انصراف داده شده + + //آیا کنسل شده است + public bool IsCancel { get; set; } + //توضیحات درخواست انصراف + public string? CancelDescription { get; set; } + public bool IsDone { get; set; } + public bool IsDoneRequest { get; set; } + + public string? DoneDescription { get; set; } + public bool IsCanceledRequest { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/CameraAccount/CreateCameraAccount.cs b/AccountManagement.Application.Contracts/CameraAccount/CreateCameraAccount.cs index 477d36d9..0c405125 100644 --- a/AccountManagement.Application.Contracts/CameraAccount/CreateCameraAccount.cs +++ b/AccountManagement.Application.Contracts/CameraAccount/CreateCameraAccount.cs @@ -10,6 +10,7 @@ public class CreateCameraAccount { public string Username { get; set; } public string Password { get; set; } + public string RePassword { get; set; } public string Mobile { get; set; } public long WorkshopId { get; set; } public string WorkshopName { get; set; } diff --git a/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs b/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs index 73389d6e..9a2133e9 100644 --- a/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs +++ b/AccountManagement.Application.Contracts/Task/CompleteTaskViewModel.cs @@ -2,6 +2,6 @@ public class CompleteTaskViewModel { - public long Id { get; set; } + public long TaskId { get; set; } public string? Description { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/CreateTask.cs b/AccountManagement.Application.Contracts/Task/CreateTask.cs index 8b951b5f..47f37d30 100644 --- a/AccountManagement.Application.Contracts/Task/CreateTask.cs +++ b/AccountManagement.Application.Contracts/Task/CreateTask.cs @@ -16,6 +16,17 @@ public class CreateTask public List UploadedMedia { get; set; } public long UploadedVoiceMedia { get; set; } + #region Task Schedule + + public string ScheduleCount { get; set; } + public string ScheduleType{ get; set; } + public bool HasSchedule { get; set; } + public string ScheduleUnitType { get; set; } + public string ScheduleUnitNumber { get; set; } + + + #endregion + } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/CreateTaskCancel.cs b/AccountManagement.Application.Contracts/Task/CreateTaskCancel.cs index b7e2ffee..a20c74c6 100644 --- a/AccountManagement.Application.Contracts/Task/CreateTaskCancel.cs +++ b/AccountManagement.Application.Contracts/Task/CreateTaskCancel.cs @@ -1,4 +1,6 @@ -namespace AccountManagement.Application.Contracts.Task; +using System.Security.AccessControl; + +namespace AccountManagement.Application.Contracts.Task; public class CreateTaskCancel { public long TaskId { get; set; } diff --git a/AccountManagement.Application.Contracts/Task/CreateTaskModal.cs b/AccountManagement.Application.Contracts/Task/CreateTaskModal.cs new file mode 100644 index 00000000..30064a53 --- /dev/null +++ b/AccountManagement.Application.Contracts/Task/CreateTaskModal.cs @@ -0,0 +1,19 @@ +using AccountManagement.Application.Contracts.Account; +using AccountManagement.Application.Contracts.Position; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AccountManagement.Application.Contracts.Task; +public class CreateTaskModal +{ + public CreateTask Command { get; set; } + public long TicketId{ get; set; } + public List AccountsList { get; set; } + public List PositionViewModels { get; set; } + public string DateFa { get; set; } + public long Id { get; set; } +} + diff --git a/AccountManagement.Application.Contracts/Task/EditTask.cs b/AccountManagement.Application.Contracts/Task/EditTask.cs index 7974ddb9..4c9f1fbc 100644 --- a/AccountManagement.Application.Contracts/Task/EditTask.cs +++ b/AccountManagement.Application.Contracts/Task/EditTask.cs @@ -1,5 +1,8 @@ using System.Collections.Generic; +using AccountManagement.Application.Contracts.Account; +using AccountManagement.Application.Contracts.Assign; using AccountManagement.Application.Contracts.Media; +using AccountManagement.Application.Contracts.Ticket; namespace AccountManagement.Application.Contracts.Task; public class EditTask:CreateTask @@ -8,5 +11,12 @@ public class EditTask:CreateTask public List medias { get; set; } public string? CompleteDescription { get; set; } public bool IsDone { get; set; } + public bool IsCancel { get; set; } + public string CreateDateFa { get; set; } public List DeletedFileIds { get; set; } + public List AssignViewModels { get; set; } + public AccountViewModel SenderViewModel { get; set; } + public EditTicket TicketViewModel { get; set; } + public long? TicketId { get; set; } + public List AssignsLists { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/ITaskApplication.cs b/AccountManagement.Application.Contracts/Task/ITaskApplication.cs index b2cf6640..9318f10e 100644 --- a/AccountManagement.Application.Contracts/Task/ITaskApplication.cs +++ b/AccountManagement.Application.Contracts/Task/ITaskApplication.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using _0_Framework.Application; using AccountManagement.Application.Contracts.Assign; +using AccountManagement.Application.Contracts.TaskMessage; using Microsoft.AspNetCore.Http; namespace AccountManagement.Application.Contracts.Task; @@ -11,44 +12,53 @@ public interface ITaskApplication OperationResult RemoveTask(long TaskId); OperationResult RemoveFile(long MediaId); OperationResult Edit(EditTask command); - OperationResult CreateAssign(CreateAssign command); - OperationResult CreateTask(CreateTask command); OperationResult CreateTaskByPosition(CreateTask command); - EditTask GetDetails(long taskId); + EditTask GetDetails(long taskId); //گرفتن تمامی وظایف List GetTasks(TaskSearchModel searchModel); List GetSelfTasks(TaskSearchModel searchModel); - List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel); + List GetAllTasks(TaskSearchModel searchModel); + //List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel); List GetReceivedTasks(TaskSearchModel searchModel); List GetSentTasks(TaskSearchModel searchModel); - // گرفتن مهلت برای یک وظیفه - OperationResult CreateRequestTime(CreateTaskTimeRequest command); + // گرفتن مهلت برای یک وظیفه + OperationResult CreateRequestTime(CreateTaskTimeRequest command); //تایید مهلت وظیفه - OperationResult AcceptRequestDatetime(long taskId); - OperationResult RejectTimeRequest(long taskId); + OperationResult AcceptRequestDatetime(long taskId, long assignedId,string message); + OperationResult RejectTimeRequest(long taskId, long assignedId, string message); + //درخواست انصراف وظیفه OperationResult CreateCancelRequest(CreateTaskCancel command); //تایید اانصراف وظیفه - OperationResult AcceptCancelRequest(long taskId); - OperationResult RejectCancelRequest(long taskId); + OperationResult AcceptCancelRequest(long taskId,long assignedId, string message); + OperationResult RejectCancelRequest(long taskId, long assignedId, string message); OperationResult CreateCompleteTaskRequest(CompleteTaskViewModel command); - OperationResult AcceptCompleteRequest(long taskId); - OperationResult RejectCompleteRequest(long taskId); + OperationResult AcceptCompleteRequest(long taskId, long assignedId, string message); + OperationResult RejectCompleteRequest(long taskId, long assignedId, string message); OperationResult CreateTaskByPosition(CreateTask command, List positionIds); List GetRequestedTasks(TaskSearchModel searchModel); List AllRequestedTasks(TaskSearchModel searchModel); int GetRequestedTasksCount(); + List GetTaskMessages(long assignId); - OperationResult ChangeRequestTimeAndAccept(string time,long taskId); - TaskViewModel GetRequestDetails(long id); - OperationResult UploadMedia(IFormFile mediaFile,long senderId); + OperationResult ChangeRequestTimeAndAccept(string time,long taskId,long assignedId, string message); + EditTask GetRequestDetails(long id); + OperationResult UploadMedia(IFormFile mediaFile, long senderId); OperationResult RemoveMedia(long mediaId); void RemoveTempUploadedFiles(long userId); + + OperationResult SendTicketResponseInTask(long assignId,string message,long ticketId); + + List GetAssignsByTaskId(long taskId); + + + //متد انتقال داده از تسک به ارجاعی ها + //OperationResult MoveDataFRomTaskToAssign(); } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Task/TaskViewModel.cs b/AccountManagement.Application.Contracts/Task/TaskViewModel.cs index 9cbafc26..f66b07a2 100644 --- a/AccountManagement.Application.Contracts/Task/TaskViewModel.cs +++ b/AccountManagement.Application.Contracts/Task/TaskViewModel.cs @@ -18,26 +18,22 @@ public class TaskViewModel public string EndTaskDateFA { get; set; } public string EndTaskTime { get; set; } public string RequestTaskDate { get; set; } - public bool IsDone { get; set; } public bool IsDoneRequest { get; set; } public string IsDoneDescription { get; set; } - - public bool RequestCancel { get; set; } + public bool RequestCancel { get; set; } public bool RequestTime { get; set; } public bool IsCancel { get; set; } public bool IsCancelRequest { get; set; } public string CancelDescription { get; set; } public int AcceptedTimeRequest { get; set; } public string TimeRequestDescription { get; set; } - - public DateTime EndTaskDateGE { get; set; } + public DateTime EndTaskDateGE { get; set; } public DateTime CreateTaskDateGE { get; set; } public string ContractingPartyName { get; set; } public string? Description { get; set; } public AccountViewModel Sender { get; set; } public string Assigner { get; set; } - public string SelfName { get; set; } public long SenderId { get; set; } public string Color { get; set; } @@ -52,5 +48,7 @@ public class TaskViewModel public bool CanDelete { get; set; } public bool CanAssign { get; set; } public bool CanCheckRequests { get; set; } + public AssignViewModel AssignedReceiverViewModel { get; set; } + } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/TaskMessage/CreateTaskMessage.cs b/AccountManagement.Application.Contracts/TaskMessage/CreateTaskMessage.cs new file mode 100644 index 00000000..b7f604b7 --- /dev/null +++ b/AccountManagement.Application.Contracts/TaskMessage/CreateTaskMessage.cs @@ -0,0 +1,9 @@ +namespace AccountManagement.Application.Contracts.TaskMessage; + +public class CreateTaskMessage +{ + public string Message { get; set; } + public long AssignId { get; set; } + public long SenderId { get; set; } + public long ReceiverId { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/TaskMessage/EditTaskMessage.cs b/AccountManagement.Application.Contracts/TaskMessage/EditTaskMessage.cs new file mode 100644 index 00000000..6129b1d3 --- /dev/null +++ b/AccountManagement.Application.Contracts/TaskMessage/EditTaskMessage.cs @@ -0,0 +1,6 @@ +namespace AccountManagement.Application.Contracts.TaskMessage; + +public class EditTaskMessage:CreateTaskMessage +{ + public long Id { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/TaskMessage/TaskMessageViewModel.cs b/AccountManagement.Application.Contracts/TaskMessage/TaskMessageViewModel.cs new file mode 100644 index 00000000..9a25249b --- /dev/null +++ b/AccountManagement.Application.Contracts/TaskMessage/TaskMessageViewModel.cs @@ -0,0 +1,14 @@ +using System.Security.Cryptography; + +namespace AccountManagement.Application.Contracts.TaskMessage; + +public class TaskMessageViewModel +{ + public string Message { get; set; } + public string SenderName { get; set; } + public long SenderId { get; set; } + public long ReceiverId { get; set; } + public string TypeOfMessage { get; set; } + public string RequestedDateFa { get; set; } + public string CreationDate { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/TaskSchedule/ITaskScheduleApplication.cs b/AccountManagement.Application.Contracts/TaskSchedule/ITaskScheduleApplication.cs new file mode 100644 index 00000000..a67e9ac8 --- /dev/null +++ b/AccountManagement.Application.Contracts/TaskSchedule/ITaskScheduleApplication.cs @@ -0,0 +1,12 @@ +using _0_Framework.Application; +using AccountManagement.Application.Contracts.Task; + +namespace AccountManagement.Application.Contracts.TaskSchedule; + +public interface ITaskScheduleApplication +{ + OperationResult Create(CreateTask command); + OperationResult CreateLimitedTasks(CreateTask command); + OperationResult CreateUnlimitedTasks(CreateTask command); + +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/AdminResponseViewModel.cs b/AccountManagement.Application.Contracts/Ticket/AdminResponseViewModel.cs index bc15c709..0bf58190 100644 --- a/AccountManagement.Application.Contracts/Ticket/AdminResponseViewModel.cs +++ b/AccountManagement.Application.Contracts/Ticket/AdminResponseViewModel.cs @@ -1,11 +1,17 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using AccountManagement.Application.Contracts.Media; namespace AccountManagement.Application.Contracts.Ticket; public class AdminResponseViewModel { + public long Id { get; set; } + public string FullName { get; set; } + public string IsActive { get; set; } public long TicketId { get; set; } public string Response { get; set; } + public long AdminAccountId { get; set; } + public DateTime CreationDate { get; set; } public List MediaViewModels { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs b/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs index 5821c6e1..ce17caec 100644 --- a/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs +++ b/AccountManagement.Application.Contracts/Ticket/CreateTicket.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Microsoft.AspNetCore.Http; namespace AccountManagement.Application.Contracts.Ticket; @@ -12,5 +13,7 @@ public class CreateTicket public string TicketType { get; set; } public List UploadedMediaIds { get; set; } public long ScreenShotId { get; set; } - public long VoiceId { get; set; } + public long VoiceId { get; set; } + public DateTime CreationDate { get; set; } + public long WorkshopId { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/CreateTicketViewModel.cs b/AccountManagement.Application.Contracts/Ticket/CreateTicketViewModel.cs new file mode 100644 index 00000000..a7c691e4 --- /dev/null +++ b/AccountManagement.Application.Contracts/Ticket/CreateTicketViewModel.cs @@ -0,0 +1,10 @@ +namespace AccountManagement.Application.Contracts.Ticket; + +public class CreateTicketViewModel +{ + public string FullName { get; set; } + public string CreateDate { get; set; } + public string WorkshopName { get; set; } + public string PhoneNumber { get; set; } + +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/EditTicket.cs b/AccountManagement.Application.Contracts/Ticket/EditTicket.cs index 77ec0ae0..84327f00 100644 --- a/AccountManagement.Application.Contracts/Ticket/EditTicket.cs +++ b/AccountManagement.Application.Contracts/Ticket/EditTicket.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using AccountManagement.Application.Contracts.Account; using AccountManagement.Application.Contracts.Media; namespace AccountManagement.Application.Contracts.Ticket; @@ -7,6 +8,12 @@ public class EditTicket:CreateTicket { public long Id { get; set; } public List MediaViewModels { get; set; } - public List AdminResponseViewModels{ get; set; } + public List ResponseViewModels { get; set; } + public List AdminResponseViewModels{ get; set; } public List ClientResponseViewModels { get; set; } + public AccountViewModel Sender { get; set; } + public string WorkshopName { get; set; } + public string TicketNumber { get; set; } + public string CreationDateStr { get; set; } + public string Status { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs b/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs index b4095f5a..64878bee 100644 --- a/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs +++ b/AccountManagement.Application.Contracts/Ticket/ITicketApplication.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using _0_Framework.Application; using AccountManagement.Application.Contracts.Task; +using Microsoft.AspNetCore.Http; namespace AccountManagement.Application.Contracts.Ticket; @@ -12,6 +13,21 @@ public interface ITicketApplication OperationResult AdminResponseTicket(ResponseTicket command); OperationResult ClientResponseTicket(ResponseTicket command); EditTicket GetDetails(long id); + EditTicket GetDetailsForClient(long id); List GetAll(TicketSearchModel searchModel); bool IsExist(long id); + OperationResult UploadMedia(IFormFile mediaFile, long senderId); + OperationResult RemoveMedia(long mediaId); + void RemoveTempUploadedFiles(long userId); + List GetTicketsForClients(TicketSearchModel searchModel); + + OperationResult AcceptPendingAdminResponse(long adminResId); + OperationResult RejectPendingAdminResponse(long adminResId); + OperationResult EditAndAcceptPendingAdminResponse(long adminResId,string newResponse); + OperationResult DeletePendingAdminResponse(int adminResId); + OperationResult EditPendingAdminResponse(long adminResId, string newMessage); + OperationResult CloseTicket(long ticketId); + + + } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/Response.cs b/AccountManagement.Application.Contracts/Ticket/Response.cs index 5b09069a..9604fdeb 100644 --- a/AccountManagement.Application.Contracts/Ticket/Response.cs +++ b/AccountManagement.Application.Contracts/Ticket/Response.cs @@ -8,9 +8,16 @@ using System.Threading.Tasks; namespace AccountManagement.Application.Contracts.Ticket; public class Response { + public long AdminResponseId { get; set; } + public long ClientResponseId { get; set; } public long TicketId { get; set; } + public string FullName { get; set; } public string ResponseMessage { get; set; } public bool IsAdmin { get; set; } public bool IsClient { get; set; } + public string IsActive { get; set; } + public long AdminAccountId { get; set; } public List MediaViewModels { get; set; } + public DateTime CreationDate { get; set; } + public string CreationDateStr { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs b/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs index a233e0d9..bca66c91 100644 --- a/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs +++ b/AccountManagement.Application.Contracts/Ticket/ResponseTicket.cs @@ -6,6 +6,7 @@ public class ResponseTicket { public long TicketId { get; set; } public string Response { get; set; } + public long AdminId { get; set; } public List UploadedFileIds { get; set; } public long VoiceId { get; set; } } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/Ticket/TicketSearchModel.cs b/AccountManagement.Application.Contracts/Ticket/TicketSearchModel.cs index 074e9689..57cd63ba 100644 --- a/AccountManagement.Application.Contracts/Ticket/TicketSearchModel.cs +++ b/AccountManagement.Application.Contracts/Ticket/TicketSearchModel.cs @@ -2,6 +2,14 @@ public class TicketSearchModel { + public int PageIndex { get; set; } + + public string TicketNumber { get; set; } + + public long WorkshopId { get; set; } + + public long ClientAccountId { get; set; } + public string StartDate { get; set; } public string EndDate { get; set; } @@ -10,11 +18,7 @@ public class TicketSearchModel public string OneDay { get; set; } - public string IsAssigned { get; set; } - - public string TypeOfTicket { get; set; } - - public string Title { get; set; } + public string GeneralSearch { get; set; } public string Status { get; set; } diff --git a/AccountManagement.Application.Contracts/Ticket/TicketViewModel.cs b/AccountManagement.Application.Contracts/Ticket/TicketViewModel.cs index 123a2681..33e2f08f 100644 --- a/AccountManagement.Application.Contracts/Ticket/TicketViewModel.cs +++ b/AccountManagement.Application.Contracts/Ticket/TicketViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Security.AccessControl; namespace AccountManagement.Application.Contracts.Ticket; @@ -11,5 +12,10 @@ public class TicketViewModel:EditTicket public string CreationDateTime { get; set; } public DateTime CreationDateTimeGr { get; set; } public long? TaskId { get; set; } + public bool HasTask { get; set; } + public string RawTicketNumber { get; set; } + public int PageIndex { get; set; } + + } \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/TicketAccessAccount/ITicketAccessAccountApplication.cs b/AccountManagement.Application.Contracts/TicketAccessAccount/ITicketAccessAccountApplication.cs new file mode 100644 index 00000000..c8ba6b33 --- /dev/null +++ b/AccountManagement.Application.Contracts/TicketAccessAccount/ITicketAccessAccountApplication.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Runtime.InteropServices.ComTypes; +using _0_Framework.Application; +using AccountManagement.Application.Contracts.Account; + +namespace AccountManagement.Application.Contracts.TicketAccessAccount; + +public interface ITicketAccessAccountApplication +{ + bool HasTicketAccess(long accountId); + OperationResult Create(long accountId); + OperationResult Delete(long id); + List GetAllAccessedAccounts(); +} \ No newline at end of file diff --git a/AccountManagement.Application.Contracts/TicketAccessAccount/TicketAccessAccountViewModel.cs b/AccountManagement.Application.Contracts/TicketAccessAccount/TicketAccessAccountViewModel.cs new file mode 100644 index 00000000..0036aab3 --- /dev/null +++ b/AccountManagement.Application.Contracts/TicketAccessAccount/TicketAccessAccountViewModel.cs @@ -0,0 +1,9 @@ +namespace AccountManagement.Application.Contracts.TicketAccessAccount; + +public class TicketAccessAccountViewModel +{ + public long Id { get; set; } + public long AccountId { get; set; } + public string Name { get; set; } + public string CreateDateFa { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Application/AccountApplication.cs b/AccountManagement.Application/AccountApplication.cs index 23fcacd0..52004db4 100644 --- a/AccountManagement.Application/AccountApplication.cs +++ b/AccountManagement.Application/AccountApplication.cs @@ -444,15 +444,15 @@ public class AccountApplication : IAccountApplication { return this._accountLeftworkRepository.SaveWorkshopAccount(workshopAccountList, startDate, leftDate, accountId); } - public OperationResult CreateNewWorkshopAccount(long currentAccountId, long newAccountId) { return this._accountLeftworkRepository.CopyWorkshopToNewAccount(currentAccountId, newAccountId); } + #region Mahan - public List AccountsForAssign(long accountId) + public List AccountsForAssign(long taskId) { - return _accountRepository.AccountsForAssign(accountId); + return _accountRepository.AccountsForAssign(taskId); } public List GetAccountsByPositionId(long positionId) @@ -471,25 +471,28 @@ public class AccountApplication : IAccountApplication public OperationResult ReLogin() { - var prAcc = _authHelper.CurrentAccountInfo(); - var operation = new OperationResult(); - var account = _accountRepository.GetIncludePositions(prAcc.Id); - if (account == null) - return operation.Failed("این اکانت وجود ندارد"); + var prAcc = _authHelper.CurrentAccountInfo(); + var operation = new OperationResult(); + var account = _accountRepository.GetIncludePositions(prAcc.Id); + if (account == null) + return operation.Failed("این اکانت وجود ندارد"); - var permissions = _roleRepository.Get(account.RoleId) - .Permissions - .Select(x => x.Code) - .ToList(); + var permissions = _roleRepository.Get(account.RoleId) + .Permissions + .Select(x => x.Code) + .ToList(); - _authHelper.SignOut(); - var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname - , account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, account.AdminAreaPermission, account.ClientAriaPermission, account.Position.PositionValue); - _authHelper.Signin(authViewModel); - return operation.Succcedded(2); + _authHelper.SignOut(); + var authViewModel = new AuthViewModel(account.id, account.RoleId, account.Fullname + , account.Username, account.Mobile, account.ProfilePhoto, permissions, account.RoleName, account.AdminAreaPermission, account.ClientAriaPermission, account.Position.PositionValue); + _authHelper.Signin(authViewModel); + return operation.Succcedded(2); + + } + + #endregion - } } \ No newline at end of file diff --git a/AccountManagement.Application/AccountManagement.Application.csproj b/AccountManagement.Application/AccountManagement.Application.csproj index cab6f7be..7fcb4ebe 100644 --- a/AccountManagement.Application/AccountManagement.Application.csproj +++ b/AccountManagement.Application/AccountManagement.Application.csproj @@ -7,6 +7,7 @@ + diff --git a/AccountManagement.Application/PositionApplication.cs b/AccountManagement.Application/PositionApplication.cs index decf6050..8f7e969a 100644 --- a/AccountManagement.Application/PositionApplication.cs +++ b/AccountManagement.Application/PositionApplication.cs @@ -3,21 +3,24 @@ using _0_Framework.Application; using AccountManagement.Application.Contracts.Account; using AccountManagement.Application.Contracts.Position; using AccountManagement.Domain.AccountAgg; +using AccountManagement.Domain.AssignAgg; using TaskManager.Domain.PositionAgg; namespace TaskManager.Application; -public class PositionApplication:IPositionApplication +public class PositionApplication : IPositionApplication { private readonly IPositionRepository _positionRepository; private readonly IAccountRepository _accountRepository; private readonly IAccountApplication _accountApplication; + private readonly IAssignRepository _assignRepository; - public PositionApplication(IPositionRepository positionRepository, IAccountRepository accountRepository, IAccountApplication accountApplication) + public PositionApplication(IPositionRepository positionRepository, IAccountRepository accountRepository, IAccountApplication accountApplication, IAssignRepository assignRepository) { _positionRepository = positionRepository; _accountRepository = accountRepository; _accountApplication = accountApplication; + _assignRepository = assignRepository; } //ساخت پوزیشن public OperationResult Create(CreatePosition command) @@ -29,18 +32,18 @@ public class PositionApplication:IPositionApplication } - if (command.Value==0) + if (command.Value == 0) { return operation.Failed("لطفا سطح سمت را وارد کنید"); } - if (command.Value>5) + if (command.Value > 5) { return operation.Failed(" سطح سمت وارد شده معتبر نمیباشد"); } - if (_positionRepository.Exists(x=>x.PositionValue==command.Value)) + if (_positionRepository.Exists(x => x.PositionValue == command.Value)) { return operation.Failed("سطح انتخاب شده قبلا تعریف شده است"); } @@ -54,12 +57,12 @@ public class PositionApplication:IPositionApplication public OperationResult SaveAccountPosition(List accountIds, long positionId) { var operation = new OperationResult(); - if (!_positionRepository.Exists(x=>x.id==positionId)) + if (!_positionRepository.Exists(x => x.id == positionId)) { return operation.Failed("چنین سمتی وجود ندارد"); } - if (accountIds.Count<1) + if (accountIds.Count < 1) { return operation.Failed("لطفا شخصی برای ذخیره انتخاب کنید"); } @@ -80,21 +83,31 @@ public class PositionApplication:IPositionApplication public List GetUnUsedPositionValues() { - return _positionRepository.GetUnUsedPositionValues(); + return _positionRepository.GetUnUsedPositionValues(); } public OperationResult Remove(long id) { var operation = new OperationResult(); - if (!_positionRepository.Exists(x=>x.id==id)) + if (!_positionRepository.Exists(x => x.id == id)) { - return operation.Failed("سمت مورد نظر یافت نشد"); + return operation.Failed("گروه مورد نظر یافت نشد"); } - if (_accountApplication.GetAccountsByPositionId(id).Count>0) + if (_accountApplication.GetAccountsByPositionId(id).Count > 0) { - return operation.Failed("شما نمیتوانید سمتی که در آن شخصی وجود دارد را حذف کنید."); + return operation.Failed("شما نمیتوانید گروهی که در آن شخصی وجود دارد را حذف کنید."); + } + var deActives = _accountRepository.GetAccountsDeactivePositionValue(id); + + if (deActives?.Count > 0) + { + foreach (var acc in deActives) + { + var account = _accountRepository.Get(acc.Id); + account.RemovePosition(); + } } _positionRepository.Remove(id); @@ -105,7 +118,7 @@ public class PositionApplication:IPositionApplication public OperationResult Edit(EditPosition command) { var operation = new OperationResult(); - if (_positionRepository.Exists(x=>x.id!=command.Id&&x.PositionName==command.Name)) + if (_positionRepository.Exists(x => x.id != command.Id && x.PositionName == command.Name)) { return operation.Failed("سمتی با این نام وجود دارد"); } @@ -115,13 +128,13 @@ public class PositionApplication:IPositionApplication } var position = _positionRepository.Get(command.Id); - position.Edit(command.Name,command.Value); + position.Edit(command.Name, command.Value); _positionRepository.SaveChanges(); return operation.Succcedded(command.Id); } //گرفتن تمامی پوزیشن ها برای نمایش - public List GetPositions()=> + public List GetPositions() => _positionRepository.GetPositions(); //ذخیره پوزیشن public OperationResult Save() @@ -132,7 +145,7 @@ public class PositionApplication:IPositionApplication //حذف یک شخص از یک گروه public OperationResult RemoveAccountFromPosition(long positionId, long AccountId) { - var operation=new OperationResult(); + var operation = new OperationResult(); if (!_accountRepository.Exists(x => x.id == AccountId)) { return operation.Failed("چنین شخصی وجود ندارد"); @@ -142,19 +155,24 @@ public class PositionApplication:IPositionApplication { return operation.Failed("چنین شخصی در این گروه وجود ندارد"); } - account.DeletePositionId(); + account.DeActivePosition(); _positionRepository.SaveChanges(); - - return operation.Succcedded(); + + return operation.Succcedded(); } //حذف یک لیستی از اشخاص از یک گروه public OperationResult RemoveAccountListFromPosition(List accountIdList, long PositionId) { - var operation= new OperationResult(); + var operation = new OperationResult(); foreach (var account in accountIdList) { var acc = _accountRepository.GetIncludePositions(account); - acc.DeletePositionId(); + if (_assignRepository.Exists(x => x.AssignerId == acc.id || x.AssignedId == acc.id)) + acc.DeActivePosition(); + + else + + acc.RemovePosition(); } _accountRepository.SaveChanges(); return operation.Succcedded(); diff --git a/AccountManagement.Application/TaskApplication.cs b/AccountManagement.Application/TaskApplication.cs index 1bc26aec..c264deac 100644 --- a/AccountManagement.Application/TaskApplication.cs +++ b/AccountManagement.Application/TaskApplication.cs @@ -1,7 +1,6 @@ using _0_Framework.Application; using System; using System.Collections.Generic; -using System.Data.OleDb; using System.IO; using System.Linq; using AccountManagement.Application.Contracts.Assign; @@ -10,12 +9,13 @@ using AccountManagement.Domain.AccountAgg; using AccountManagement.Domain.AssignAgg; using AccountManagement.Domain.MediaAgg; using AccountManagement.Domain.TaskAgg; -using IPE.SmsIrClient.Models.Results; using TaskManager.Domain.PositionAgg; -using System.Reflection; - using Microsoft.AspNetCore.Http; using System.Globalization; +using AccountManagement.Application.Contracts.TaskMessage; +using AccountManagement.Domain.AdminResponseAgg; +using AccountManagement.Domain.TaskMessageAgg; +using AccountManagement.Domain.TicketAgg; namespace AccountManagement.Application; @@ -27,11 +27,13 @@ public class TaskApplication : ITaskApplication private readonly IPositionRepository _positionRepository; private readonly IAssignRepository _assignRepository; private readonly IHttpContextAccessor _contextAccessor; - + private readonly ITaskMessageRepository _taskMessageRepository; + private readonly ITicketRepository _ticketRepository; + private readonly IAuthHelper _authHelper; - public TaskApplication(ITaskRepository taskRepository, IAccountRepository accountRepository, IMediaRepository mediaRepository, IAssignRepository assignRepository, IHttpContextAccessor contextAccessor, IPositionRepository positionRepository, IAuthHelper authHelper) + public TaskApplication(ITaskRepository taskRepository, IAccountRepository accountRepository, IMediaRepository mediaRepository, IAssignRepository assignRepository, IHttpContextAccessor contextAccessor, IPositionRepository positionRepository, IAuthHelper authHelper, ITaskMessageRepository taskMessageRepository, ITicketRepository ticketRepository) { _taskRepository = taskRepository; _accountRepository = accountRepository; @@ -39,8 +41,9 @@ public class TaskApplication : ITaskApplication _assignRepository = assignRepository; _contextAccessor = contextAccessor; _positionRepository = positionRepository; - _authHelper = authHelper; + _taskMessageRepository = taskMessageRepository; + _ticketRepository = ticketRepository; } //غیرفعال سازی تسک public OperationResult DeActiveTask(long TaskId) @@ -67,6 +70,7 @@ public class TaskApplication : ITaskApplication } var task = _taskRepository.Get(TaskId); + var assigns = _assignRepository.GetAssignsByTaskId(TaskId); var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); var sender = _accountRepository.GetIncludePositions(task.SenderId); if (sender.Position.PositionValue < positionValue) @@ -74,7 +78,7 @@ public class TaskApplication : ITaskApplication return operation.Failed("شما نمیتواند وظیفه ای که سطحی از شما پایین تر دارد را حذف کنید"); } var medias = _mediaRepository.GetMediaByTaskId(TaskId); - if (task.IsCanceledRequest || task.IsDone || task.IsCancel || task.TimeRequest || task.AcceptedTimeRequest > 0) + if (assigns.Any(x => x.IsCanceledRequest || x.IsDone || x.IsCancel || x.TimeRequest || x.AcceptedTimeRequest > 0)) { task.DeActive(); } @@ -114,22 +118,18 @@ public class TaskApplication : ITaskApplication { return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید"); } - if (string.IsNullOrEmpty(command.EndTaskDate)) { return operation.Failed("لطفا تاریخ انجام وظیفه را وارد کنید"); } - if (command.ReceiverId.Count < 1) { return operation.Failed("طرف وظیفه خود را وارد کنید"); } - if (command.SenderId < 1) { return operation.Failed("خطای سیستمی!!!"); } - var sender = _accountRepository.GetIncludePositions(command.SenderId); if (sender.Position.PositionValue < posValue) { @@ -167,14 +167,14 @@ public class TaskApplication : ITaskApplication return operation.Failed("لطفا تاریخ را به درستی وارد کنید"); } - task.Edit(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName); + task.Edit(command.Title, command.Description, command.SenderId, command.ContractingPartyName); _taskRepository.SaveChanges(); _assignRepository.RemoveRangeAssigns(task.id); foreach (var receiver in receivers) { var assign = new Assign(task.id, task.SenderId, receiver.id, sender.Position.PositionValue, receiver.Fullname, - receiver.Position.PositionValue); + receiver.Position.PositionValue, endTask); _assignRepository.Create(assign); } _assignRepository.SaveChanges(); @@ -184,53 +184,19 @@ public class TaskApplication : ITaskApplication #region SaveDocuments - if (command.UploadedMedia?.Count>0) + if (command.UploadedMedia?.Count > 0) { foreach (var mediaId in command.UploadedMedia) { - var media = _mediaRepository.Get(mediaId); - var oldPath = media.Path; - var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - - - string filepath = Path.Combine(path, Path.GetFileName(oldPath)); - File.Move(oldPath, filepath); - - media.Edit(filepath, media.Type, media.Category); - - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + MoveTaskFile(mediaId, task.id); } } - - - - #endregion - - if (command.UploadedVoiceMedia > 0) { - var media = _mediaRepository.Get(command.UploadedVoiceMedia); - var oldPath = media.Path; - var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - - - string filepath = Path.Combine(path, Path.GetFileName(oldPath)); - File.Move(oldPath, filepath); - - media.Edit(filepath, media.Type, "صوت"); - - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + MoveTaskFile(command.UploadedVoiceMedia, task.id, "voice"); } #region DeleteMedias @@ -269,6 +235,28 @@ public class TaskApplication : ITaskApplication return operation.Failed("خطای سیستمی!!"); } + var assignEntity = _assignRepository.GetAssignByAssignedIdAndTaskId(command.AssignerId, command.TaskId); + var now = DateTime.Now; + if (assignEntity.EndTaskDate < now) + { + operation.Failed("شما نمیتوانید وظیفه ای که مهلت آن گذشته است را به کسی ارجاع دهید"); + } + + if (_assignRepository.Exists(x => x.TaskId == command.TaskId && command.AssignedId.Contains(x.AssignedId))) + { + var assignedIdsInDataBase = _assignRepository.GetAssignedIdsByTaskId(command.TaskId); + var similarIds = assignedIdsInDataBase.Intersect(command.AssignedId).ToList(); + var assignedAccounts = _accountRepository.GetAccountsByIds(similarIds); + string accNames = ""; + foreach (var account in assignedAccounts) + { + accNames = accNames + account.Fullname + "،"; + + } + return operation.Failed($"به اشخاص {accNames} قبلا این تسک ارجاع داده شده است"); + } + + foreach (var assignedId in command.AssignedId) { if (!_accountRepository.Exists(x => x.id == assignedId)) @@ -278,13 +266,19 @@ public class TaskApplication : ITaskApplication } + + + var task = _taskRepository.Get(command.TaskId); + + var endOfDayDateTime = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59); + + var assigner = _accountRepository.GetIncludePositions(command.AssignerId); foreach (var assignedId in command.AssignedId) { var assigned = _accountRepository.GetIncludePositions(assignedId); - var assign = new Assign(command.TaskId, command.AssignerId, assignedId, assigner.Position.PositionValue, - assigned.Fullname, assigned.Position.PositionValue); + assigned.Fullname, assigned.Position.PositionValue, endOfDayDateTime); _assignRepository.Create(assign); } _assignRepository.SaveChanges(); @@ -296,8 +290,9 @@ public class TaskApplication : ITaskApplication var operation = new OperationResult(); if (string.IsNullOrEmpty(command.Title)) { - return operation.Failed("لطفا عنوان وظیفه خود ار وارد کنید"); + return operation.Failed("لطفا عنوان وظیفه خود را وارد کنید"); } + var now = DateTime.Now.Date; if (string.IsNullOrEmpty(command.EndTaskDate)) { @@ -305,11 +300,9 @@ public class TaskApplication : ITaskApplication return operation.Failed("لطفا تاریخ انجام وظیفه را وارد کنید"); } - - if (string.IsNullOrEmpty(command.ContractingPartyName)) { - return operation.Failed("لطفا طرف حساب خودرا وارد کنید"); + return operation.Failed("لطفا طرف حساب خود را وارد کنید"); } @@ -361,8 +354,6 @@ public class TaskApplication : ITaskApplication { } - - var endTask = string.IsNullOrWhiteSpace(command.EndTaskTime) || command.EndTaskTime == "00:00" ? command.EndTaskDate.ToGeorgianDateTime2() : command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime); var errorDateTime = new DateTime(3000, 12, 20, new PersianCalendar()); @@ -375,65 +366,34 @@ public class TaskApplication : ITaskApplication { return operation.Failed("لطفا تاریخ آینده را وارد کنید"); } - var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName); + var task = new Tasks(command.Title, command.Description, command.SenderId, command.ContractingPartyName); _taskRepository.Create(task); _assignRepository.SaveChanges(); foreach (var receiver in receivers) { var assign = new Assign(task.id, task.SenderId, receiver.id, sender.Position.PositionValue, receiver.Fullname, - receiver.Position.PositionValue); + receiver.Position.PositionValue, endTask); _assignRepository.Create(assign); } - - #region SaveMedias #region SaveDocuments if (command.UploadedMedia?.Count > 0) - { - foreach (var mediaId in command.UploadedMedia) - { - var media = _mediaRepository.Get(mediaId); - var oldPath = media.Path; - var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); + { + foreach (var mediaId in command.UploadedMedia) + { + MoveTaskFile(mediaId, task.id); + } + } - - string filepath = Path.Combine(path, Path.GetFileName(oldPath)); - File.Move(oldPath, filepath); - - media.Edit(filepath, media.Type, media.Category); - - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - } - } - - #endregion if (command.UploadedVoiceMedia > 0) { - var media = _mediaRepository.Get(command.UploadedVoiceMedia); - var oldPath = media.Path; - var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - - - string filepath = Path.Combine(path, Path.GetFileName(oldPath)); - File.Move(oldPath, filepath); - - media.Edit(filepath, media.Type, "صوت"); - - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); - + MoveTaskFile(command.UploadedVoiceMedia, task.id, "voice"); } #endregion @@ -446,7 +406,7 @@ public class TaskApplication : ITaskApplication var operation = new OperationResult(); var sender = _accountRepository.GetIncludePositions(command.SenderId); - var receivers = _positionRepository.GetAccountsByIds(command.PositionId); + var receivers = _positionRepository.GetAccountsByPositionIds(command.PositionId); if (sender.Position.PositionValue == 1) @@ -461,9 +421,6 @@ public class TaskApplication : ITaskApplication { } - - - DateTime endTask; if (string.IsNullOrWhiteSpace(command.EndTaskTime)) { @@ -474,62 +431,33 @@ public class TaskApplication : ITaskApplication endTask = command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime); } - - - var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName); + var task = new Tasks(command.Title, command.Description, command.SenderId, command.ContractingPartyName); _taskRepository.Create(task); _assignRepository.SaveChanges(); foreach (var receiver in receivers) { var assign = new Assign(task.id, task.SenderId, receiver.id, sender.Position.PositionValue, receiver.Fullname, - receiver.Position.PositionValue); + receiver.Position.PositionValue, endTask); _assignRepository.Create(assign); } - - #region SaveMedias #region SaveDocuments - foreach (var mediaId in command.UploadedMedia) + if (command.UploadedMedia?.Count > 0) { - var media = _mediaRepository.Get(mediaId); - var oldPath = media.Path; - var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - - - string filepath = Path.Combine(path, Path.GetFileName(oldPath)); - File.Move(oldPath, filepath); - - media.Edit(filepath, media.Type, media.Category); - - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + foreach (var mediaId in command.UploadedMedia) + { + MoveTaskFile(mediaId, task.id); + } } #endregion if (command.UploadedVoiceMedia > 0) { - var media = _mediaRepository.Get(command.UploadedVoiceMedia); - var oldPath = media.Path; - var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", - "Task", $"{task.id}"); - Directory.CreateDirectory(path); - - - - string filepath = Path.Combine(path, Path.GetFileName(oldPath)); - File.Move(oldPath, filepath); - - media.Edit(filepath, media.Type, "صوت"); - - _mediaRepository.SaveChanges(); - _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); + MoveTaskFile(command.UploadedVoiceMedia, task.id, "voice"); } @@ -539,7 +467,7 @@ public class TaskApplication : ITaskApplication return operation.Succcedded(task.id); } - // ویرایش تسک + // جزئیات تسک public EditTask GetDetails(long taskId) { return _taskRepository.GetDetails(taskId); @@ -558,11 +486,16 @@ public class TaskApplication : ITaskApplication return _taskRepository.GetSelfTasks(searchModel); } - public List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel) + public List GetAllTasks(TaskSearchModel searchModel) { - return _taskRepository.GetAllNotSelfIncludedTasks(searchModel); + return _taskRepository.GetAllTasks(searchModel); } + //public List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel) + //{ + // return _taskRepository.GetAllNotSelfIncludedTasks(searchModel); + //} + public List GetReceivedTasks(TaskSearchModel searchModel) { return _taskRepository.GetReceivedTasks(searchModel); @@ -594,7 +527,7 @@ public class TaskApplication : ITaskApplication } - var task = _taskRepository.Get(command.TaskId); + var task = _taskRepository.GetIncludeAssign(command.TaskId); var requestTime = command.RequestTime.ToGeorgianDateTime(); var errorDateTime = new DateTime(3000, 12, 20, new PersianCalendar()); if (requestTime == errorDateTime) @@ -603,39 +536,91 @@ public class TaskApplication : ITaskApplication } if (task.SenderId == accountId) { - task.ChangeTimeTask(requestTime); + foreach (var assign in task.Assigns) + { + assign.ChangeTimeTask(requestTime); + var message = new TaskMessage(command.Description, "تغییر تاریخ", assign.id); + _taskMessageRepository.Create(message); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assign.AssignedId, message.id); + } + _taskMessageRepository.SaveChanges(); + } else { - task.CreateTimeRequest(requestTime, command.Description); + var assign = _assignRepository.GetAssignByAssignedIdAndTaskId(accountId, command.TaskId); + assign.CreateTimeRequest(requestTime, command.Description); + var message = new TaskMessage(command.Description, "درخواست مهلت", assign.id, command.RequestTime); + _taskMessageRepository.Create(message); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assign.Task.SenderId, message.id); + } _taskRepository.SaveChanges(); return operation.Succcedded(task.id); } //تایید درخواست مهلت - public OperationResult AcceptRequestDatetime(long taskId) + public OperationResult AcceptRequestDatetime(long taskId, long assignedId, string message) { + var accountId = _authHelper.CurrentAccountId(); var operation = new OperationResult(); if (!_taskRepository.Exists(x => x.id == taskId)) { return operation.Failed("چنین وظیفه ای وجود ندارد"); } - var task = _taskRepository.Get(taskId); - if (!task.TimeRequest) + var assign = _assignRepository.GetAssignByAssignedIdAndTaskId(assignedId, taskId); + if (!assign.TimeRequest) { return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد"); } - if (task.RequestDate == null) + if (assign.RequestDate == null) { return operation.Failed("تاریخی برای درخواست وظیفه ثبت نشده است"); } - task.AcceptTimeRequest(); - _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); + assign.AcceptTimeRequest(); + message = string.IsNullOrWhiteSpace(message) ? "درخواست شما مورد تایید قرار گرفت" : message; + var messageEntity = new TaskMessage(message, "تایید درخواست مهلت", assign.id); + _taskMessageRepository.Create(messageEntity); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assignedId, messageEntity.id); + _assignRepository.SaveChanges(); + return operation.Succcedded(taskId); } + //لغو درخواست مهلت تسک + public OperationResult RejectTimeRequest(long taskId, long assignedId, string message) + { + var accountId = _authHelper.CurrentAccountId(); + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == taskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + + var assign = _assignRepository.GetAssignByAssignedIdAndTaskId(assignedId, taskId); + if (!assign.TimeRequest) + { + return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد"); + } + assign.RejectTimeRequest(); + if (assign.EndTaskDate.Date <= DateTime.Now.Date) + { + var now = DateTime.Now; + var endOfDay = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59); + assign.EditTime(endOfDay); + } + + var messageEntity = new TaskMessage(message, "رد درخواست مهلت", assign.id); + _taskMessageRepository.Create(messageEntity); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assignedId, messageEntity.id); + _assignRepository.SaveChanges(); + return operation.Succcedded(taskId); + } + //ساخت درخواست کنسل public OperationResult CreateCancelRequest(CreateTaskCancel command) { @@ -650,120 +635,188 @@ public class TaskApplication : ITaskApplication { return operation.Failed("چنین وظیفه ای وجود ندارد"); } - var task = _taskRepository.Get(command.TaskId); - task.CreateCancelRequest(command.Description); + var task = _taskRepository.GetIncludeAssign(command.TaskId); + + + if (task.SenderId == accountId) { - task.AcceptCancelRequest(); + foreach (var assign in task.Assigns) + { + assign.CreateCancelRequest(command.Description); + assign.AcceptCancelRequest(); + var message = new TaskMessage(command.Description, "لغو", assign.id); + _taskMessageRepository.Create(message); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assign.AssignedId, message.id); + + } + _taskMessageRepository.SaveChanges(); } - _taskRepository.SaveChanges(); + else + { + var assign = _assignRepository.GetAssignByAssignedIdAndTaskId(accountId, task.id); + assign.CreateCancelRequest(command.Description); + var message = new TaskMessage(command.Description, "درخواست کنسل", assign.id); + _taskMessageRepository.Create(message); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assign.Task.SenderId, message.id); + } + _assignRepository.SaveChanges(); return operation.Succcedded(task.id); } //تایید درخواست کنسل - public OperationResult AcceptCancelRequest(long taskId) + public OperationResult AcceptCancelRequest(long taskId, long assignedId, string message) { + var accountId = _authHelper.CurrentAccountId(); var operation = new OperationResult(); if (!_taskRepository.Exists(x => x.id == taskId)) { return operation.Failed("چنین وظیفه ای وجود ندارد"); } - var task = _taskRepository.Get(taskId); - if (!task.IsCanceledRequest) + var assign = _assignRepository.GetAssignByAssignedIdAndTaskId(assignedId, taskId); + if (!assign.IsCanceledRequest) { return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد"); } - task.AcceptCancelRequest(); - _taskRepository.SaveChanges(); + assign.AcceptCancelRequest(); + message = string.IsNullOrWhiteSpace(message) ? "درخواست شما مورد تایید قرار گرفت" : message; + var messageEntity = new TaskMessage(message, "تایید درخواست کنسل", assign.id); + _taskMessageRepository.Create(messageEntity); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assignedId, messageEntity.id); + _assignRepository.SaveChanges(); return operation.Succcedded(taskId); } + //لغو درخواست کنسل تسک + public OperationResult RejectCancelRequest(long taskId, long assignedId, string message) + { + var accountId = _authHelper.CurrentAccountId(); + var operation = new OperationResult(); + if (!_taskRepository.Exists(x => x.id == taskId)) + { + return operation.Failed("چنین وظیفه ای وجود ندارد"); + } + var assign = _assignRepository.GetAssignByAssignedIdAndTaskId(assignedId, taskId); + if (!assign.IsCanceledRequest) + { + return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد"); + } + assign.RejectCancel(); + if (assign.EndTaskDate.Date <= DateTime.Now.Date) + { + var now = DateTime.Now; + var endOfDay = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59); + assign.EditTime(endOfDay); + } + var messageEntity = new TaskMessage(message, "رد درخواست کنسل", assign.id); + _taskMessageRepository.Create(messageEntity); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assignedId, messageEntity.id); + _assignRepository.SaveChanges(); + return operation.Succcedded(taskId); + } + //انجام شدن تسک public OperationResult CreateCompleteTaskRequest(CompleteTaskViewModel command) { var accountId = _authHelper.CurrentAccountId(); var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == command.Id)) + if (!_taskRepository.Exists(x => x.id == command.TaskId)) { return operation.Failed("چنین وظیفه ای وجود ندارد"); } - var task = _taskRepository.Get(command.Id); - task.CompleteRequest(command.Description); + var task = _taskRepository.GetIncludeAssign(command.TaskId); + + if (task.SenderId ==accountId) + { + command.Description=string.IsNullOrWhiteSpace(command.Description) ? "وظیفه محول‌شده توسط ارسال کننده به پایان رسیده است." :command.Description; + } + else + { + command.Description = string.IsNullOrWhiteSpace(command.Description) ? "وظیفه محول شده با موفقیت به اتمام رسید." : command.Description; + } + if (task.SenderId == accountId) { - task.Completed(); + foreach (var assign in task.Assigns) + { + assign.CompleteRequest(command.Description); + assign.Completed(); + var message = new TaskMessage(command.Description, "تکمیل", assign.id); + _taskMessageRepository.Create(message); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assign.AssignedId, message.id); + + } + _taskMessageRepository.SaveChanges(); } - _taskRepository.SaveChanges(); + else + { + var assign = _assignRepository.GetAssignByAssignedIdAndTaskId(accountId, task.id); + assign.CompleteRequest(command.Description); + var message = new TaskMessage(command.Description, "درخواست انجام", assign.id); + _taskMessageRepository.Create(message); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assign.Task.SenderId, message.id); + } + _assignRepository.SaveChanges(); return operation.Succcedded(task.id); } - public OperationResult AcceptCompleteRequest(long taskId) + public OperationResult AcceptCompleteRequest(long taskId, long assignedId, string message) { + var accountId = _authHelper.CurrentAccountId(); var operation = new OperationResult(); if (!_taskRepository.Exists(x => x.id == taskId)) { return operation.Failed("چنین وظیفه ای وجود ندارد"); } - var task = _taskRepository.Get(taskId); - if (!task.IsDoneRequest) + var assign = _assignRepository.GetAssignByAssignedIdAndTaskId(assignedId, taskId); + if (!assign.IsDoneRequest) { return operation.Failed("چنین وظیفه ای درخواستی برای تایید ندارد"); } - task.Completed(); - _taskRepository.SaveChanges(); + assign.Completed(); + message = string.IsNullOrWhiteSpace(message) ? "درخواست شما مورد تایید قرار گرفت" : message; + var messageEntity = new TaskMessage(message, "تایید درخواست انجام", assign.id); + _taskMessageRepository.Create(messageEntity); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assignedId, messageEntity.id); + _assignRepository.SaveChanges(); return operation.Succcedded(taskId); } - public OperationResult RejectCompleteRequest(long taskId) + public OperationResult RejectCompleteRequest(long taskId, long assignedId, string message) { + var accountId = _authHelper.CurrentAccountId(); var operation = new OperationResult(); if (!_taskRepository.Exists(x => x.id == taskId)) { return operation.Failed("چنین وظیفه ای وجود ندارد"); } - var task = _taskRepository.Get(taskId); - if (!task.IsDoneRequest) + var assign = _assignRepository.GetAssignByAssignedIdAndTaskId(assignedId, taskId); + if (!assign.IsDoneRequest) { return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد"); } - task.RejectCompleteRequest(); - _taskRepository.SaveChanges(); + assign.RejectCompleteRequest(); + if (assign.EndTaskDate.Date <= DateTime.Now.Date) + { + var now = DateTime.Now; + var endOfDay = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59); + assign.EditTime(endOfDay); + } + var messageEntity = new TaskMessage(message, "رد درخواست انجام", assign.id); + _taskMessageRepository.Create(messageEntity); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assignedId, messageEntity.id); + _assignRepository.SaveChanges(); return operation.Succcedded(taskId); } - //لغو درخواست کنسل تسک - public OperationResult RejectCancelRequest(long taskId) - { - var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == taskId)) - { - return operation.Failed("چنین وظیفه ای وجود ندارد"); - } - var task = _taskRepository.Get(taskId); - if (!task.IsCanceledRequest) - { - return operation.Failed("چنین وظیفه ای درخواستی برای انصراف ندارد"); - } - task.RejectCancel(); - _taskRepository.SaveChanges(); - return operation.Succcedded(taskId); - } - //لغو درخواست مهلت تسک - public OperationResult RejectTimeRequest(long taskId) - { - var operation = new OperationResult(); - if (!_taskRepository.Exists(x => x.id == taskId)) - { - return operation.Failed("چنین وظیفه ای وجود ندارد"); - } - var task = _taskRepository.Get(taskId); - if (!task.TimeRequest) - { - return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد"); - } - task.RejectTimeRequest(); - _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); - } + public OperationResult CreateTaskByPosition(CreateTask command, List positionIds) { @@ -801,7 +854,12 @@ public class TaskApplication : ITaskApplication public List AllRequestedTasks(TaskSearchModel searchModel) { - return _taskRepository.AllRequestedTasks(searchModel); + return _taskRepository.AllRequestedTasks(searchModel); + } + + public List GetTaskMessages(long assignId) + { + return _taskMessageRepository.GetTaskMessages(assignId); } public int GetRequestedTasksCount() @@ -809,40 +867,45 @@ public class TaskApplication : ITaskApplication return _taskRepository.GetRequestedTasksCount(); } - public OperationResult ChangeRequestTimeAndAccept(string time, long taskId) + public OperationResult ChangeRequestTimeAndAccept(string time, long taskId, long assignedId, string message) { + var accountId = _authHelper.CurrentAccountId(); var operation = new OperationResult(); if (!_taskRepository.Exists(x => x.id == taskId)) { return operation.Failed("چنین وظیفه ای وجود ندارد"); } - var task = _taskRepository.Get(taskId); - if (!task.TimeRequest) + var assign = _assignRepository.GetAssignByAssignedIdAndTaskId(assignedId, taskId); + if (!assign.TimeRequest) { return operation.Failed("چنین وظیفه ای درخواستی برای مهلت ندارد"); } - if (task.RequestDate == null) + if (assign.RequestDate == null) { return operation.Failed("تاریخی برای درخواست وظیفه ثبت نشده است"); } DateTime timeGr = time.ToGeorgianDateTime2(); - task.ChangeTimeTask(timeGr); + assign.ChangeTimeTask(timeGr); + var messageEntity = new TaskMessage(message, "تایید و تغییر درخواست کنسل", assign.id); + _taskMessageRepository.Create(messageEntity); + _taskMessageRepository.SaveChanges(); + _taskMessageRepository.CreateTaskMessageItems(accountId, assignedId, messageEntity.id); _taskRepository.SaveChanges(); - return operation.Succcedded(task.id); + return operation.Succcedded(taskId); } - public TaskViewModel GetRequestDetails(long id) + public EditTask GetRequestDetails(long id) { return _taskRepository.GetRequestDetails(id); } public OperationResult UploadMedia(IFormFile mediaFile, long senderId) { var operation = new OperationResult(); - if ((mediaFile.Length > 2000000) || (mediaFile.Length > 2000000) || (mediaFile.Length > 2000000)) - return operation.Failed("حجم فایل نمیتواند از 2 مگابایت بیشتر باشد"); + if ((mediaFile.Length > 5000000)) + return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد"); var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", "temp", $"{senderId}"); Directory.CreateDirectory(path); @@ -897,4 +960,51 @@ public class TaskApplication : ITaskApplication } } + + public OperationResult SendTicketResponseInTask(long assignId, string message, long ticketId) + { + var accountId = _authHelper.CurrentAccountId(); + var operation = new OperationResult(); + var assign = _assignRepository.GetIncludeTask(assignId); + if (ticketId != assign.Task.TicketId) + { + return operation.Failed("خطای سیستمی!"); + + } + + var adminRes = new AdminResponse(message, ticketId, accountId); + _ticketRepository.CreateAdminResponse(adminRes); + _ticketRepository.SaveChanges(); + return operation.Succcedded(); + } + + public List GetAssignsByTaskId(long taskId) + { + return _assignRepository.GetAssignsByTaskId(taskId); + } + + //public OperationResult MoveDataFRomTaskToAssign() + //{ + // return _taskRepository.MoveDataFRomTaskToAssign(); + //} + + public void MoveTaskFile(long mediaId, long taskId, string category = "file") + { + var media = _mediaRepository.Get(mediaId); + var oldPath = media.Path; + var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", + "Task", $"{taskId}"); + Directory.CreateDirectory(path); + + string filepath = Path.Combine(path, Path.GetFileName(oldPath)); + File.Move(oldPath, filepath); + + string categoryMedia = category == "file" ? media.Category : + category == "voice" ? "صوت" : throw new InvalidDataException(); + + media.Edit(filepath, media.Type, categoryMedia); + + _mediaRepository.SaveChanges(); + _mediaRepository.CreateMediaWithTaskMedia(taskId, media.id); + } } \ No newline at end of file diff --git a/AccountManagement.Application/TaskScheduleApplication.cs b/AccountManagement.Application/TaskScheduleApplication.cs new file mode 100644 index 00000000..158e6165 --- /dev/null +++ b/AccountManagement.Application/TaskScheduleApplication.cs @@ -0,0 +1,223 @@ +using _0_Framework.Application; +using AccountManagement.Application.Contracts.Task; +using AccountManagement.Application.Contracts.TaskSchedule; +using AccountManagement.Domain.TaskScheduleAgg; +using System; +using System.IO; +using Company.Domain.HolidayItemAgg; + +namespace AccountManagement.Application; + +public class TaskScheduleApplication : ITaskScheduleApplication +{ + private readonly ITaskApplication _taskApplication; + private readonly ITaskScheduleRepository _taskScheduleRepository; + private readonly IHolidayItemRepository _holidayItemRepository; + + public TaskScheduleApplication(ITaskApplication taskApplication, ITaskScheduleRepository taskScheduleRepository, IHolidayItemRepository holidayItemRepository) + { + _taskApplication = taskApplication; + _taskScheduleRepository = taskScheduleRepository; + _holidayItemRepository = holidayItemRepository; + } + + public OperationResult Create(CreateTask command) + { + OperationResult operation = new OperationResult(); + + + if (command.HasSchedule) + { + switch (command.ScheduleType) + { + case "limited": + if (Convert.ToInt32(command.ScheduleCount) > 60) + { + return operation.Failed("تعداد وارد شده بیشتر از حد مجاز است"); + } + return CreateLimitedTasks(command); + break; + + case "unlimited": + return CreateUnlimitedTasks(command); + break; + + default: + return operation.Failed("خطای سیستمی!"); + + } + } + else + { + return operation.Failed("این تسک بصورت زمان بندی شده نمیباشد"); + } + } + + public OperationResult CreateLimitedTasks(CreateTask command) + { + OperationResult operation = new OperationResult(); + if (Convert.ToInt32(command.ScheduleCount) < 1 || string.IsNullOrWhiteSpace(command.ScheduleCount)) + { + return operation.Failed("تعداد وارد شده باید بیشتر از 2 باشد"); + } + + switch (command.ScheduleUnitType) + { + case "year": + if (Convert.ToInt32(command.ScheduleCount) != 1) + { + return operation.Failed("دوره نمیتواند بیشتر از 1 سال باشد"); + } + break; + case "month": + if (Convert.ToInt32(command.ScheduleCount) > 12) + { + return operation.Failed("بازه وارد شده نا معتبر است"); + } + break; + case "week": + if (command.ScheduleUnitNumber != "first" && command.ScheduleUnitNumber != "last") + { + return operation.Failed("بازه وارد شده نا معتبر است"); + } + break; + case "day": + if (Convert.ToInt32(command.ScheduleUnitNumber) > 29) + { + return operation.Failed("بازه وارد شده نا معتبر است"); + } + break; + default: + return operation.Failed("نوع بازه مشخص نمیباشد"); + break; + + } + try + { + DateTime previousDateRaw = command.EndTaskDate.ToGeorgianDateTime2(); + DateTime previousDateEdited = command.EndTaskDate.ToGeorgianDateTime2(); + + int count = Convert.ToInt32(command.ScheduleCount); + bool isInt = int.TryParse(command.ScheduleUnitNumber, out int unitNumber); + string kindOfWeekUnit = isInt ? "" : command.ScheduleUnitNumber; + + switch (command.ScheduleUnitType) + { + case "year": + for (int i = 1; i <= count; i++) + { + command.EndTaskDate = previousDateEdited.ToFarsi(); + operation = _taskApplication.CreateTask(command); + + bool isHoliday = _holidayItemRepository.GetHoliday(previousDateRaw); + while (isHoliday || previousDateEdited.DayOfWeek == DayOfWeek.Friday) + { + previousDateEdited = previousDateRaw.AddDays(1); + isHoliday = _holidayItemRepository.GetHoliday(previousDateEdited); + + } + previousDateRaw = previousDateRaw.AddYears(unitNumber); + previousDateEdited = previousDateRaw; + + } + break; + + case "month": + for (int i = 1; i <= count; i++) + { + command.EndTaskDate = previousDateEdited.ToFarsi(); + operation = _taskApplication.CreateTask(command); + bool isHoliday = _holidayItemRepository.GetHoliday(previousDateRaw); + while (isHoliday || previousDateEdited.DayOfWeek == DayOfWeek.Friday) + { + previousDateEdited = previousDateRaw.AddDays(1); + isHoliday = _holidayItemRepository.GetHoliday(previousDateEdited); + + } + previousDateRaw = previousDateRaw.AddMonths(unitNumber); + previousDateEdited = previousDateRaw; + + } + break; + + case "week": + for (int i = 1; i <= count; i++) + { + if (string.IsNullOrWhiteSpace(kindOfWeekUnit)) + { + throw new InvalidDataException(); + } + + command.EndTaskDate = kindOfWeekUnit switch + { + "first" => previousDateRaw.GetNextDayOfWeek(DayOfWeek.Saturday).ToFarsi(), + "last" => previousDateRaw.GetNextDayOfWeek(DayOfWeek.Thursday).ToFarsi(), + _ => throw new InvalidDataException() + }; + operation = _taskApplication.CreateTask(command); + bool isHoliday = _holidayItemRepository.GetHoliday(previousDateRaw); + while (isHoliday || previousDateEdited.DayOfWeek == DayOfWeek.Friday) + { + previousDateEdited = previousDateRaw.AddDays(1); + isHoliday = _holidayItemRepository.GetHoliday(previousDateEdited); + + } + previousDateRaw = command.EndTaskDate.ToGeorgianDateTime(); + previousDateEdited = previousDateRaw; + + + } + break; + + case "day": + + for (int i = 1; i <= count; i++) + { + command.EndTaskDate = previousDateEdited.ToFarsi(); + operation = _taskApplication.CreateTask(command); + previousDateRaw = previousDateRaw.AddDays(unitNumber); + bool isHoliday = _holidayItemRepository.GetHoliday(previousDateRaw); + while (isHoliday || previousDateEdited.DayOfWeek == DayOfWeek.Friday) + { + previousDateEdited = previousDateRaw.AddDays(1); + isHoliday = _holidayItemRepository.GetHoliday(previousDateEdited); + + } + + previousDateEdited = previousDateRaw; + } + break; + + default: + return operation.Failed("نوع بازه درست نمیباشد"); + } + + var lastDate = command.EndTaskDate.ToGeorgianDateTime(); + var taskSchedule = new TaskSchedule(command.ScheduleCount, command.ScheduleType, command.ScheduleUnitType, + command.ScheduleUnitNumber, lastDate); + _taskScheduleRepository.Create(taskSchedule); + _taskScheduleRepository.SaveChanges(); + operation = operation.Succcedded(); + return operation; + } + catch (Exception e) + { + return operation.Failed(e.ToString()); + } + } + + public OperationResult CreateUnlimitedTasks(CreateTask command) + { + var operation = _taskApplication.CreateTask(command); + if (!operation.IsSuccedded) + return operation; + var lastDate = command.EndTaskDate.ToGeorgianDateTime(); + var taskSchedule = new TaskSchedule(command.ScheduleCount, command.ScheduleType, command.ScheduleUnitType, + command.ScheduleUnitNumber, lastDate); + _taskScheduleRepository.Create(taskSchedule); + _taskScheduleRepository.SaveChanges(); + return operation.Succcedded(); + + } + +} \ No newline at end of file diff --git a/AccountManagement.Application/TaskSubjectApplication.cs b/AccountManagement.Application/TaskSubjectApplication.cs index 42383942..c27fa674 100644 --- a/AccountManagement.Application/TaskSubjectApplication.cs +++ b/AccountManagement.Application/TaskSubjectApplication.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using _0_Framework.Application; using AccountManagement.Application.Contracts.TaskSubject; using AccountManagement.Domain.TaskSubjectAgg; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; namespace AccountManagement.Application; diff --git a/AccountManagement.Application/TicketAccessAccountApplication.cs b/AccountManagement.Application/TicketAccessAccountApplication.cs new file mode 100644 index 00000000..c7e27be9 --- /dev/null +++ b/AccountManagement.Application/TicketAccessAccountApplication.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; +using _0_Framework.Application; +using AccountManagement.Application.Contracts.TicketAccessAccount; +using AccountManagement.Domain.AccountAgg; +using AccountManagement.Domain.TicketAccessAccountAgg; + +namespace AccountManagement.Application; + +public class TicketAccessAccountApplication : ITicketAccessAccountApplication +{ + private readonly ITicketAccessAccountRepository _ticketAccessAccountRepository; + private readonly IAccountRepository _accountRepository; + + public TicketAccessAccountApplication(ITicketAccessAccountRepository ticketAccessAccountRepository, IAccountRepository accountRepository) + { + _ticketAccessAccountRepository = ticketAccessAccountRepository; + _accountRepository = accountRepository; + } + + public bool HasTicketAccess(long accountId) + { + return _ticketAccessAccountRepository.HasTicketAccess(accountId); + } + + public OperationResult Create(long accountId) + { + OperationResult operation = new(); + if (!_accountRepository.Exists(x => x.id == accountId && x.AdminAreaPermission == "true")) + { + return operation.Failed("شخص انتخاب شده نا معتبر است"); + + } + + if (_ticketAccessAccountRepository.Exists(x => x.AccountId == accountId)) + return operation.Failed("به این شخص قبلا دسترسی داده شده است"); + + TicketAccessAccount accessAccountEntity = new(accountId); + _ticketAccessAccountRepository.Create(accessAccountEntity); + _ticketAccessAccountRepository.SaveChanges(); + + return operation.Succcedded(accessAccountEntity.id); + + } + + public OperationResult Delete(long id) + { + OperationResult operation = new(); + if (!_ticketAccessAccountRepository.Exists(x => x.id == id)) + return operation.Failed("اطلاعات داده شده نامعتبر است"); + _ticketAccessAccountRepository.Remove(id); + _ticketAccessAccountRepository.SaveChanges(); + return operation.Succcedded(id); + + } + + public List GetAllAccessedAccounts() + { + return _ticketAccessAccountRepository.GetAllAccessedAccounts(); + } +} \ No newline at end of file diff --git a/AccountManagement.Application/TicketApplication.cs b/AccountManagement.Application/TicketApplication.cs index bb665d9d..a17f3040 100644 --- a/AccountManagement.Application/TicketApplication.cs +++ b/AccountManagement.Application/TicketApplication.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Net.Sockets; using _0_Framework.Application; using AccountManagement.Application.Contracts.Task; using AccountManagement.Application.Contracts.Ticket; +using AccountManagement.Application.Contracts.TicketAccessAccount; using AccountManagement.Domain.AccountAgg; using AccountManagement.Domain.AdminResponseAgg; using AccountManagement.Domain.AssignAgg; @@ -13,7 +13,7 @@ using AccountManagement.Domain.ClientResponseAgg; using AccountManagement.Domain.MediaAgg; using AccountManagement.Domain.TaskAgg; using AccountManagement.Domain.TicketAgg; -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; namespace AccountManagement.Application; @@ -24,14 +24,18 @@ public class TicketApplication : ITicketApplication private readonly ITaskRepository _taskRepository; private readonly IAssignRepository _assignRepository; private readonly IMediaRepository _mediaRepository; + private readonly ITicketAccessAccountApplication _ticketAccessAccountApplication; + private readonly IAuthHelper _authHelper; - public TicketApplication(ITicketRepository ticketRepository, IAccountRepository accountRepository, ITaskRepository taskRepository, IAssignRepository assignRepository, IMediaRepository mediaRepository) + public TicketApplication(ITicketRepository ticketRepository, IAccountRepository accountRepository, ITaskRepository taskRepository, IAssignRepository assignRepository, IMediaRepository mediaRepository, ITicketAccessAccountApplication ticketAccessAccountApplication, IAuthHelper authHelper) { _ticketRepository = ticketRepository; _accountRepository = accountRepository; _taskRepository = taskRepository; _assignRepository = assignRepository; _mediaRepository = mediaRepository; + _ticketAccessAccountApplication = ticketAccessAccountApplication; + _authHelper = authHelper; } public OperationResult CreateTicket(CreateTicket command) @@ -47,21 +51,24 @@ public class TicketApplication : ITicketApplication return operation.Failed("لطفا عنوان را وارد کنید"); } - if (string.IsNullOrWhiteSpace(command.Description)) + if (string.IsNullOrWhiteSpace(command.Description) && command.VoiceId < 1) { return operation.Failed("لطفا توضیحات خودرا وارد کنید"); } - - + else if (string.IsNullOrWhiteSpace(command.Description)) + { + command.Description = ""; + } + var ticketNumber = (_ticketRepository.GetLastTicketNumber() + 1).ToString("D5"); var ticket = new Ticket(command.Title, command.Description, command.SenderId, command.ContractingPartyName, - command.TicketType); + command.TicketType, command.WorkshopId, ticketNumber); _ticketRepository.Create(ticket); _ticketRepository.SaveChanges(); + #region SaveDocuments - - if (command.UploadedMediaIds?.Count>0) + if (command.UploadedMediaIds?.Count > 0) { foreach (var mediaId in command.UploadedMediaIds) { @@ -80,6 +87,7 @@ public class TicketApplication : ITicketApplication _mediaRepository.SaveChanges(); _mediaRepository.CreateTicketMedia(ticket.id, media.id); + _mediaRepository.SaveChanges(); } } if (command.ScreenShotId > 0) @@ -90,13 +98,14 @@ public class TicketApplication : ITicketApplication "Ticket", $"{ticket.id}"); Directory.CreateDirectory(path); - string filepath = Path.Combine(path, Path.GetFileName(path)); + string filepath = Path.Combine(path, Path.GetFileName(oldPath)); File.Move(oldPath, filepath); - media.Edit(filepath, media.Type, media.Category); + media.Edit(filepath, media.Type, "اسکرین شات"); _mediaRepository.SaveChanges(); _mediaRepository.CreateTicketMedia(ticket.id, media.id); + } @@ -105,13 +114,13 @@ public class TicketApplication : ITicketApplication #region SaveVoice if (command.VoiceId > 0) { - var media = _mediaRepository.Get(command.ScreenShotId); + var media = _mediaRepository.Get(command.VoiceId); var oldPath = media.Path; var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", "Ticket", $"{ticket.id}"); Directory.CreateDirectory(path); - string filepath = Path.Combine(path, Path.GetFileName(path)); + string filepath = Path.Combine(path, Path.GetFileName(oldPath)); File.Move(oldPath, filepath); media.Edit(filepath, media.Type, "صوت"); @@ -119,6 +128,7 @@ public class TicketApplication : ITicketApplication _mediaRepository.SaveChanges(); _mediaRepository.CreateTicketMedia(ticket.id, media.id); + } #endregion @@ -181,27 +191,34 @@ public class TicketApplication : ITicketApplication { } + var ticket = _ticketRepository.Get(ticketId); + if (ticket == null) + return operation.Failed("چنین پشتیبانی وجود ندارد"); + var endTask = string.IsNullOrWhiteSpace(command.EndTaskTime) ? command.EndTaskDate.ToGeorgianDateTime2() : command.EndTaskDate.ToGeorgianDateWithTime(command.EndTaskTime); - - var task = new Tasks(command.Title, endTask, command.Description, command.SenderId, command.ContractingPartyName, ticketId); + + var task = new Tasks(command.Title, command.Description, command.SenderId, command.ContractingPartyName, ticketId); _taskRepository.Create(task); + ticket.AssignedToTasks(); _assignRepository.SaveChanges(); + + foreach (var receiver in receivers) { var assign = new Assign(task.id, task.SenderId, receiver.id, sender.Position.PositionValue, receiver.Fullname, - receiver.Position.PositionValue); + receiver.Position.PositionValue, endTask); _assignRepository.Create(assign); } - + _assignRepository.SaveChanges(); #region SaveMedias #region SaveDocuments - if (command.UploadedMedia?.Count>0) + if (command.UploadedMedia?.Count > 0) { foreach (var mediaId in command.UploadedMedia) { @@ -221,7 +238,7 @@ public class TicketApplication : ITicketApplication _mediaRepository.SaveChanges(); _mediaRepository.CreateMediaWithTaskMedia(task.id, media.id); } - + } #endregion @@ -245,7 +262,7 @@ public class TicketApplication : ITicketApplication } #endregion - + _taskRepository.SaveChanges(); @@ -268,18 +285,28 @@ public class TicketApplication : ITicketApplication public OperationResult AdminResponseTicket(ResponseTicket command) { var operation = new OperationResult(); - if (string.IsNullOrWhiteSpace(command.Response)) + if (string.IsNullOrWhiteSpace(command.Response) && !(command.UploadedFileIds?.Count > 0) && !(command.VoiceId > 0)) { - return operation.Failed("لطفا پیغام خود را وارد کنبد"); + return operation.Failed("لطفا پیغام یا فایل را وارد کنید"); } - var adminRes = new AdminResponse(command.Response, command.TicketId); - _ticketRepository.CreateAdminResponse(adminRes); - _ticketRepository.SaveChanges(); + if (string.IsNullOrWhiteSpace(command.Response)) + { + command.Response = "$GOzaReshgirMediaVoIce@"; + } + + var adminRes = new AdminResponse(command.Response, command.TicketId, command.AdminId); + if (_ticketAccessAccountApplication.HasTicketAccess(command.AdminId)) + adminRes.Active(); + var ticket = _ticketRepository.Get(command.TicketId); + _ticketRepository.CreateAdminResponse(adminRes); + ticket.Responded(); + _ticketRepository.SaveChanges(); + #region SaveDocuments - if (command.UploadedFileIds?.Count>0) + if (command.UploadedFileIds?.Count > 0) { foreach (var mediaId in command.UploadedFileIds) { @@ -300,10 +327,28 @@ public class TicketApplication : ITicketApplication _mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id); } } + if (command.VoiceId > 0) + { + var media = _mediaRepository.Get(command.VoiceId); + var oldPath = media.Path; + var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", + "TicketAdminResponse", $"{adminRes.id}"); + Directory.CreateDirectory(path); + + + + string filepath = Path.Combine(path, Path.GetFileName(oldPath)); + File.Move(oldPath, filepath); + + media.Edit(filepath, media.Type, "صوت"); + + _mediaRepository.SaveChanges(); + _mediaRepository.CreateAdminResponseMedia(adminRes.id, media.id); + } #endregion _mediaRepository.SaveChanges(); - + return operation.Succcedded(adminRes.id); } @@ -311,17 +356,24 @@ public class TicketApplication : ITicketApplication public OperationResult ClientResponseTicket(ResponseTicket command) { var operation = new OperationResult(); + if (string.IsNullOrWhiteSpace(command.Response) && !(command.UploadedFileIds?.Count > 0) && !(command.VoiceId > 0)) + { + return operation.Failed("لطفا پیغام یا فایل را وارد کنید"); + } + if (string.IsNullOrWhiteSpace(command.Response)) { - return operation.Failed("لطفا پیغام خود را وارد کنبد"); + command.Response = "$GOzaReshgirMediaVoIce@"; } var clientRes = new ClientResponse(command.Response, command.TicketId); + var ticket = _ticketRepository.Get(command.TicketId); _ticketRepository.CreateClientResponse(clientRes); - _ticketRepository.SaveChanges(); + ticket.Open(); + _ticketRepository.SaveChanges(); #region SaveDocuments - if (command.UploadedFileIds?.Count>0) + if (command.UploadedFileIds?.Count > 0) { foreach (var mediaId in command.UploadedFileIds) { @@ -343,6 +395,25 @@ public class TicketApplication : ITicketApplication } } + if (command.VoiceId > 0) + { + var media = _mediaRepository.Get(command.VoiceId); + var oldPath = media.Path; + var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", + "TicketClientResponse", $"{clientRes.id}"); + Directory.CreateDirectory(path); + + + + string filepath = Path.Combine(path, Path.GetFileName(oldPath)); + File.Move(oldPath, filepath); + + media.Edit(filepath, media.Type, "صوت"); + + _mediaRepository.SaveChanges(); + _mediaRepository.CreateClientResponseMedia(clientRes.id, media.id); + } + #endregion _mediaRepository.SaveChanges(); return operation.Succcedded(clientRes.id); @@ -353,6 +424,11 @@ public class TicketApplication : ITicketApplication return _ticketRepository.GetDetails(id); } + public EditTicket GetDetailsForClient(long id) + { + return _ticketRepository.GetDetailsForClient(id); + } + public List GetAll(TicketSearchModel searchModel) { return _ticketRepository.GetAll(searchModel); @@ -360,6 +436,168 @@ public class TicketApplication : ITicketApplication public bool IsExist(long id) { - return _ticketRepository.Exists(x => x.id == id); + return _ticketRepository.Exists(x => x.id == id); + } + public OperationResult UploadMedia(IFormFile mediaFile, long senderId) + { + var operation = new OperationResult(); + if ((mediaFile.Length > 5000000) || (mediaFile.Length > 5000000) || (mediaFile.Length > 5000000)) + return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد"); + var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", + "temp", $"{senderId}"); + Directory.CreateDirectory(path); + + string uniqueFileName = $"{Path.GetFileNameWithoutExtension(mediaFile.FileName)}_{DateTime.Now.Ticks}{Path.GetExtension(mediaFile.FileName)}"; + string filepath = Path.Combine(path, uniqueFileName); + + using (var stream = new FileStream(filepath, FileMode.Create)) + { + mediaFile.CopyTo(stream); + + } + var type = Path.GetExtension(filepath); + var media = new Media(filepath, type, "فایل"); + _mediaRepository.Create(media); + _mediaRepository.SaveChanges(); + return operation.Succcedded(media.id); + + } + + public OperationResult RemoveMedia(long mediaId) + { + var operation = new OperationResult(); + try + { + var media = _mediaRepository.Get(mediaId); + var path = media.Path; + if (File.Exists(path)) + { + File.Delete(path); + } + _mediaRepository.Remove(mediaId); + return operation.Succcedded(); + } + catch + { + return operation.Failed("مشکلی در حذف این فایل وجود دارد"); + } + + } + + public void RemoveTempUploadedFiles(long userId) + { + var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage", + "temp", $"{userId}"); + + + if (Directory.Exists(path)) + { + + Directory.Delete(path, true); + } + + } + + public List GetTicketsForClients(TicketSearchModel searchModel) + { + return _ticketRepository.GetTicketsForClients(searchModel); + } + + public OperationResult AcceptPendingAdminResponse(long adminResId) + { + var operation = new OperationResult(); + var adminRes = _ticketRepository.GetAdminResponse(adminResId); + var ticket = _ticketRepository.Get(adminRes.TicketId); + + + if (adminRes.IsActiveString == "true") + { + return operation.Failed("خطایی رخ داده است . لطفا با مدیر سیستم تماس بگیرید"); + } + adminRes.Active(); + ticket.Responded(); + _ticketRepository.SaveChanges(); + return operation.Succcedded(); + } + + public OperationResult RejectPendingAdminResponse(long adminResId) + { + var operation = new OperationResult(); + var adminRes = _ticketRepository.GetAdminResponse(adminResId); + if (adminRes.IsActiveString == "true") + { + return operation.Failed("خطایی رخ داده است . لطفا با مدیر سیستم تماس بگیرید"); + } + _ticketRepository.RemoveAdminResponse(adminResId); + _ticketRepository.SaveChanges(); + return operation.Succcedded(); + + } + + public OperationResult EditAndAcceptPendingAdminResponse(long adminResId, string newResponse) + { + var operation = new OperationResult(); + var adminRes = _ticketRepository.GetAdminResponse(adminResId); + var ticket = _ticketRepository.Get(adminRes.TicketId); + if (adminRes.IsActiveString == "true") + { + return operation.Failed("خطایی رخ داده است . لطفا با مدیر سیستم تماس بگیرید"); + } + adminRes.Edit(newResponse); + adminRes.Active(); + ticket.Responded(); + _ticketRepository.SaveChanges(); + return operation.Succcedded(); + } + + public OperationResult DeletePendingAdminResponse(int adminResId) + { + var operation = new OperationResult(); + var userId = _authHelper.CurrentAccountId(); + try + { + var adminRes = _ticketRepository.GetAdminResponse(adminResId); + if (adminRes.AdminAccountId!=userId) + { + return operation.Failed("شما نمیتوانید این پیام را پاک کنید"); + } + if (adminRes.IsActiveString=="true") + { + return operation.Failed("شما نمیتوانید این پیام را پاک کنید"); + } + _ticketRepository.RemoveAdminResponse(adminResId); + _taskRepository.SaveChanges(); + return operation.Succcedded(); + } + catch (Exception e) + { + return operation.Failed(e.ToString()); + } + } + + public OperationResult EditPendingAdminResponse(long adminResId,string newMessage) + { + var operation = new OperationResult(); + var entity=_ticketRepository.GetAdminResponse(adminResId); + if (entity==null) + { + return operation.Failed("مشکل سیستمی!!"); + } + entity.Edit(newMessage); + _ticketRepository.SaveChanges(); + return operation.Succcedded(); + } + + public OperationResult CloseTicket(long ticketId) + { + var operation= new OperationResult(); + var ticket = _ticketRepository.Get(ticketId); + if (ticket == null) + { + return operation.Failed("اطلاعات وارد شده نامعتبر است"); + } + ticket.Completed(); + _ticketRepository.SaveChanges(); + return operation.Succcedded(); } } \ No newline at end of file diff --git a/AccountManagement.Configuration/AccountManagementBootstrapper.cs b/AccountManagement.Configuration/AccountManagementBootstrapper.cs index 492d7547..cd8c1b25 100644 --- a/AccountManagement.Configuration/AccountManagementBootstrapper.cs +++ b/AccountManagement.Configuration/AccountManagementBootstrapper.cs @@ -6,6 +6,7 @@ using AccountManagement.Application.Contracts.Role; using AccountManagement.Application.Contracts.Task; using AccountManagement.Application.Contracts.TaskSubject; using AccountManagement.Application.Contracts.Ticket; +using AccountManagement.Application.Contracts.TicketAccessAccount; using AccountManagement.Domain.AccountAgg; using AccountManagement.Domain.AccountLeftWorkAgg; using AccountManagement.Domain.AssignAgg; @@ -13,7 +14,9 @@ using AccountManagement.Domain.CameraAccountAgg; using AccountManagement.Domain.MediaAgg; using AccountManagement.Domain.RoleAgg; using AccountManagement.Domain.TaskAgg; +using AccountManagement.Domain.TaskMessageAgg; using AccountManagement.Domain.TaskSubjectAgg; +using AccountManagement.Domain.TicketAccessAccountAgg; using AccountManagement.Domain.TicketAgg; using AccountMangement.Infrastructure.EFCore; using AccountMangement.Infrastructure.EFCore.Repository; @@ -41,13 +44,15 @@ namespace AccountManagement.Configuration services.AddTransient(); - //services.AddTransient(); - #region Mahan - services.AddTransient(); + //services.AddTransient(); + #region Mahan + + services.AddTransient(); services.AddTransient(); + services.AddScoped(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); @@ -59,6 +64,12 @@ namespace AccountManagement.Configuration services.AddTransient(); services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + + #endregion diff --git a/AccountManagement.Domain/AccountAgg/Account.cs b/AccountManagement.Domain/AccountAgg/Account.cs index b398098a..60ba1f0b 100644 --- a/AccountManagement.Domain/AccountAgg/Account.cs +++ b/AccountManagement.Domain/AccountAgg/Account.cs @@ -27,7 +27,7 @@ namespace AccountManagement.Domain.AccountAgg public string IsActiveString { get; private set; } #region Mahan - + public string PositionIsActive { get; private set; } public long? PositionId { get; private set; } public Position Position { get; private set; } @@ -128,13 +128,19 @@ namespace AccountManagement.Domain.AccountAgg public void SetPosition(long positionId) { PositionId = positionId; + PositionIsActive = "true"; } - public void DeletePositionId() + public void DeActivePosition() + { + PositionIsActive = "false"; + } + + public void RemovePosition() { PositionId = null; + PositionIsActive = null; } - #endregion } } diff --git a/AccountManagement.Domain/AccountAgg/IAccountRepository.cs b/AccountManagement.Domain/AccountAgg/IAccountRepository.cs index 65d20cd0..278ed596 100644 --- a/AccountManagement.Domain/AccountAgg/IAccountRepository.cs +++ b/AccountManagement.Domain/AccountAgg/IAccountRepository.cs @@ -9,6 +9,7 @@ namespace AccountManagement.Domain.AccountAgg { Account GetBy(string username); Account GetById(long id); + EditAccount GetDetails(long id); EditAccount GetByVerifyCode(string code, string phone); EditAccount GetByUserNameAndId(long id, string username); @@ -17,15 +18,15 @@ namespace AccountManagement.Domain.AccountAgg List GetClientsAccount(); List Search(AccountSearchModel searchModel); Task RemoveCode(long id); - #region Mahan - + Account GetIncludePositions(long id); List GetAccountsByPositionId(long positionId); List AccountsForAssign(long taskId); List GetAccountsByIds(List ids); List GetAccountLowerPositionvalue(); AccountViewModel GetAccountViewModel(long id); + List GetAccountsDeactivePositionValue(long Positionid); #endregion } diff --git a/AccountManagement.Domain/AdminResponseAgg/AdminResponse.cs b/AccountManagement.Domain/AdminResponseAgg/AdminResponse.cs index a8c6cc40..b6df36e6 100644 --- a/AccountManagement.Domain/AdminResponseAgg/AdminResponse.cs +++ b/AccountManagement.Domain/AdminResponseAgg/AdminResponse.cs @@ -7,16 +7,31 @@ namespace AccountManagement.Domain.AdminResponseAgg; public class AdminResponse:EntityBase { - public AdminResponse(string response,long ticketId) + public AdminResponse(string response,long ticketId, long adminAccountId) { Response = response; TicketId = ticketId; + AdminAccountId = adminAccountId; + IsActiveString = "false"; } public long TicketId { get; private set; } + public long AdminAccountId { get; private set; } public string Response { get; private set; } + public string IsActiveString { get; private set; } public Ticket Ticket { get; set; } public List AdminResponseMedias { get; set; } + public void Active() + { + IsActiveString = "true"; + } + + public void Edit(string response) + { + Response=response; + } + + } \ No newline at end of file diff --git a/AccountManagement.Domain/AssignAgg/Assign.cs b/AccountManagement.Domain/AssignAgg/Assign.cs index 0ebc9ac1..2bab15b8 100644 --- a/AccountManagement.Domain/AssignAgg/Assign.cs +++ b/AccountManagement.Domain/AssignAgg/Assign.cs @@ -1,11 +1,14 @@ using _0_Framework.Domain; using AccountManagement.Domain.TaskAgg; +using System; +using System.Collections.Generic; +using AccountManagement.Domain.TaskMessageAgg; namespace AccountManagement.Domain.AssignAgg; public class Assign : EntityBase { - public Assign(long taskId, long assignerId, long assignedId, int assignerPositionValue, string assignedName, int assignedPositionValue) + public Assign(long taskId, long assignerId, long assignedId, int assignerPositionValue, string assignedName, int assignedPositionValue, DateTime endTaskDate) { TaskId = taskId; AssignerId = assignerId; @@ -13,21 +16,129 @@ public class Assign : EntityBase AssignerPositionValue = assignerPositionValue; AssignedName = assignedName; AssignedPositionValue = assignedPositionValue; + EndTaskDate = endTaskDate; } - - public long TaskId { get; private set; } - //آیدی شخص ارسال کننده - public long AssignerId { get; private set; } - //نام دریافت کننده - public string AssignedName { get; private set; } - //آیدی شخص دریافت کننده - public long AssignedId { get; private set; } - //سطح شخص ارسال کننده - public int AssignerPositionValue { get; private set; } + + //آیدی شخص ارسال کننده + public long TaskId { get; private set; } + //نام دریافت کننده + public long AssignerId { get; private set; } + //آیدی شخص دریافت کننده + public string AssignedName { get; private set; } + //سطح شخص ارسال کننده + public long AssignedId { get; private set; } + + public int AssignerPositionValue { get; private set; } public int AssignedPositionValue { get; private set; } + //زمان پایان وظیفه + public DateTime EndTaskDate { get; private set; } + //آیا درخواست مهلت کرده است؟ + public bool TimeRequest { get; private set; } + //تعداد تایید درخواست مهلت + public int AcceptedTimeRequest { get; private set; } + //مهلت زمان درخواست شده + public DateTime? RequestDate { get; private set; } + //توضیحات درخواست مهلت + public string? TimeRequestDescription { get; private set; } + //آیا درخواست انصراف داده شده - public Tasks Task { get; set; } + //آیا کنسل شده است + public bool IsCancel { get; private set; } + //توضیحات درخواست انصراف + public string? CancelDescription { get; private set; } + public bool IsDone { get; private set; } + public bool IsDoneRequest { get; private set; } + + public string? DoneDescription { get; private set; } + public bool IsCanceledRequest { get; private set; } + + public Tasks Task { get; set; } + public List TaskMessageList { get; set; } + + public void EditTime(DateTime endTaskDate) + { + EndTaskDate = endTaskDate; + } + public void CreateTimeRequest(DateTime requestDate, string timeRequestDescription) + { + RequestDate = requestDate; + TimeRequestDescription = timeRequestDescription; + TimeRequest = true; + } + + public void AcceptTimeRequest() + { + TimeRequest = false; + AcceptedTimeRequest++; + EndTaskDate = RequestDate.Value; + + } + public void RejectTimeRequest() + { + TimeRequest = false; + TimeRequestDescription = null; + RequestDate = null; + } + + public void CreateCancelRequest(string cancelDescription) + { + CancelDescription = cancelDescription; + IsCanceledRequest = true; - + } + public void AcceptCancelRequest() + { + IsCanceledRequest = false; + IsCancel = true; + + + } + public void RejectCancel() + { + CancelDescription = null; + IsCanceledRequest = false; + } + + public void CompleteRequest(string? doneDescription) + { + DoneDescription = doneDescription; + IsDoneRequest = true; + } + + public void RejectCompleteRequest() + { + IsDoneRequest = false; + DoneDescription = null; + } + public void Completed() + { + IsDoneRequest = false; + IsDone = true; + } + + public void ChangeTimeTask(DateTime time) + { + EndTaskDate = time; + AcceptedTimeRequest++; + RequestDate = null; + TimeRequest = false; + } + + public void InsertNewData(DateTime endTaskDate,bool timeRequest,int acceptedTimeRequest,DateTime? requestDate, string timeRequestDescription, bool isCanceledRequest, + bool isCancel,string cancelDescription,bool isDone,bool isDoneRequest,string? doneDescription) + { + EndTaskDate = endTaskDate; + TimeRequest=timeRequest; + AcceptedTimeRequest = acceptedTimeRequest; + RequestDate = requestDate; + TimeRequestDescription = timeRequestDescription; + IsCanceledRequest = isCanceledRequest; + IsCancel=isCancel; + IsDone=isDone; + CancelDescription=cancelDescription; + IsDone=isDone; + IsDoneRequest=isDoneRequest; + DoneDescription=doneDescription; + } } \ No newline at end of file diff --git a/AccountManagement.Domain/AssignAgg/IAssignRepository.cs b/AccountManagement.Domain/AssignAgg/IAssignRepository.cs index 8a8bdef1..cf1453f6 100644 --- a/AccountManagement.Domain/AssignAgg/IAssignRepository.cs +++ b/AccountManagement.Domain/AssignAgg/IAssignRepository.cs @@ -1,13 +1,17 @@ using System.Collections.Generic; using _0_Framework.Domain; using AccountManagement.Application.Contracts.Assign; +using Microsoft.VisualBasic.CompilerServices; namespace AccountManagement.Domain.AssignAgg; -public interface IAssignRepository:IRepository +public interface IAssignRepository : IRepository { - List GetAssignsByTaskId(long id); - void RemoveRangeAssigns(long taskId); + List GetAssignsByTaskId(long id); + void RemoveRangeAssigns(long taskId); + List GetAssignedIdsByTaskId(long taskId); + Assign GetAssignByAssignedIdAndTaskId(long assignedId, long taskId); + Assign GetIncludeTask(long id); } \ No newline at end of file diff --git a/AccountManagement.Domain/PositionAgg/IPositionRepository.cs b/AccountManagement.Domain/PositionAgg/IPositionRepository.cs index 60cbc802..8e93c3c2 100644 --- a/AccountManagement.Domain/PositionAgg/IPositionRepository.cs +++ b/AccountManagement.Domain/PositionAgg/IPositionRepository.cs @@ -14,7 +14,7 @@ public interface IPositionRepository : IRepository List GetUnUsedPositionValues(); List GetNoPositionAccounts(); - List GetAccountsByIds(List ids); + List GetAccountsByPositionIds(List ids); void Remove(long id); diff --git a/AccountManagement.Domain/TaskAgg/ITaskRepository.cs b/AccountManagement.Domain/TaskAgg/ITaskRepository.cs index 571c7f6e..24040064 100644 --- a/AccountManagement.Domain/TaskAgg/ITaskRepository.cs +++ b/AccountManagement.Domain/TaskAgg/ITaskRepository.cs @@ -1,25 +1,38 @@ using System; using System.Collections.Generic; +using _0_Framework.Application; using _0_Framework.Domain; using AccountManagement.Application.Contracts.Task; +using AccountManagement.Application.Contracts.TaskMessage; namespace AccountManagement.Domain.TaskAgg; public interface ITaskRepository:IRepository { EditTask GetDetails(long TaskId); + Tasks GetIncludeAssign(long taskId); void Remove(long id); //گرفتن تمامی وظایف List GetTasks(TaskSearchModel searchModel); + List GetAllTasks(TaskSearchModel searchModel); List GetRequestedTasks(TaskSearchModel searchModel); List GetSelfTasks(TaskSearchModel searchModel); - List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel); + //List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel); List GetReceivedTasks(TaskSearchModel searchModel); List GetSentTasks(TaskSearchModel searchModel); List AllRequestedTasks(TaskSearchModel searchModel); string SetTasksColors(DateTime time,bool isCancel); int GetRequestedTasksCount(); - TaskViewModel GetRequestDetails(long id); + EditTask GetRequestDetails(long id); string GetWebEnvironmentPath(); + bool HasOverdueTasks(); + + + + /// گرفتن پیام های مربوط به هر تسک + + + + //OperationResult MoveDataFRomTaskToAssign(); } \ No newline at end of file diff --git a/AccountManagement.Domain/TaskAgg/Tasks.cs b/AccountManagement.Domain/TaskAgg/Tasks.cs index e2c75ca9..39d94082 100644 --- a/AccountManagement.Domain/TaskAgg/Tasks.cs +++ b/AccountManagement.Domain/TaskAgg/Tasks.cs @@ -4,61 +4,48 @@ using System.Security.AccessControl; using _0_Framework.Domain; using AccountManagement.Domain.AssignAgg; using AccountManagement.Domain.TaskMediaAgg; +using AccountManagement.Domain.TaskScheduleAgg; namespace AccountManagement.Domain.TaskAgg; public class Tasks : EntityBase { - public Tasks(string title, DateTime endTaskDate, string? description, long senderId, string contractingPartyName) + public Tasks(string title, string? description, long senderId, string contractingPartyName) { Title = title; - EndTaskDate = endTaskDate; + Description = description; SenderId = senderId; ContractingPartyName = contractingPartyName; StartTaskDate = DateTime.Now; IsActiveString = "true"; + TaskScheduleId = null; } //عنوان وظیفه public string Title { get; private set; } - //زمان پایان وظیفه - public DateTime EndTaskDate { get; private set; } //زمان ارسال وظیفه public DateTime StartTaskDate { get; private set; } //توضیحات وظیفه public string? Description { get; private set; } //آیدی شخص ارسال کننده public long SenderId { get; private set; } - //آیا درخواست مهلت کرده است؟ - public bool TimeRequest { get; private set; } - //تعداد تایید درخواست مهلت - public int AcceptedTimeRequest { get; set; } - //مهلت زمان درخواست شده - public DateTime? RequestDate { get; private set; } - //توضیحات درخواست مهلت - public string? TimeRequestDescription { get; private set; } - //آیا درخواست انصراف داده شده - public bool IsCanceledRequest { get; private set; } //نام طرف حساب public string ContractingPartyName { get; set; } - //آیا کنسل شده است - public bool IsCancel { get; private set; } - //توضیحات درخواست انصراف - public string? CancelDescription { get; private set; } - public bool IsDone { get; private set; } - public bool IsDoneRequest { get; private set; } - - public string? DoneDescription { get; private set; } public string IsActiveString { get; private set; } + + public long? TicketId { get; private set; } + + public long? TaskScheduleId { get; private set; } + public List Assigns { get; set; } public List TaskMedias { get; set; } - public long? TicketId { get; set; } + public TaskSchedule TaskSchedule { get; set; } - public Tasks(string title, DateTime endTaskDate, string? description, long senderId, string contractingPartyName, long ticketId) + + public Tasks(string title, string? description, long senderId, string contractingPartyName, long ticketId) { Title = title; - EndTaskDate = endTaskDate; Description = description; SenderId = senderId; ContractingPartyName = contractingPartyName; @@ -67,93 +54,30 @@ public class Tasks : EntityBase TicketId = ticketId; } - public void Edit(string title, DateTime endTaskDate, string? description, long senderId, string contractingPartyName) + public void Edit(string title, string? description, long senderId, string contractingPartyName) { Title = title; - EndTaskDate = endTaskDate; Description = description; SenderId = senderId; - ContractingPartyName= contractingPartyName; + ContractingPartyName = contractingPartyName; } //برای ایجاد یک درخواست مهلت - public void CreateTimeRequest(DateTime requestDate, string timeRequestDescription) + + public void DeActive() { - RequestDate = requestDate; - TimeRequestDescription = timeRequestDescription; - TimeRequest = true; + IsActiveString = "false"; } - public void AcceptTimeRequest() + public void Activator() { - TimeRequest = false; - AcceptedTimeRequest++; - EndTaskDate = (DateTime)RequestDate; - - } - public void RejectTimeRequest() - { - TimeRequest = false; - TimeRequestDescription = null; - RequestDate = null; + IsActiveString = "true"; } - public void CreateCancelRequest(string cancelDescription) + public void SetTaskSchedule(long taskScheduleId) { - CancelDescription = cancelDescription; - IsCanceledRequest=true; - - + TaskScheduleId = taskScheduleId; } - public void AcceptCancelRequest() - { - IsCanceledRequest=false; - IsCancel = true; - - } - public void RejectCancel() - { - CancelDescription = null; - IsCanceledRequest = false; - } - - public void CompleteRequest(string? doneDescription) - { - DoneDescription = doneDescription; - IsDoneRequest = true; - } - - public void RejectCompleteRequest() - { - IsDoneRequest = false; - DoneDescription=null; - } - public void Completed() - { - IsDoneRequest = false; - IsDone=true; - } - - public void DeActive() - { - IsActiveString = "false"; - } - - public void Activator() - { - IsActiveString = "true"; - } - - - public void ChangeTimeTask(DateTime time) - { - EndTaskDate = time; - AcceptedTimeRequest++; - RequestDate = null; - TimeRequest = false; - } - - } \ No newline at end of file diff --git a/AccountManagement.Domain/TaskMessageAgg/ITaskMessageRepository.cs b/AccountManagement.Domain/TaskMessageAgg/ITaskMessageRepository.cs new file mode 100644 index 00000000..10f7145d --- /dev/null +++ b/AccountManagement.Domain/TaskMessageAgg/ITaskMessageRepository.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using _0_Framework.Domain; +using AccountManagement.Application.Contracts.TaskMessage; + +namespace AccountManagement.Domain.TaskMessageAgg; + +public interface ITaskMessageRepository: IRepository +{ + void CreateTaskMessageItems(long senderId,long receiverId,long messageId); + List GetTaskMessages(long assignId); +} \ No newline at end of file diff --git a/AccountManagement.Domain/TaskMessageAgg/TaskMessage.cs b/AccountManagement.Domain/TaskMessageAgg/TaskMessage.cs new file mode 100644 index 00000000..d9222cad --- /dev/null +++ b/AccountManagement.Domain/TaskMessageAgg/TaskMessage.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using System.Runtime; +using _0_Framework.Domain; +using AccountManagement.Domain.AssignAgg; +using AccountManagement.Domain.TaskMessageItemsAgg; + +namespace AccountManagement.Domain.TaskMessageAgg; + +public class TaskMessage:EntityBase +{ + public TaskMessage(string message, string typeOfMessage, long assignId, string requestedDateFa="") + { + Message = message; + TypeOfMessage = typeOfMessage; + AssignId = assignId; + RequestedDateFa = requestedDateFa; + } + + public string Message { get; private set; } + public string TypeOfMessage { get; private set; } + public string RequestedDateFa { get; private set; } + public long AssignId { get; private set; } + + public List TaskMessageItemsList { get; set; } + public Assign Assign { get; set; } +} \ No newline at end of file diff --git a/AccountManagement.Domain/TaskMessageItemsAgg/TaskMessageItems.cs b/AccountManagement.Domain/TaskMessageItemsAgg/TaskMessageItems.cs new file mode 100644 index 00000000..155017f2 --- /dev/null +++ b/AccountManagement.Domain/TaskMessageItemsAgg/TaskMessageItems.cs @@ -0,0 +1,22 @@ +using _0_Framework.Domain; +using AccountManagement.Domain.TaskMessageAgg; + +namespace AccountManagement.Domain.TaskMessageItemsAgg; + +public class TaskMessageItems:EntityBase +{ + public TaskMessageItems(long senderAccountId, long receiverAccountId, long taskMessageId) + { + SenderAccountId = senderAccountId; + ReceiverAccountId = receiverAccountId; + TaskMessageId = taskMessageId; + } + + public long SenderAccountId { get; private set; } + public long ReceiverAccountId { get; private set; } + public long TaskMessageId { get; private set; } + + public TaskMessage TaskMessage { get; set; } + + +} \ No newline at end of file diff --git a/AccountManagement.Domain/TaskScheduleAgg/ITaskScheduleRepository.cs b/AccountManagement.Domain/TaskScheduleAgg/ITaskScheduleRepository.cs new file mode 100644 index 00000000..21bb249d --- /dev/null +++ b/AccountManagement.Domain/TaskScheduleAgg/ITaskScheduleRepository.cs @@ -0,0 +1,8 @@ +using _0_Framework.Domain; + +namespace AccountManagement.Domain.TaskScheduleAgg; + +public interface ITaskScheduleRepository:IRepository +{ + +} \ No newline at end of file diff --git a/AccountManagement.Domain/TaskScheduleAgg/TaskSchedule.cs b/AccountManagement.Domain/TaskScheduleAgg/TaskSchedule.cs new file mode 100644 index 00000000..da4a037f --- /dev/null +++ b/AccountManagement.Domain/TaskScheduleAgg/TaskSchedule.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using _0_Framework.Domain; +using AccountManagement.Domain.TaskAgg; + +namespace AccountManagement.Domain.TaskScheduleAgg; + +public class TaskSchedule:EntityBase +{ + public TaskSchedule(string count, string type, string unitType, string unitNumber, DateTime lastEndTaskDate) + { + Count = count; + Type = type; + UnitType = unitType; + UnitNumber = unitNumber; + LastEndTaskDate = lastEndTaskDate; + } + public string Count { get; private set; } + public string Type { get; private set; } + public string UnitType { get; private set; } + public string UnitNumber { get; private set; } + public DateTime LastEndTaskDate { get; private set; } + public List TasksList { get; set; } + + public void SetLastEndTaskDate(DateTime lastEndTaskDate) + { + LastEndTaskDate = lastEndTaskDate; + } +} \ No newline at end of file diff --git a/AccountManagement.Domain/TicketAccessAccountAgg/ITicketAccessAccountRepository.cs b/AccountManagement.Domain/TicketAccessAccountAgg/ITicketAccessAccountRepository.cs new file mode 100644 index 00000000..cc326a38 --- /dev/null +++ b/AccountManagement.Domain/TicketAccessAccountAgg/ITicketAccessAccountRepository.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using _0_Framework.Domain; +using AccountManagement.Application.Contracts.TicketAccessAccount; + +namespace AccountManagement.Domain.TicketAccessAccountAgg; + +public interface ITicketAccessAccountRepository:IRepository +{ + bool HasTicketAccess(long accountId); + List GetAllAccessedAccounts(); + void Remove (long id); +} \ No newline at end of file diff --git a/AccountManagement.Domain/TicketAccessAccountAgg/TicketAccessAccount.cs b/AccountManagement.Domain/TicketAccessAccountAgg/TicketAccessAccount.cs new file mode 100644 index 00000000..e1014cde --- /dev/null +++ b/AccountManagement.Domain/TicketAccessAccountAgg/TicketAccessAccount.cs @@ -0,0 +1,13 @@ +using _0_Framework.Domain; + +namespace AccountManagement.Domain.TicketAccessAccountAgg; + +public class TicketAccessAccount:EntityBase +{ + public TicketAccessAccount(long accountId) + { + AccountId = accountId; + } + + public long AccountId { get; private set; } +} \ No newline at end of file diff --git a/AccountManagement.Domain/TicketAgg/ITicketRepository.cs b/AccountManagement.Domain/TicketAgg/ITicketRepository.cs index c6aa0aee..c782d472 100644 --- a/AccountManagement.Domain/TicketAgg/ITicketRepository.cs +++ b/AccountManagement.Domain/TicketAgg/ITicketRepository.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using _0_Framework.Application; using _0_Framework.Domain; using AccountManagement.Application.Contracts.Ticket; using AccountManagement.Domain.AdminResponseAgg; @@ -9,9 +10,16 @@ namespace AccountManagement.Domain.TicketAgg; public interface ITicketRepository:IRepository { List GetAll(TicketSearchModel searchModel); + List GetTicketsForClients(TicketSearchModel searchModel); void CreateAdminResponse(AdminResponse command); void CreateClientResponse(ClientResponse command); EditTicket GetDetails(long id); + EditTicket GetDetailsForClient(long id); + int GetLastTicketNumber(); + AdminResponse GetAdminResponse(long adminResId); + ClientResponse GetClientResponse(long adminResId); + void RemoveAdminResponse(long adminResId); + } \ No newline at end of file diff --git a/AccountManagement.Domain/TicketAgg/Ticket.cs b/AccountManagement.Domain/TicketAgg/Ticket.cs index b3d0e84a..b16a895d 100644 --- a/AccountManagement.Domain/TicketAgg/Ticket.cs +++ b/AccountManagement.Domain/TicketAgg/Ticket.cs @@ -9,23 +9,27 @@ namespace AccountManagement.Domain.TicketAgg; public class Ticket:EntityBase { - public Ticket(string title, string description, long senderId, string contractingPartyName, string ticketType) + public Ticket(string title, string description, long senderId, string contractingPartyName, string ticketType, long workshopId, string ticketNumber,long subAccountSenderId=0) { Title = title; Description = description; - Status = "درحال بررسی"; + Status = "باز"; SenderId = senderId; ContractingPartyName = contractingPartyName; TicketType = ticketType; + WorkshopId = workshopId; + TicketNumber = ticketNumber; + SubAccountSenderId = subAccountSenderId; } - public string Title { get; private set; } public string Description { get; private set; } public string TicketType { get; set; } + public string TicketNumber { get; set; } public string Status { get; private set; } public long SenderId { get; private set; } + public long SubAccountSenderId { get; set; } public string ContractingPartyName { get; private set; } - public long? TaskId { get; private set; } + public long WorkshopId { get; private set; } public List ClientResponses { get; set; } public List AdminResponses{ get; set; } public List TicketMedias { get; set; } @@ -39,4 +43,14 @@ public class Ticket:EntityBase { Status = "پاسخ داده شده"; } + + public void AssignedToTasks() + { + Status = "درحال بررسی"; + } + + public void Open() + { + Status = "باز"; + } } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/AccountContext.cs b/AccountMangement.Infrastructure.EFCore/AccountContext.cs index 2c4e2d04..bf99a681 100644 --- a/AccountMangement.Infrastructure.EFCore/AccountContext.cs +++ b/AccountMangement.Infrastructure.EFCore/AccountContext.cs @@ -17,6 +17,9 @@ using AccountManagement.Domain.ClientResponseAgg; using AccountManagement.Domain.ClientResponseMediaAgg; using AccountManagement.Domain.TicketAgg; using AccountManagement.Domain.TicketMediasAgg; +using AccountManagement.Domain.TaskMessageAgg; +using AccountManagement.Domain.TaskMessageItemsAgg; +using AccountManagement.Domain.TicketAccessAccountAgg; namespace AccountMangement.Infrastructure.EFCore { @@ -42,6 +45,10 @@ namespace AccountMangement.Infrastructure.EFCore public DbSet ClientResponseMedias { get; set; } public DbSet Tickets { get; set; } public DbSet TicketMedias { get; set; } + public DbSet TaskMessages { get; set; } + public DbSet TaskMessageItems { get; set; } + + public DbSet TicketAccessAccounts { get; set; } #endregion public AccountContext(DbContextOptions options) : base(options) diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/AccountMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/AccountMapping.cs index 4bb3309f..6ae53575 100644 --- a/AccountMangement.Infrastructure.EFCore/Mappings/AccountMapping.cs +++ b/AccountMangement.Infrastructure.EFCore/Mappings/AccountMapping.cs @@ -23,7 +23,8 @@ public class AccountMapping : IEntityTypeConfiguration builder.Property(x => x.Email).HasMaxLength(150); builder.Property(x => x.VerifyCode).HasMaxLength(1000); builder.Property(x => x.IsActiveString).HasMaxLength(6); - builder.Property(x => x.PositionId).HasMaxLength(10).IsRequired(false); + builder.Property(x => x.PositionId).HasMaxLength(10).IsRequired(false); + builder.Property(x => x.PositionIsActive).HasMaxLength(5); builder.HasOne(x => x.Role).WithMany(x => x.Accounts).HasForeignKey(x => x.RoleId); builder.HasMany(x => x.CameraAccounts) diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/AdminResponseMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/AdminResponseMapping.cs index 526b9872..bc03cef0 100644 --- a/AccountMangement.Infrastructure.EFCore/Mappings/AdminResponseMapping.cs +++ b/AccountMangement.Infrastructure.EFCore/Mappings/AdminResponseMapping.cs @@ -13,6 +13,7 @@ public class AdminResponseMapping : IEntityTypeConfiguration builder.Property(x => x.Response).HasColumnType("ntext"); + builder.Property(x => x.IsActiveString).HasMaxLength(5); builder.HasMany(x => x.AdminResponseMedias).WithOne(x => x.AdminResponse).HasForeignKey(x => x.AdminResponseId); diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/AssignMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/AssignMapping.cs index f58602fb..60ef205a 100644 --- a/AccountMangement.Infrastructure.EFCore/Mappings/AssignMapping.cs +++ b/AccountMangement.Infrastructure.EFCore/Mappings/AssignMapping.cs @@ -11,8 +11,13 @@ public class AssignMapping:IEntityTypeConfiguration builder.ToTable("Assigns"); builder.HasKey(x => x.id); builder.Property(x => x.AssignedName).HasMaxLength(200); - + builder.Property(x => x.RequestDate).IsRequired(false); + builder.Property(x => x.EndTaskDate).IsRequired(); + builder.Property(x => x.CancelDescription).IsRequired(false).HasColumnType("ntext"); + builder.Property(x => x.TimeRequestDescription).IsRequired(false).HasColumnType("ntext"); + builder.Property(x => x.DoneDescription).IsRequired(false).HasColumnType("ntext"); - builder.HasOne(x => x.Task).WithMany(x => x.Assigns).HasForeignKey(x => x.TaskId).IsRequired(false); + + builder.HasOne(x => x.Task).WithMany(x => x.Assigns).HasForeignKey(x => x.TaskId).IsRequired(false); } } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TaskMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TaskMapping.cs index fc66ab7c..0fd84437 100644 --- a/AccountMangement.Infrastructure.EFCore/Mappings/TaskMapping.cs +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TaskMapping.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace AccountMangement.Infrastructure.EFCore.Mappings; -public class TaskMapping:IEntityTypeConfiguration +public class TaskMapping : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { @@ -12,19 +12,20 @@ public class TaskMapping:IEntityTypeConfiguration builder.HasKey(t => t.id); - builder.Property(x => x.RequestDate).IsRequired(false); - builder.Property(x => x.EndTaskDate).IsRequired(); + builder.Property(x => x.Description).IsRequired(false).HasColumnType("ntext"); - builder.Property(x => x.CancelDescription).IsRequired(false).HasColumnType("ntext"); - builder.Property(x => x.TimeRequestDescription).IsRequired(false).HasColumnType("ntext"); builder.Property(x => x.Title).IsRequired().HasMaxLength(100); builder.Property(x => x.IsActiveString).HasMaxLength(7); builder.Property(x => x.ContractingPartyName).HasMaxLength(200); - builder.Property(x => x.DoneDescription).IsRequired(false).HasColumnType("ntext"); - builder.Property(x => x.TicketId).IsRequired(false); + builder.Property(x => x.TaskScheduleId).IsRequired(false); + builder.Property(x => x.TicketId).IsRequired(false); - builder.HasMany(x => x.Assigns).WithOne(x => x.Task).HasForeignKey(x => x.TaskId).IsRequired(false).OnDelete(DeleteBehavior.Cascade); + builder.HasOne(x => x.TaskSchedule).WithMany(x => x.TasksList).HasForeignKey(x => x.TaskScheduleId) + .IsRequired(false).OnDelete(DeleteBehavior.Cascade); + + builder.HasMany(x => x.Assigns).WithOne(x => x.Task).HasForeignKey(x => x.TaskId) + .IsRequired(false).OnDelete(DeleteBehavior.Cascade); } } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TaskMessageItemsMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TaskMessageItemsMapping.cs new file mode 100644 index 00000000..b18be0d4 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TaskMessageItemsMapping.cs @@ -0,0 +1,17 @@ +using AccountManagement.Domain.TaskMessageAgg; +using AccountManagement.Domain.TaskMessageItemsAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace AccountMangement.Infrastructure.EFCore.Mappings; + +public class TaskMessageItemsMapping: IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("TaskMessageItems"); + builder.HasKey(x => x.id); + + builder.HasOne(x => x.TaskMessage).WithMany(x => x.TaskMessageItemsList).HasForeignKey(x => x.TaskMessageId); + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TaskMessageMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TaskMessageMapping.cs new file mode 100644 index 00000000..cb45f26b --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TaskMessageMapping.cs @@ -0,0 +1,23 @@ +using AccountManagement.Domain.AccountLeftWorkAgg; +using AccountManagement.Domain.TaskMessageAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace AccountMangement.Infrastructure.EFCore.Mappings; + +public class TaskMessageMapping : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("TaskMessages"); + builder.HasKey(x => x.id); + + builder.Property(x => x.TypeOfMessage).HasMaxLength(30); + builder.Property(x=>x.Message).HasColumnType("ntext"); + builder.Property(x => x.RequestedDateFa).HasMaxLength(25); + + + builder.HasMany(x => x.TaskMessageItemsList).WithOne(x => x.TaskMessage).HasForeignKey(x => x.TaskMessageId); + builder.HasOne(x => x.Assign).WithMany(x => x.TaskMessageList).HasForeignKey(x => x.AssignId); + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TaskScheduleMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TaskScheduleMapping.cs new file mode 100644 index 00000000..2f4a0f50 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TaskScheduleMapping.cs @@ -0,0 +1,22 @@ +using AccountManagement.Domain.TaskScheduleAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace AccountMangement.Infrastructure.EFCore.Mappings; + +public class TaskScheduleMapping : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("TaskSchedules"); + builder.HasKey(x => x.id); + + builder.Property(x => x.Count).HasMaxLength(10); + builder.Property(x => x.Type).HasMaxLength(12); + builder.Property(x => x.UnitNumber).HasMaxLength(10); + builder.Property(x => x.UnitType).HasMaxLength(10); + + builder.HasMany(x => x.TasksList).WithOne(x => x.TaskSchedule) + .HasForeignKey(x => x.TaskScheduleId); + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TicketAccessAccountMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TicketAccessAccountMapping.cs new file mode 100644 index 00000000..9c1ac463 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TicketAccessAccountMapping.cs @@ -0,0 +1,14 @@ +using AccountManagement.Domain.TicketAccessAccountAgg; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace AccountMangement.Infrastructure.EFCore.Mappings; + +public class TicketAccessAccountMapping:IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("TicketAccessAccounts"); + builder.HasKey(x => x.id); + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/TicketMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/TicketMapping.cs index 0ca34f93..d346e318 100644 --- a/AccountMangement.Infrastructure.EFCore/Mappings/TicketMapping.cs +++ b/AccountMangement.Infrastructure.EFCore/Mappings/TicketMapping.cs @@ -13,15 +13,12 @@ public class TicketMapping:IEntityTypeConfiguration builder.ToTable("Tickets"); - builder.Property(x => x.TaskId).IsRequired(false); builder.Property(x => x.ContractingPartyName).HasMaxLength(155); builder.Property(x => x.TicketType).HasMaxLength(50); builder.Property(x => x.Title).HasMaxLength(200); builder.Property(x => x.Description).HasColumnType("ntext"); builder.Property(x => x.Status).HasMaxLength(30); - - - + builder.Property(x => x.TicketNumber).HasMaxLength(12); builder.HasMany(x => x.ClientResponses).WithOne(x => x.Ticket).HasForeignKey(x => x.TicketId); builder.HasMany(x => x.TicketMedias).WithOne(x => x.Ticket).HasForeignKey(x => x.MediaId); builder.HasMany(x => x.AdminResponses).WithOne(x => x.Ticket).HasForeignKey(x => x.TicketId); diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240821152830_AccountTableChanges.Designer.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240821152830_AccountTableChanges.Designer.cs new file mode 100644 index 00000000..232bc598 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240821152830_AccountTableChanges.Designer.cs @@ -0,0 +1,772 @@ +// +using System; +using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + [DbContext(typeof(AccountContext))] + [Migration("20240821152830_AccountTableChanges")] + partial class AccountTableChanges + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAreaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ClientAriaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Fullname") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActiveString") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PositionId") + .HasMaxLength(10) + .HasColumnType("bigint"); + + b.Property("PositionIsActive") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("id"); + + b.HasIndex("PositionId"); + + b.HasIndex("RoleId"); + + b.ToTable("Accounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountLeftWorkAgg.AccountLeftWork", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("LeftWorkGr") + .HasColumnType("datetime2"); + + b.Property("StartWorkGr") + .HasColumnType("datetime2"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("AccountLeftWork", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("AdminResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.Property("AdminResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("AdminResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("AdminResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignedId") + .HasColumnType("bigint"); + + b.Property("AssignedName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("AssignedPositionValue") + .HasColumnType("int"); + + b.Property("AssignerId") + .HasColumnType("bigint"); + + b.Property("AssignerPositionValue") + .HasColumnType("int"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskId"); + + b.ToTable("Assigns", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveSting") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Mobile") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.Property("WorkshopName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("CameraAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("ClientResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.Property("ClientResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("ClientResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("ClientResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Category") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Path") + .HasColumnType("ntext"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("Medias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("ContractingPartyName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveString") + .HasMaxLength(7) + .HasColumnType("nvarchar(7)"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("IsDoneRequest") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("StartTaskDate") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TasksManager", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.Property("MediaId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("MediaId", "TaskId"); + + b.HasIndex("TaskId"); + + b.ToTable("TasksMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TaskSubjects", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(155) + .HasColumnType("nvarchar(155)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("Status") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("TicketType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("id"); + + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("TicketId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("TicketMedias", (string)null); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PositionName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PositionValue") + .HasMaxLength(2) + .HasColumnType("int"); + + b.HasKey("id"); + + b.ToTable("Positions", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.HasOne("TaskManager.Domain.PositionAgg.Position", "Position") + .WithMany("Accounts") + .HasForeignKey("PositionId"); + + b.HasOne("AccountManagement.Domain.RoleAgg.Role", "Role") + .WithMany("Accounts") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountLeftWorkAgg.AccountLeftWork", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("AccountLeftWorkList") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("AdminResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.AdminResponseAgg.AdminResponse", "AdminResponse") + .WithMany("AdminResponseMedias") + .HasForeignKey("AdminResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("AdminResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AdminResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Task") + .WithMany("Assigns") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("CameraAccounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("ClientResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.ClientResponseAgg.ClientResponse", "ClientResponse") + .WithMany("ClientResponseMedias") + .HasForeignKey("ClientResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("ClientResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ClientResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("RolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TaskMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Tasks") + .WithMany("TaskMedias") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TicketMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("TicketMedias") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Navigation("AccountLeftWorkList"); + + b.Navigation("CameraAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Navigation("AdminResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Navigation("ClientResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Navigation("AdminResponseMedias"); + + b.Navigation("ClientResponseMedias"); + + b.Navigation("TaskMedias"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Navigation("Assigns"); + + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Navigation("AdminResponses"); + + b.Navigation("ClientResponses"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Navigation("Accounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240821152830_AccountTableChanges.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240821152830_AccountTableChanges.cs new file mode 100644 index 00000000..53f39901 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240821152830_AccountTableChanges.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + /// + public partial class AccountTableChanges : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "PositionIsActive", + table: "Accounts", + type: "nvarchar(5)", + maxLength: 5, + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "PositionIsActive", + table: "Accounts"); + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240821154206_taskMessageTables_AssignChanges.Designer.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240821154206_taskMessageTables_AssignChanges.Designer.cs new file mode 100644 index 00000000..284286bd --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240821154206_taskMessageTables_AssignChanges.Designer.cs @@ -0,0 +1,896 @@ +// +using System; +using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + [DbContext(typeof(AccountContext))] + [Migration("20240821154206_taskMessageTables_AssignChanges")] + partial class taskMessageTables_AssignChanges + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAreaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ClientAriaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Fullname") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActiveString") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PositionId") + .HasMaxLength(10) + .HasColumnType("bigint"); + + b.Property("PositionIsActive") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("id"); + + b.HasIndex("PositionId"); + + b.HasIndex("RoleId"); + + b.ToTable("Accounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountLeftWorkAgg.AccountLeftWork", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("LeftWorkGr") + .HasColumnType("datetime2"); + + b.Property("StartWorkGr") + .HasColumnType("datetime2"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("AccountLeftWork", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("AdminResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.Property("AdminResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("AdminResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("AdminResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("AssignedId") + .HasColumnType("bigint"); + + b.Property("AssignedName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("AssignedPositionValue") + .HasColumnType("int"); + + b.Property("AssignerId") + .HasColumnType("bigint"); + + b.Property("AssignerPositionValue") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("IsDoneRequest") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.HasKey("id"); + + b.HasIndex("TaskId"); + + b.ToTable("Assigns", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveSting") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Mobile") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.Property("WorkshopName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("CameraAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("ClientResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.Property("ClientResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("ClientResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("ClientResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Category") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Path") + .HasColumnType("ntext"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("Medias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("ContractingPartyName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveString") + .HasMaxLength(7) + .HasColumnType("nvarchar(7)"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("IsDoneRequest") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("StartTaskDate") + .HasColumnType("datetime2"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TasksManager", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.Property("MediaId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("MediaId", "TaskId"); + + b.HasIndex("TaskId"); + + b.ToTable("TasksMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Message") + .HasColumnType("ntext"); + + b.Property("RequestedDateFa") + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.Property("TypeOfMessage") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("id"); + + b.HasIndex("AssignId"); + + b.ToTable("TaskMessages", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageItemsAgg.TaskMessageItems", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ReceiverAccountId") + .HasColumnType("bigint"); + + b.Property("SenderAccountId") + .HasColumnType("bigint"); + + b.Property("TaskMessageId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskMessageId"); + + b.ToTable("TaskMessageItems", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TaskSubjects", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(155) + .HasColumnType("nvarchar(155)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("Status") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("TicketType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("id"); + + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("TicketId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("TicketMedias", (string)null); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PositionName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PositionValue") + .HasMaxLength(2) + .HasColumnType("int"); + + b.HasKey("id"); + + b.ToTable("Positions", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.HasOne("TaskManager.Domain.PositionAgg.Position", "Position") + .WithMany("Accounts") + .HasForeignKey("PositionId"); + + b.HasOne("AccountManagement.Domain.RoleAgg.Role", "Role") + .WithMany("Accounts") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountLeftWorkAgg.AccountLeftWork", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("AccountLeftWorkList") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("AdminResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.AdminResponseAgg.AdminResponse", "AdminResponse") + .WithMany("AdminResponseMedias") + .HasForeignKey("AdminResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("AdminResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AdminResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Task") + .WithMany("Assigns") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("CameraAccounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("ClientResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.ClientResponseAgg.ClientResponse", "ClientResponse") + .WithMany("ClientResponseMedias") + .HasForeignKey("ClientResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("ClientResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ClientResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("RolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TaskMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Tasks") + .WithMany("TaskMedias") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.HasOne("AccountManagement.Domain.AssignAgg.Assign", "Assign") + .WithMany("TaskMessageList") + .HasForeignKey("AssignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Assign"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageItemsAgg.TaskMessageItems", b => + { + b.HasOne("AccountManagement.Domain.TaskMessageAgg.TaskMessage", "TaskMessage") + .WithMany("TaskMessageItemsList") + .HasForeignKey("TaskMessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TaskMessage"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TicketMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("TicketMedias") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Navigation("AccountLeftWorkList"); + + b.Navigation("CameraAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Navigation("AdminResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Navigation("TaskMessageList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Navigation("ClientResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Navigation("AdminResponseMedias"); + + b.Navigation("ClientResponseMedias"); + + b.Navigation("TaskMedias"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Navigation("Assigns"); + + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.Navigation("TaskMessageItemsList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Navigation("AdminResponses"); + + b.Navigation("ClientResponses"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Navigation("Accounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240821154206_taskMessageTables_AssignChanges.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240821154206_taskMessageTables_AssignChanges.cs new file mode 100644 index 00000000..055d19a2 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240821154206_taskMessageTables_AssignChanges.cs @@ -0,0 +1,197 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + /// + public partial class taskMessageTables_AssignChanges : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "AcceptedTimeRequest", + table: "Assigns", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "CancelDescription", + table: "Assigns", + type: "ntext", + nullable: true); + + migrationBuilder.AddColumn( + name: "DoneDescription", + table: "Assigns", + type: "ntext", + nullable: true); + + migrationBuilder.AddColumn( + name: "EndTaskDate", + table: "Assigns", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "IsCancel", + table: "Assigns", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsCanceledRequest", + table: "Assigns", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsDone", + table: "Assigns", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsDoneRequest", + table: "Assigns", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "RequestDate", + table: "Assigns", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "TimeRequest", + table: "Assigns", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "TimeRequestDescription", + table: "Assigns", + type: "ntext", + nullable: true); + + migrationBuilder.CreateTable( + name: "TaskMessages", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Message = table.Column(type: "ntext", nullable: true), + TypeOfMessage = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: true), + RequestedDateFa = table.Column(type: "nvarchar(25)", maxLength: 25, nullable: true), + AssignId = table.Column(type: "bigint", nullable: false), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TaskMessages", x => x.id); + table.ForeignKey( + name: "FK_TaskMessages_Assigns_AssignId", + column: x => x.AssignId, + principalTable: "Assigns", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "TaskMessageItems", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SenderAccountId = table.Column(type: "bigint", nullable: false), + ReceiverAccountId = table.Column(type: "bigint", nullable: false), + TaskMessageId = table.Column(type: "bigint", nullable: false), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TaskMessageItems", x => x.id); + table.ForeignKey( + name: "FK_TaskMessageItems_TaskMessages_TaskMessageId", + column: x => x.TaskMessageId, + principalTable: "TaskMessages", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_TaskMessageItems_TaskMessageId", + table: "TaskMessageItems", + column: "TaskMessageId"); + + migrationBuilder.CreateIndex( + name: "IX_TaskMessages_AssignId", + table: "TaskMessages", + column: "AssignId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TaskMessageItems"); + + migrationBuilder.DropTable( + name: "TaskMessages"); + + migrationBuilder.DropColumn( + name: "AcceptedTimeRequest", + table: "Assigns"); + + migrationBuilder.DropColumn( + name: "CancelDescription", + table: "Assigns"); + + migrationBuilder.DropColumn( + name: "DoneDescription", + table: "Assigns"); + + migrationBuilder.DropColumn( + name: "EndTaskDate", + table: "Assigns"); + + migrationBuilder.DropColumn( + name: "IsCancel", + table: "Assigns"); + + migrationBuilder.DropColumn( + name: "IsCanceledRequest", + table: "Assigns"); + + migrationBuilder.DropColumn( + name: "IsDone", + table: "Assigns"); + + migrationBuilder.DropColumn( + name: "IsDoneRequest", + table: "Assigns"); + + migrationBuilder.DropColumn( + name: "RequestDate", + table: "Assigns"); + + migrationBuilder.DropColumn( + name: "TimeRequest", + table: "Assigns"); + + migrationBuilder.DropColumn( + name: "TimeRequestDescription", + table: "Assigns"); + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240821171716_Task_TicketChanges.Designer.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240821171716_Task_TicketChanges.Designer.cs new file mode 100644 index 00000000..96d2a598 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240821171716_Task_TicketChanges.Designer.cs @@ -0,0 +1,951 @@ +// +using System; +using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + [DbContext(typeof(AccountContext))] + [Migration("20240821171716_Task_TicketChanges")] + partial class Task_TicketChanges + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAreaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("ClientAriaPermission") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Fullname") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsActiveString") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("Mobile") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("NationalCode") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("PositionId") + .HasMaxLength(10) + .HasColumnType("bigint"); + + b.Property("PositionIsActive") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("ProfilePhoto") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("RoleName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("VerifyCode") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.HasKey("id"); + + b.HasIndex("PositionId"); + + b.HasIndex("RoleId"); + + b.ToTable("Accounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountLeftWorkAgg.AccountLeftWork", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("LeftWorkGr") + .HasColumnType("datetime2"); + + b.Property("StartWorkGr") + .HasColumnType("datetime2"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("AccountLeftWork", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AdminAccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveString") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("AdminResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.Property("AdminResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("AdminResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("AdminResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + + b.Property("AssignedId") + .HasColumnType("bigint"); + + b.Property("AssignedName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("AssignedPositionValue") + .HasColumnType("int"); + + b.Property("AssignerId") + .HasColumnType("bigint"); + + b.Property("AssignerPositionValue") + .HasColumnType("int"); + + b.Property("CancelDescription") + .HasColumnType("ntext"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("IsDoneRequest") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + + b.HasKey("id"); + + b.HasIndex("TaskId"); + + b.ToTable("Assigns", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("IsActiveSting") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Mobile") + .HasMaxLength(11) + .HasColumnType("nvarchar(11)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.Property("WorkshopName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("AccountId"); + + b.ToTable("CameraAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Response") + .HasColumnType("ntext"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TicketId"); + + b.ToTable("ClientResponses", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.Property("ClientResponseId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("ClientResponseId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("ClientResponseMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Category") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Path") + .HasColumnType("ntext"); + + b.Property("Type") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("Medias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("IsActiveString") + .HasMaxLength(7) + .HasColumnType("nvarchar(7)"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("StartTaskDate") + .HasColumnType("datetime2"); + + b.Property("TaskScheduleId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.HasIndex("TaskScheduleId"); + + b.ToTable("TasksManager", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.Property("MediaId") + .HasColumnType("bigint"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.HasKey("MediaId", "TaskId"); + + b.HasIndex("TaskId"); + + b.ToTable("TasksMedias", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Message") + .HasColumnType("ntext"); + + b.Property("RequestedDateFa") + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.Property("TypeOfMessage") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("id"); + + b.HasIndex("AssignId"); + + b.ToTable("TaskMessages", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageItemsAgg.TaskMessageItems", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ReceiverAccountId") + .HasColumnType("bigint"); + + b.Property("SenderAccountId") + .HasColumnType("bigint"); + + b.Property("TaskMessageId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskMessageId"); + + b.ToTable("TaskMessageItems", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Count") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("LastEndTaskDate") + .HasColumnType("datetime2"); + + b.Property("Type") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("UnitNumber") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("UnitType") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("TaskSchedules", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Subject") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("id"); + + b.ToTable("TaskSubjects", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAccessAccountAgg.TicketAccessAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.HasKey("id"); + + b.ToTable("TicketAccessAccounts", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("ContractingPartyName") + .HasMaxLength(155) + .HasColumnType("nvarchar(155)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("ntext"); + + b.Property("SenderId") + .HasColumnType("bigint"); + + b.Property("Status") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("SubAccountSenderId") + .HasColumnType("bigint"); + + b.Property("TicketNumber") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("TicketType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("WorkshopId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("MediaId") + .HasColumnType("bigint"); + + b.HasKey("TicketId", "MediaId"); + + b.HasIndex("MediaId"); + + b.ToTable("TicketMedias", (string)null); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("PositionName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("PositionValue") + .HasMaxLength(2) + .HasColumnType("int"); + + b.HasKey("id"); + + b.ToTable("Positions", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.HasOne("TaskManager.Domain.PositionAgg.Position", "Position") + .WithMany("Accounts") + .HasForeignKey("PositionId"); + + b.HasOne("AccountManagement.Domain.RoleAgg.Role", "Role") + .WithMany("Accounts") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Position"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountLeftWorkAgg.AccountLeftWork", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("AccountLeftWorkList") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("AdminResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseMediaAgg.AdminResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.AdminResponseAgg.AdminResponse", "AdminResponse") + .WithMany("AdminResponseMedias") + .HasForeignKey("AdminResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("AdminResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AdminResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Task") + .WithMany("Assigns") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Task"); + }); + + modelBuilder.Entity("AccountManagement.Domain.CameraAccountAgg.CameraAccount", b => + { + b.HasOne("AccountManagement.Domain.AccountAgg.Account", "Account") + .WithMany("CameraAccounts") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("ClientResponses") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseMediaAgg.ClientResponseMedia", b => + { + b.HasOne("AccountManagement.Domain.ClientResponseAgg.ClientResponse", "ClientResponse") + .WithMany("ClientResponseMedias") + .HasForeignKey("ClientResponseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("ClientResponseMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ClientResponse"); + + b.Navigation("Media"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Code") + .HasColumnType("int"); + + b1.Property("RoleId") + .HasColumnType("bigint"); + + b1.HasKey("Id"); + + b1.HasIndex("RoleId"); + + b1.ToTable("RolePermissions", (string)null); + + b1.WithOwner("Role") + .HasForeignKey("RoleId"); + + b1.Navigation("Role"); + }); + + b.Navigation("Permissions"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.HasOne("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", "TaskSchedule") + .WithMany("TasksList") + .HasForeignKey("TaskScheduleId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("TaskSchedule"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TaskMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TaskAgg.Tasks", "Tasks") + .WithMany("TaskMedias") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.HasOne("AccountManagement.Domain.AssignAgg.Assign", "Assign") + .WithMany("TaskMessageList") + .HasForeignKey("AssignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Assign"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageItemsAgg.TaskMessageItems", b => + { + b.HasOne("AccountManagement.Domain.TaskMessageAgg.TaskMessage", "TaskMessage") + .WithMany("TaskMessageItemsList") + .HasForeignKey("TaskMessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TaskMessage"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => + { + b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") + .WithMany("TicketMedias") + .HasForeignKey("MediaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("AccountManagement.Domain.TicketAgg.Ticket", "Ticket") + .WithMany("TicketMedias") + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Media"); + + b.Navigation("Ticket"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AccountAgg.Account", b => + { + b.Navigation("AccountLeftWorkList"); + + b.Navigation("CameraAccounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AdminResponseAgg.AdminResponse", b => + { + b.Navigation("AdminResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Navigation("TaskMessageList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => + { + b.Navigation("ClientResponseMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.MediaAgg.Media", b => + { + b.Navigation("AdminResponseMedias"); + + b.Navigation("ClientResponseMedias"); + + b.Navigation("TaskMedias"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => + { + b.Navigation("Accounts"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.Navigation("Assigns"); + + b.Navigation("TaskMedias"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.Navigation("TaskMessageItemsList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", b => + { + b.Navigation("TasksList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => + { + b.Navigation("AdminResponses"); + + b.Navigation("ClientResponses"); + + b.Navigation("TicketMedias"); + }); + + modelBuilder.Entity("TaskManager.Domain.PositionAgg.Position", b => + { + b.Navigation("Accounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/20240821171716_Task_TicketChanges.cs b/AccountMangement.Infrastructure.EFCore/Migrations/20240821171716_Task_TicketChanges.cs new file mode 100644 index 00000000..933161dc --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Migrations/20240821171716_Task_TicketChanges.cs @@ -0,0 +1,270 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AccountMangement.Infrastructure.EFCore.Migrations +{ + /// + public partial class Task_TicketChanges : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "TaskId", + table: "Tickets"); + + migrationBuilder.DropColumn( + name: "AcceptedTimeRequest", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "CancelDescription", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "DoneDescription", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "EndTaskDate", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "IsCancel", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "IsCanceledRequest", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "IsDone", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "IsDoneRequest", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "RequestDate", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "TimeRequest", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "TimeRequestDescription", + table: "TasksManager"); + + migrationBuilder.AddColumn( + name: "SubAccountSenderId", + table: "Tickets", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "TicketNumber", + table: "Tickets", + type: "nvarchar(12)", + maxLength: 12, + nullable: true); + + migrationBuilder.AddColumn( + name: "WorkshopId", + table: "Tickets", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "TaskScheduleId", + table: "TasksManager", + type: "bigint", + nullable: true); + + migrationBuilder.AddColumn( + name: "AdminAccountId", + table: "AdminResponses", + type: "bigint", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "IsActiveString", + table: "AdminResponses", + type: "nvarchar(5)", + maxLength: 5, + nullable: true); + + migrationBuilder.CreateTable( + name: "TaskSchedules", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Count = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: true), + Type = table.Column(type: "nvarchar(12)", maxLength: 12, nullable: true), + UnitType = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: true), + UnitNumber = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: true), + LastEndTaskDate = table.Column(type: "datetime2", nullable: false), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TaskSchedules", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "TicketAccessAccounts", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AccountId = table.Column(type: "bigint", nullable: false), + CreationDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TicketAccessAccounts", x => x.id); + }); + + migrationBuilder.CreateIndex( + name: "IX_TasksManager_TaskScheduleId", + table: "TasksManager", + column: "TaskScheduleId"); + + migrationBuilder.AddForeignKey( + name: "FK_TasksManager_TaskSchedules_TaskScheduleId", + table: "TasksManager", + column: "TaskScheduleId", + principalTable: "TaskSchedules", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_TasksManager_TaskSchedules_TaskScheduleId", + table: "TasksManager"); + + migrationBuilder.DropTable( + name: "TaskSchedules"); + + migrationBuilder.DropTable( + name: "TicketAccessAccounts"); + + migrationBuilder.DropIndex( + name: "IX_TasksManager_TaskScheduleId", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "SubAccountSenderId", + table: "Tickets"); + + migrationBuilder.DropColumn( + name: "TicketNumber", + table: "Tickets"); + + migrationBuilder.DropColumn( + name: "WorkshopId", + table: "Tickets"); + + migrationBuilder.DropColumn( + name: "TaskScheduleId", + table: "TasksManager"); + + migrationBuilder.DropColumn( + name: "AdminAccountId", + table: "AdminResponses"); + + migrationBuilder.DropColumn( + name: "IsActiveString", + table: "AdminResponses"); + + migrationBuilder.AddColumn( + name: "TaskId", + table: "Tickets", + type: "bigint", + nullable: true); + + migrationBuilder.AddColumn( + name: "AcceptedTimeRequest", + table: "TasksManager", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "CancelDescription", + table: "TasksManager", + type: "ntext", + nullable: true); + + migrationBuilder.AddColumn( + name: "DoneDescription", + table: "TasksManager", + type: "ntext", + nullable: true); + + migrationBuilder.AddColumn( + name: "EndTaskDate", + table: "TasksManager", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "IsCancel", + table: "TasksManager", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsCanceledRequest", + table: "TasksManager", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsDone", + table: "TasksManager", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsDoneRequest", + table: "TasksManager", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "RequestDate", + table: "TasksManager", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "TimeRequest", + table: "TasksManager", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "TimeRequestDescription", + table: "TasksManager", + type: "ntext", + nullable: true); + } + } +} diff --git a/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs b/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs index 0dcdbbb8..051be14a 100644 --- a/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs +++ b/AccountMangement.Infrastructure.EFCore/Migrations/AccountContextModelSnapshot.cs @@ -72,6 +72,10 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations .HasMaxLength(10) .HasColumnType("bigint"); + b.Property("PositionIsActive") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + b.Property("ProfilePhoto") .HasMaxLength(500) .HasColumnType("nvarchar(500)"); @@ -136,9 +140,16 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + b.Property("AdminAccountId") + .HasColumnType("bigint"); + b.Property("CreationDate") .HasColumnType("datetime2"); + b.Property("IsActiveString") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + b.Property("Response") .HasColumnType("ntext"); @@ -175,6 +186,9 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + b.Property("AcceptedTimeRequest") + .HasColumnType("int"); + b.Property("AssignedId") .HasColumnType("bigint"); @@ -191,12 +205,42 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations b.Property("AssignerPositionValue") .HasColumnType("int"); + b.Property("CancelDescription") + .HasColumnType("ntext"); + b.Property("CreationDate") .HasColumnType("datetime2"); + b.Property("DoneDescription") + .HasColumnType("ntext"); + + b.Property("EndTaskDate") + .HasColumnType("datetime2"); + + b.Property("IsCancel") + .HasColumnType("bit"); + + b.Property("IsCanceledRequest") + .HasColumnType("bit"); + + b.Property("IsDone") + .HasColumnType("bit"); + + b.Property("IsDoneRequest") + .HasColumnType("bit"); + + b.Property("RequestDate") + .HasColumnType("datetime2"); + b.Property("TaskId") .HasColumnType("bigint"); + b.Property("TimeRequest") + .HasColumnType("bit"); + + b.Property("TimeRequestDescription") + .HasColumnType("ntext"); + b.HasKey("id"); b.HasIndex("TaskId"); @@ -346,12 +390,6 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); - b.Property("AcceptedTimeRequest") - .HasColumnType("int"); - - b.Property("CancelDescription") - .HasColumnType("ntext"); - b.Property("ContractingPartyName") .HasMaxLength(200) .HasColumnType("nvarchar(200)"); @@ -362,45 +400,21 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations b.Property("Description") .HasColumnType("ntext"); - b.Property("DoneDescription") - .HasColumnType("ntext"); - - b.Property("EndTaskDate") - .HasColumnType("datetime2"); - b.Property("IsActiveString") .HasMaxLength(7) .HasColumnType("nvarchar(7)"); - b.Property("IsCancel") - .HasColumnType("bit"); - - b.Property("IsCanceledRequest") - .HasColumnType("bit"); - - b.Property("IsDone") - .HasColumnType("bit"); - - b.Property("IsDoneRequest") - .HasColumnType("bit"); - - b.Property("RequestDate") - .HasColumnType("datetime2"); - b.Property("SenderId") .HasColumnType("bigint"); b.Property("StartTaskDate") .HasColumnType("datetime2"); - b.Property("TicketId") + b.Property("TaskScheduleId") .HasColumnType("bigint"); - b.Property("TimeRequest") - .HasColumnType("bit"); - - b.Property("TimeRequestDescription") - .HasColumnType("ntext"); + b.Property("TicketId") + .HasColumnType("bigint"); b.Property("Title") .IsRequired() @@ -409,6 +423,8 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations b.HasKey("id"); + b.HasIndex("TaskScheduleId"); + b.ToTable("TasksManager", (string)null); }); @@ -427,6 +443,100 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations b.ToTable("TasksMedias", (string)null); }); + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AssignId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Message") + .HasColumnType("ntext"); + + b.Property("RequestedDateFa") + .HasMaxLength(25) + .HasColumnType("nvarchar(25)"); + + b.Property("TypeOfMessage") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("id"); + + b.HasIndex("AssignId"); + + b.ToTable("TaskMessages", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageItemsAgg.TaskMessageItems", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ReceiverAccountId") + .HasColumnType("bigint"); + + b.Property("SenderAccountId") + .HasColumnType("bigint"); + + b.Property("TaskMessageId") + .HasColumnType("bigint"); + + b.HasKey("id"); + + b.HasIndex("TaskMessageId"); + + b.ToTable("TaskMessageItems", (string)null); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("Count") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("LastEndTaskDate") + .HasColumnType("datetime2"); + + b.Property("Type") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("UnitNumber") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("UnitType") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.HasKey("id"); + + b.ToTable("TaskSchedules", (string)null); + }); + modelBuilder.Entity("AccountManagement.Domain.TaskSubjectAgg.TaskSubject", b => { b.Property("id") @@ -448,6 +558,25 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations b.ToTable("TaskSubjects", (string)null); }); + modelBuilder.Entity("AccountManagement.Domain.TicketAccessAccountAgg.TicketAccessAccount", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); + + b.Property("AccountId") + .HasColumnType("bigint"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.HasKey("id"); + + b.ToTable("TicketAccessAccounts", (string)null); + }); + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => { b.Property("id") @@ -473,9 +602,13 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations .HasMaxLength(30) .HasColumnType("nvarchar(30)"); - b.Property("TaskId") + b.Property("SubAccountSenderId") .HasColumnType("bigint"); + b.Property("TicketNumber") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + b.Property("TicketType") .HasMaxLength(50) .HasColumnType("nvarchar(50)"); @@ -484,6 +617,9 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations .HasMaxLength(200) .HasColumnType("nvarchar(200)"); + b.Property("WorkshopId") + .HasColumnType("bigint"); + b.HasKey("id"); b.ToTable("Tickets", (string)null); @@ -639,7 +775,7 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations modelBuilder.Entity("AccountManagement.Domain.RoleAgg.Role", b => { - b.OwnsMany("AccountManagement.Domain.RoleAgg.Role.Permissions#AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => + b.OwnsMany("AccountManagement.Domain.RoleAgg.Permission", "Permissions", b1 => { b1.Property("Id") .ValueGeneratedOnAdd() @@ -668,6 +804,16 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations b.Navigation("Permissions"); }); + modelBuilder.Entity("AccountManagement.Domain.TaskAgg.Tasks", b => + { + b.HasOne("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", "TaskSchedule") + .WithMany("TasksList") + .HasForeignKey("TaskScheduleId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("TaskSchedule"); + }); + modelBuilder.Entity("AccountManagement.Domain.TaskMediaAgg.TaskMedia", b => { b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") @@ -687,6 +833,28 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations b.Navigation("Tasks"); }); + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.HasOne("AccountManagement.Domain.AssignAgg.Assign", "Assign") + .WithMany("TaskMessageList") + .HasForeignKey("AssignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Assign"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskMessageItemsAgg.TaskMessageItems", b => + { + b.HasOne("AccountManagement.Domain.TaskMessageAgg.TaskMessage", "TaskMessage") + .WithMany("TaskMessageItemsList") + .HasForeignKey("TaskMessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TaskMessage"); + }); + modelBuilder.Entity("AccountManagement.Domain.TicketMediasAgg.TicketMedia", b => { b.HasOne("AccountManagement.Domain.MediaAgg.Media", "Media") @@ -718,6 +886,11 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations b.Navigation("AdminResponseMedias"); }); + modelBuilder.Entity("AccountManagement.Domain.AssignAgg.Assign", b => + { + b.Navigation("TaskMessageList"); + }); + modelBuilder.Entity("AccountManagement.Domain.ClientResponseAgg.ClientResponse", b => { b.Navigation("ClientResponseMedias"); @@ -746,6 +919,16 @@ namespace AccountMangement.Infrastructure.EFCore.Migrations b.Navigation("TaskMedias"); }); + modelBuilder.Entity("AccountManagement.Domain.TaskMessageAgg.TaskMessage", b => + { + b.Navigation("TaskMessageItemsList"); + }); + + modelBuilder.Entity("AccountManagement.Domain.TaskScheduleAgg.TaskSchedule", b => + { + b.Navigation("TasksList"); + }); + modelBuilder.Entity("AccountManagement.Domain.TicketAgg.Ticket", b => { b.Navigation("AdminResponses"); diff --git a/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs index 5ab11099..a3c0223f 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/AccountRepository.cs @@ -196,9 +196,8 @@ public class AccountRepository : RepositoryBase, IAccountReposito PositionValue = x.Position.PositionValue, PositionId = x.Position.id, IsActiveString = x.IsActiveString, - Username = x.Username - - + Username = x.Username, + PositionIsActive = x.PositionIsActive }).ToList(); } @@ -209,7 +208,7 @@ public class AccountRepository : RepositoryBase, IAccountReposito var assignerIds = _context.Assigns.Where(x => x.TaskId == taskId).Select(x => x.AssignerId).ToList(); return _context.Accounts.Include(x => x.Position).Where(x => - x.Position.PositionValue > posValue && !assignerIds.Contains(x.id) && !assignedIds.Contains(x.id)).Select( + x.Position.PositionValue >= posValue && !assignerIds.Contains(x.id) && !assignedIds.Contains(x.id)).Select( x => new AccountViewModel() { PositionValue = x.Position.PositionValue, @@ -230,7 +229,7 @@ public class AccountRepository : RepositoryBase, IAccountReposito var account = GetIncludePositions(int.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value)); return _context.Accounts.Include(x => x.Position) - .Where(x => x.Position.PositionValue >= account.Position.PositionValue && x.IsActiveString == "true").Select(x => new AccountViewModel() + .Where(x => x.Position.PositionValue > account.Position.PositionValue && x.IsActiveString == "true").Select(x => new AccountViewModel() { PositionValue = x.Position.PositionValue, Id = x.id, @@ -270,24 +269,33 @@ public class AccountRepository : RepositoryBase, IAccountReposito }).FirstOrDefault(x => x.Id == id); } + + public List GetAccountsDeactivePositionValue(long Positionid) + { + return _context.Accounts.Where(x => x.PositionId == Positionid && x.PositionIsActive == "false").Select(x => new AccountViewModel() + { + Id = x.id, + Fullname = x.Fullname + }).ToList(); + } //public List GetAdminAccounts() //{ - // return _context.Accounts.Where(x=>x.AdminAreaPermission == "true" && x.IsActiveString == "true").Select(x => new AccountViewModel() - // { - // Id = x.id, - // Fullname = x.Fullname, - // RoleName = x.RoleName, - // Username = x.Username, - // RoleId = x.RoleId, - // Mobile = x.Mobile, - // CreationDateGr = x.CreationDate, - // IsActiveString = x.IsActiveString, - - + // return _context.Accounts.Where(x=>x.AdminAreaPermission == "true" && x.IsActiveString == "true").Select(x => new AccountViewModel() + // { + // Id = x.id, + // Fullname = x.Fullname, + // RoleName = x.RoleName, + // Username = x.Username, + // RoleId = x.RoleId, + // Mobile = x.Mobile, + // CreationDateGr = x.CreationDate, + // IsActiveString = x.IsActiveString, - // }).ToList(); + + + // }).ToList(); //} - #endregion + #endregion } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Repository/AssignRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/AssignRepository.cs index 2ae0c0cc..b99f4578 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/AssignRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/AssignRepository.cs @@ -1,37 +1,65 @@ - -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using _0_Framework.InfraStructure; using AccountManagement.Application.Contracts.Assign; using AccountManagement.Domain.AssignAgg; using AccountMangement.Infrastructure.EFCore; +using Microsoft.EntityFrameworkCore; + namespace AccountMangement.Infrastructure.EFCore.Repository; public class AssignRepository :RepositoryBase,IAssignRepository { - private readonly AccountContext _taskManagerContext; - public AssignRepository(AccountContext taskManagerContext) : base(taskManagerContext) + private readonly AccountContext _accountContext; + public AssignRepository(AccountContext accountContext) : base(accountContext) { - _taskManagerContext = taskManagerContext; + _accountContext = accountContext; } public List GetAssignsByTaskId(long id) { - return _taskManagerContext.Assigns.Where(x=>x.TaskId==id).Select(x => new AssignViewModel() + return _accountContext.Assigns.Where(x=>x.TaskId==id).Select(x => new AssignViewModel() { - AssignedId = _taskManagerContext.Assigns.Where(e=>e.TaskId==id&&e.AssignerId==x.AssignerId).Select(a=>a.AssignedId).ToList(), + AssignedId = x.AssignedId, AssignerId = x.AssignerId, AssignerPositionValue = x.AssignerPositionValue, Id = x.id, TaskId = x.TaskId, - AssignedName = x.AssignedName + AssignedName = x.AssignedName, + TimeRequest = x.TimeRequest, + IsCancel = x.IsCancel, + EndTaskDateGr = x.EndTaskDate, + IsDone = x.IsDone, + IsDoneRequest = x.IsDoneRequest, + IsCanceledRequest = x.IsCanceledRequest, + AcceptedTimeRequest = x.AcceptedTimeRequest, + RequestDate = x.RequestDate, + AssignedPositionValue = x.AssignedPositionValue, + CancelDescription = x.CancelDescription, + DoneDescription = x.DoneDescription, + TimeRequestDescription = x.TimeRequestDescription, }).ToList(); } public void RemoveRangeAssigns( long taskId) { - var assigns= _taskManagerContext.Assigns.Where(x => x.TaskId == taskId); - _taskManagerContext.RemoveRange(assigns); - _taskManagerContext.SaveChanges(); + var assigns= _accountContext.Assigns.Where(x => x.TaskId == taskId); + _accountContext.RemoveRange(assigns); + _accountContext.SaveChanges(); + } + + public List GetAssignedIdsByTaskId(long taskId) + { + return _accountContext.Assigns.Where(x => x.TaskId == taskId).Select(x => x.AssignedId).ToList(); + } + + public Assign GetAssignByAssignedIdAndTaskId(long assignedId, long taskId) + { + return _accountContext.Assigns.Include(x=>x.Task).FirstOrDefault(x => x.TaskId == taskId && x.AssignedId == assignedId); + } + + public Assign GetIncludeTask(long id) + { + return _accountContext.Assigns.Include(x=>x.Task).FirstOrDefault(x => x.id == id); } } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs index b50e3ff1..f5df51aa 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/PositionRepository.cs @@ -30,7 +30,7 @@ public class PositionRepository : RepositoryBase, IPositionRepos Value = x.PositionValue, Id = x.id, Name = x.PositionName, - CountUsers = _accountContext.Accounts.Count(a => a.PositionId == x.id) + CountUsers = _accountContext.Accounts.Count(a => a.PositionId == x.id &&a.PositionIsActive=="true") @@ -47,6 +47,10 @@ public class PositionRepository : RepositoryBase, IPositionRepos Value = x.PositionValue, Id = x.id, Name = x.PositionName + + + + }).OrderBy(x => x.Value).ToList(); } @@ -61,14 +65,14 @@ public class PositionRepository : RepositoryBase, IPositionRepos public List GetNoPositionAccounts() { - return _accountContext.Accounts.Where(x => x.PositionId == null && x.IsActiveString == "true" && x.AdminAreaPermission == "true").Select(x => new AccountViewModel() + return _accountContext.Accounts.Where(x =>( x.PositionId == null || (x.PositionId !=null && x.PositionIsActive== "false"))&& x.IsActiveString == "true" && x.AdminAreaPermission == "true").Select(x => new AccountViewModel() { Id = x.id, Fullname = x.Fullname }).ToList(); } - public List GetAccountsByIds(List ids) + public List GetAccountsByPositionIds(List ids) { var res = _accountContext.Accounts.Include(x => x.Position).Where(x => x.PositionId != null); return res.Where(x => ids.Contains((long)x.PositionId)).ToList(); diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TaskMessageRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TaskMessageRepository.cs new file mode 100644 index 00000000..46b7c67a --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Repository/TaskMessageRepository.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using _0_Framework.Application; +using _0_Framework.InfraStructure; +using AccountManagement.Application.Contracts.TaskMessage; +using AccountManagement.Domain.AccountAgg; +using AccountManagement.Domain.AccountLeftWorkAgg; +using AccountManagement.Domain.TaskMessageAgg; +using AccountManagement.Domain.TaskMessageItemsAgg; +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore; + +namespace AccountMangement.Infrastructure.EFCore.Repository; + +public class TaskMessageRepository : RepositoryBase, ITaskMessageRepository +{ + private readonly AccountContext _accountContext; + private readonly IHttpContextAccessor _contextAccessor; + private readonly IAccountRepository _accountRepository; + public TaskMessageRepository(AccountContext accountContext, IHttpContextAccessor contextAccessor, IAccountRepository accountRepository) : base(accountContext) + { + _accountContext = accountContext; + _contextAccessor = contextAccessor; + _accountRepository = accountRepository; + } + + + public void CreateTaskMessageItems(long senderId, long receiverId, long messageId) + { + var messageItems = new TaskMessageItems(senderId, receiverId, messageId); + _accountContext.Add(messageItems); + _accountContext.SaveChanges(); + } + public List GetTaskMessages(long assignId) + { + var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); + var raw = _accountContext.TaskMessages.Include(x => x.TaskMessageItemsList).Include(x => x.Assign).Where(x => + x.AssignId == assignId && + x.TaskMessageItemsList.Any(x => x.ReceiverAccountId == accountId || x.SenderAccountId == accountId)).Select( + x => new TaskMessageViewModel() + { + SenderId = x.TaskMessageItemsList.First().SenderAccountId, + ReceiverId = x.TaskMessageItemsList.First().ReceiverAccountId, + CreationDate = $"{x.CreationDate.ToFarsi()} {x.CreationDate.DayOfWeek.DayOfWeeKToPersian()} {x.CreationDate.Hour}:{x.CreationDate.Minute}", + Message = x.Message, + TypeOfMessage = x.TypeOfMessage, + RequestedDateFa = x.RequestedDateFa + + }).ToList(); + + List res = raw.Select(x => new TaskMessageViewModel() + { + SenderId = x.SenderId, + CreationDate = x.CreationDate, + Message = x.Message, + TypeOfMessage = x.TypeOfMessage, + ReceiverId = x.ReceiverId, + SenderName = _accountRepository.GetAccountViewModel(x.SenderId).Fullname + }).ToList(); + return res; + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs index 30a588b0..92b8e6c7 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/TaskRepository.cs @@ -9,138 +9,187 @@ using AccountManagement.Application.Contracts.Account; using AccountManagement.Application.Contracts.Assign; using AccountManagement.Application.Contracts.Media; using AccountManagement.Application.Contracts.Task; +using AccountManagement.Application.Contracts.TaskMessage; using AccountManagement.Domain.AccountAgg; using AccountManagement.Domain.TaskAgg; +using AccountManagement.Domain.TicketAgg; using TaskManager.Domain.PositionAgg; using static Microsoft.EntityFrameworkCore.DbLoggerCategory; using Microsoft.Identity.Client; using Newtonsoft.Json.Linq; using Microsoft.AspNetCore.Hosting; +using AccountManagement.Application.Contracts.Ticket; namespace AccountMangement.Infrastructure.EFCore.Repository; -public class TaskRepository : RepositoryBase, ITaskRepository +public class + TaskRepository : RepositoryBase, ITaskRepository { - private readonly AccountContext _accountContext; - private readonly IHttpContextAccessor _contextAccessor; - private readonly IAccountRepository _accountRepository; - public readonly IPositionRepository _PositionRepository; - private readonly IWebHostEnvironment _webHostEnvironment; + private readonly AccountContext _accountContext; + private readonly IHttpContextAccessor _contextAccessor; + private readonly IAccountRepository _accountRepository; + private readonly IPositionRepository _positionRepository; + private readonly IWebHostEnvironment _webHostEnvironment; + private readonly IAuthHelper _authHelper; + private readonly ITicketRepository _ticketRepository; - public TaskRepository(IHttpContextAccessor contextAccessor, AccountContext accountContext, - IAccountRepository accountRepository, IPositionRepository positionRepository, IWebHostEnvironment webHostEnvironment) : base(accountContext) - { - _contextAccessor = contextAccessor; - _accountContext = accountContext; - _accountRepository = accountRepository; - _PositionRepository = positionRepository; - _webHostEnvironment = webHostEnvironment; - } + public TaskRepository(IHttpContextAccessor contextAccessor, AccountContext accountContext, + IAccountRepository accountRepository, IPositionRepository positionRepository, + IWebHostEnvironment webHostEnvironment, IAuthHelper authHelper, ITicketRepository ticketRepository) : base(accountContext) + { + _contextAccessor = contextAccessor; + _accountContext = accountContext; + _accountRepository = accountRepository; + _positionRepository = positionRepository; + _webHostEnvironment = webHostEnvironment; + _authHelper = authHelper; + _ticketRepository = ticketRepository; + } - public EditTask GetDetails(long TaskId) - { + public EditTask GetDetails(long TaskId) + { + var task = Get(TaskId); - return _accountContext.Tasks.Where(x => x.id == TaskId).Select(x => new EditTask() - { - EndTaskDate = x.EndTaskDate.ToFarsi(), - Description = x.Description, - Id = x.id, - Title = x.Title, - medias = _accountContext.TaskMedias.Include(z => z.Media).Where(e => e.TaskId == x.id).Select(m => - new MediaViewModel() - { - Path = m.Media.Path, - Type = m.Media.Type, - Category = m.Media.Category, - Id = m.Media.id - }).ToList(), - EndTaskTime = x.EndTaskDate.ToFarsiFull().Substring(11), - ContractingPartyName = x.ContractingPartyName, - CompleteDescription = x.DoneDescription, - IsDone = x.IsDone, - ReceiverId = _accountContext.Assigns.Where(a => a.TaskId == x.id).Select(a => a.AssignedId).ToList(), - SenderId = x.SenderId + var userId = _authHelper.CurrentAccountId(); - }).FirstOrDefault(); - } + EditTask res = _accountContext.Tasks.Include(x => x.Assigns).Where(x => x.id == TaskId).Select(x => + new EditTask() + { - public void Remove(long id) - { - var task = Get(id); - Remove(task); - } + Description = x.Description, + Id = x.id, + Title = x.Title, + medias = _accountContext.TaskMedias.Include(z => z.Media).Where(e => e.TaskId == x.id).Select(m => + new MediaViewModel() + { + Path = m.Media.Path, + Type = m.Media.Type, + Category = m.Media.Category, + Id = m.Media.id + }).ToList(), + ContractingPartyName = x.ContractingPartyName, + ReceiverId = _accountContext.Assigns.Where(a => a.TaskId == x.id).Select(a => a.AssignedId).ToList(), + SenderId = x.SenderId, + AssignViewModels = x.Assigns.Select(a => new AssignViewModel() + { + Id = a.id, + EndTaskDateFa = a.EndTaskDate.ToFarsiFull(), + IsCancel = a.IsCancel, + IsCanceledRequest = a.IsCanceledRequest, + IsDone = a.IsDone, + IsDoneRequest = a.IsDoneRequest, + TimeRequest = a.TimeRequest, + AssignedName = a.AssignedName, + AssignedId = a.AssignedId, + AssignerId = a.AssignerId + }).ToList(), + IsDone = x.Assigns.All(a=>a.IsDone), + IsCancel = x.Assigns.All(a=>a.IsCancel), + TicketId = x.TicketId, + CreateDateFa = x.CreationDate.ToFarsi(), + + SenderViewModel = _accountContext.Accounts.Where(a => a.id == x.SenderId).Select(a => + new AccountViewModel() + { + Fullname = a.Fullname, + Id = a.id, - public List GetRequestedTasks(TaskSearchModel searchModel) - { - var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); - var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var emptyAcc = new AccountViewModel() - { - Fullname = "-", - PositionValue = 0 - }; - IQueryable query; + }).FirstOrDefault() - if (positionValue == 1) - { - query = _accountContext.Assigns.Include(x => x.Task).Where(x => - x.Task.IsDone == false && x.Task.IsActiveString == "true" && - (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true || x.Task.IsDoneRequest) && accountId == x.Task.SenderId).Select(x => - new TaskViewModel() - { + }).FirstOrDefault(); - AssignedId = x.AssignedId, - AssignerId = x.AssignerId, - CreateDate = x.Task.CreationDate.ToFarsi(), - EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(), - IsDone = x.Task.IsDone, - EndTaskDateGE = x.Task.EndTaskDate, - Name = x.Task.Title, - RequestCancel = x.Task.IsCanceledRequest, - RequestTime = x.Task.TimeRequest, - Id = x.Task.id, - CreateTaskDateGE = x.Task.CreationDate, - IsCancel = x.Task.IsCancel, - AcceptedTimeRequest = x.Task.AcceptedTimeRequest, - IsCancelRequest = x.Task.IsCanceledRequest, - ContractingPartyName = x.Task.ContractingPartyName, - MediaCount = x.Task.TaskMedias.Count(m => m.TaskId == x.id), - Description = x.Task.Description, - IsDoneRequest = x.Task.IsDoneRequest + res.TicketViewModel = res.TicketId != null && res.TicketId > 0 + ? _ticketRepository.GetDetails(res.TicketId.Value) + : null; + if (res.AssignViewModels.Any(x=>x.AssignedId==userId)) + { + res.EndTaskDate = _accountContext.Assigns.First(a => a.TaskId == res.Id && a.AssignedId == userId) + .EndTaskDate.ToFarsi(); - }); + + res.AssignViewModels = res.AssignViewModels.Where(x => x.AssignedId == userId).ToList(); + res.IsDone = res.AssignViewModels.First(x=>x.AssignedId==userId).IsDone; + res.IsCancel = res.AssignViewModels.First(x => x.AssignedId == userId).IsCancel; } - else - { - query = _accountContext.Assigns.Include(x => x.Task).Where(x => - !x.Task.IsDone && x.Task.IsActiveString == "true" && - (x.Task.IsCanceledRequest || x.Task.TimeRequest || x.Task.IsDoneRequest) && (accountId == x.Task.SenderId || x.AssignedId == accountId)).Select(x => - new TaskViewModel() - { + + //_accountContext.Tasks.Where(x => x.id == TaskId).Select(x => new EditTask() + //{ + // EndTaskDate = x.EndTaskDate.ToFarsi(), + // Description = x.Description, + // Id = x.id, + // Title = x.Title, + // medias = _accountContext.TaskMedias.Include(z => z.Media).Where(e => e.TaskId == x.id).Select(m => + // new MediaViewModel() + // { + // Path = m.Media.Path, + // Type = m.Media.Type, + // Category = m.Media.Category, + // Id = m.Media.id + // }).ToList(), + // EndTaskTime = x.EndTaskDate.ToFarsiFull().Substring(11), + // ContractingPartyName = x.ContractingPartyName, + // CompleteDescription = x.DoneDescription, + // IsDone = x.IsDone, + // ReceiverId = _accountContext.Assigns.Where(a => a.TaskId == x.id).Select(a => a.AssignedId).ToList(), + // SenderId = x.SenderId - AssignedId = x.AssignedId, - AssignerId = x.AssignerId, - CreateDate = x.Task.CreationDate.ToFarsi(), - EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(), - IsDone = x.Task.IsDone, - EndTaskDateGE = x.Task.EndTaskDate, - Name = x.Task.Title, - RequestCancel = x.Task.IsCanceledRequest, - RequestTime = x.Task.TimeRequest, - Id = x.Task.id, - CreateTaskDateGE = x.Task.CreationDate, - IsCancel = x.Task.IsCancel, - AcceptedTimeRequest = x.Task.AcceptedTimeRequest, - IsCancelRequest = x.Task.IsCanceledRequest, - ContractingPartyName = x.Task.ContractingPartyName, - MediaCount = x.Task.TaskMedias.Count(m => m.TaskId == x.id), - Description = x.Task.Description, - IsDoneRequest = x.Task.IsDoneRequest + //}).FirstOrDefault(); + return res; + } + + public Tasks GetIncludeAssign(long taskId) + { + return _accountContext.Tasks.Include(x => x.Assigns).FirstOrDefault(x => x.id == taskId); + } + + public void Remove(long id) + { + var task = Get(id); + Remove(task); + } + + + + public List GetRequestedTasks(TaskSearchModel searchModel) + { + var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); + var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var emptyAcc = new AccountViewModel() + { + Fullname = "-", + PositionValue = 0 + }; + IQueryable query; + + + query = _accountContext.Assigns.Include(x => x.Task).Where(x => + !x.IsDone && x.Task.IsActiveString == "true" && !x.IsCancel && + (x.IsCanceledRequest || x.TimeRequest || x.IsDoneRequest) && accountId == x.Task.SenderId).Select(x => + new TaskViewModel() + { + AssignedId = x.AssignedId, + AssignerId = x.AssignerId, + CreateDate = x.Task.CreationDate.ToFarsi(), + EndTaskDateFA = x.EndTaskDate.ToFarsi(), + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDate, + Name = x.Task.Title, + RequestCancel = x.IsCanceledRequest, + RequestTime = x.TimeRequest, + Id = x.Task.id, + CreateTaskDateGE = x.Task.CreationDate, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCanceledRequest, + ContractingPartyName = x.Task.ContractingPartyName, + MediaCount = x.Task.TaskMedias.Count(m => m.TaskId == x.id), + Description = x.Task.Description, + IsDoneRequest = x.IsDoneRequest + + }); - }); - } //res = res.GroupBy(x => x.Id).Select(x => x.First()); //res = res.OrderBy(x => x.IsDone ? 1 : 0) // .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1); @@ -153,25 +202,601 @@ public class TaskRepository : RepositoryBase, ITaskRepository } var res = query.Select(x => new TaskViewModel() - { - Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel() - { - PositionValue = a.Position.PositionValue, - Id = a.id, - Fullname = a.Fullname, - }).FirstOrDefault(a => a.Id == x.AssignerId), + { + Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel() + { + PositionValue = a.Position.PositionValue, + Id = a.id, + Fullname = a.Fullname, + }).FirstOrDefault(a => a.Id == x.AssignerId), - SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname, + SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname, Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id) .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId).ToList(), CreateDate = x.CreateDate, + EndTaskDateFA = x.EndTaskDateFA, + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDateGE, + Name = x.Name, + RequestCancel = x.RequestCancel, + RequestTime = x.RequestTime, + Id = x.Id, + CreateTaskDateGE = x.CreateTaskDateGE, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCancelRequest, + ContractingPartyName = x.ContractingPartyName, + MediaCount = x.MediaCount, + Description = x.Description, + IsDoneRequest = x.IsDoneRequest + }); + if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate)) + { + var start = searchModel.StartDate.ToGeorgianDateTime(); + var end = searchModel.EndDate.ToGeorgianDateTime(); + res = res.Where(x => + ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + + (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) + || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + + (end < x.EndTaskDateGE && x.EndTaskDateGE > start)) + || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + + (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) + || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + + (end < x.EndTaskDateGE && x.EndTaskDateGE > end))); + } + + + + if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest)) + { + bool isDoneReq = bool.Parse(searchModel.IsDoneRequest); + res = res.Where(x => x.IsDoneRequest == isDoneReq); + } + + if (!string.IsNullOrWhiteSpace(searchModel.IsDone)) + { + bool isDone = bool.Parse(searchModel.IsDone); + res = res.Where(x => x.IsDone == isDone); + } + + if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled)) + { + bool isCancel = bool.Parse(searchModel.IsCanceled); + res = res.Where(x => x.IsCancel == isCancel); + } + + if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest)) + { + bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest); + res = res.Where(x => x.RequestTime == isTimeRequest); + } + + if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted)) + { + res = res.Where(x => x.AcceptedTimeRequest > 0); + } + + if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest)) + { + bool isCancelReq = bool.Parse(searchModel.IsCancelRequest); + res = res.Where(x => x.IsCancelRequest == isCancelReq); + + } + + + + var resEnum = res.AsEnumerable(); + var result = resEnum.GroupBy(x => x.Id).Select(x => x.First()); + + if (searchModel.AccountId > 0) + { + result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); + } + + + var orderResult = result.OrderByDescending(x => x.IsCancelRequest) + .ThenByDescending(x => x.RequestTime).ThenByDescending(x => x.IsDoneRequest); + var finalList = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); + + var addAssign = finalList.Select(x => new TaskViewModel() + { + AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id) + .Select(a => new AssignViewModel() + { + AssignedName = a.Fullname, + AssignedPositionValue = a.Position.PositionValue + }).ToList(), + Sender = x.Sender, + SelfAssigner = x.Sender.Id == accountId ? true : false, + Assigned = x.Assigned, + SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false, + CreateDate = x.CreateDate, + EndTaskDateFA = x.EndTaskDateFA, + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDateGE, + Name = x.Name, + RequestCancel = x.RequestCancel, + RequestTime = x.RequestTime, + Id = x.Id, + CreateTaskDateGE = x.CreateTaskDateGE, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCancelRequest, + ContractingPartyName = x.ContractingPartyName, + MediaCount = x.MediaCount, + SelfName = x.SelfName, + Description = x.Description, + IsDoneRequest = x.IsDoneRequest, + }).ToList(); + + + var finalAssign = addAssign.Select(x => new TaskViewModel() + { + + AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList() + { + AssignViewModels = a.ToList(), + PosValue = a.Key + }).ToList(), + Sender = x.Sender, + Assigned = x.Assigned, + CreateDate = x.CreateDate, + EndTaskDateFA = x.EndTaskDateFA, + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDateGE, + Name = x.Name, + RequestCancel = x.RequestCancel, + RequestTime = x.RequestTime, + Id = x.Id, + CreateTaskDateGE = x.CreateTaskDateGE, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCancelRequest, + ContractingPartyName = x.ContractingPartyName, + Color = x.IsCancelRequest || x.RequestTime || x.IsDoneRequest ? SetRequestTasksColors(x.RequestTime, x.IsCancelRequest, x.IsDoneRequest) : "", + MediaCount = x.MediaCount, + HasAttachment = x.MediaCount > 0, + SelfName = x.SelfName, + SelfAssigned = x.SelfAssigned, + SelfAssigner = x.SelfAssigner, + Description = x.Description, + IsDoneRequest = x.IsDoneRequest, + AssignViewModels = x.AssignViewModels + }).ToList(); + + var final = finalAssign.Select(x => new TaskViewModel() + { + + AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList, + Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel() + { + PositionValue = 0, + Fullname = "-" + } : x.Sender, + Assigned = x.Assigned, + CreateDate = x.CreateDate, + EndTaskDateFA = x.EndTaskDateFA, + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDateGE, + Name = x.Name, + RequestCancel = x.RequestCancel, + RequestTime = x.RequestTime, + Id = x.Id, + CreateTaskDateGE = x.CreateTaskDateGE, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCancelRequest, + ContractingPartyName = x.ContractingPartyName, + Color = x.Color, + MediaCount = x.MediaCount, + HasAttachment = x.HasAttachment, + SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName, + EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59" + ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}" + : "", + Description = x.Description, + IsDoneRequest = x.IsDoneRequest, + CanCheckRequests = x.Sender.PositionValue >= positionValue, + Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname, + AssignedReceiverViewModel = x.AssignViewModels.Any() + ? x.AssignViewModels.MinBy(a => a.AssignedPositionValue) + : new() + { + AssignedName = "-", + AssignedPositionValue = 0 + }, + }).ToList(); + return final; + } + + public List GetAllTasks(TaskSearchModel searchModel) + { + var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); + var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var emptyAcc = new AccountViewModel() + { + Fullname = "-", + PositionValue = 0 + }; + IQueryable query; + + if (positionValue == 1) + { + query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias) + .ThenInclude(x => x.Media) + .Where(x => + x.Task.IsActiveString == "true" && (!x.IsCanceledRequest && !x.TimeRequest && !x.IsDoneRequest)) + .Select(x => + new TaskViewModel() + { + AssignedId = x.AssignedId, + AssignerId = x.AssignerId, + CreateDate = x.Task.CreationDate.ToFarsi(), + EndTaskDateFA = x.EndTaskDate.ToFarsi(), + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDate, + Name = x.Task.Title, + RequestCancel = x.IsCanceledRequest, + RequestTime = x.TimeRequest, + Id = x.Task.id, + CreateTaskDateGE = x.Task.CreationDate, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCanceledRequest, + ContractingPartyName = x.Task.ContractingPartyName, + MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), + Description = x.Task.Description, + IsDoneRequest = x.IsDoneRequest, + + }); + } + else + { + return new(); + } + + if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch)) + { + query = query.Where(x => + (x.Description != null && x.Description.Contains(searchModel.GeneralSearch)) + || x.ContractingPartyName.Contains(searchModel.GeneralSearch) + || x.Name.Contains(searchModel.GeneralSearch)); + } + + //res = res.GroupBy(x => x.Id).Select(x => x.First()); + //res = res.OrderBy(x => x.IsDone ? 1 : 0) + // .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1); + var res = query.Select(x => new TaskViewModel() + { + Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel() + { + PositionValue = a.Position.PositionValue, + Id = a.id, + Fullname = a.Fullname, + }).FirstOrDefault(a => a.Id == x.AssignerId), + + SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname, + + Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id) + .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId) + .ToList(), + CreateDate = x.CreateDate, + EndTaskDateFA = x.EndTaskDateFA, + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDateGE, + Name = x.Name, + RequestCancel = x.RequestCancel, + RequestTime = x.RequestTime, + Id = x.Id, + CreateTaskDateGE = x.CreateTaskDateGE, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCancelRequest, + ContractingPartyName = x.ContractingPartyName, + MediaCount = x.MediaCount, + Description = x.Description, + IsDoneRequest = x.IsDoneRequest + }); + if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate)) + { + var start = searchModel.StartDate.ToGeorgianDateTime(); + var end = searchModel.EndDate.ToGeorgianDateTime(); + res = res.Where(x => + ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + + (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) + || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + + (end < x.EndTaskDateGE && x.EndTaskDateGE > start)) + || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + + (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) + || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + + (end < x.EndTaskDateGE && x.EndTaskDateGE > end))); + } + + if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest)) + { + bool isDoneReq = bool.Parse(searchModel.IsDoneRequest); + res = res.Where(x => x.IsDoneRequest == isDoneReq); + } + + if (!string.IsNullOrWhiteSpace(searchModel.IsDone)) + { + bool isDone = bool.Parse(searchModel.IsDone); + res = res.Where(x => x.IsDone == isDone); + } + + if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled)) + { + bool isCancel = bool.Parse(searchModel.IsCanceled); + res = res.Where(x => x.IsCancel == isCancel); + } + + if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest)) + { + bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest); + res = res.Where(x => x.RequestTime == isTimeRequest); + } + + if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted)) + { + res = res.Where(x => x.AcceptedTimeRequest > 0); + } + + if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest)) + { + bool isCancelReq = bool.Parse(searchModel.IsCancelRequest); + res = res.Where(x => x.IsCancelRequest == isCancelReq); + + } + + + + var resEnum = res.AsEnumerable(); + var result = resEnum.GroupBy(x => x.Id).Select(x => x.First()); + + if (searchModel.AccountId > 0) + { + result = result.Where(x => + x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); + } + + + var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0) + .ThenBy(x => x.EndTaskDateGE); + + + var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); + + final = final.Select(x => new TaskViewModel() + { + AssignViewModels = _accountContext.Accounts.Include(x => x.Position) + .Where(a => x.Assigned.Contains(a.id) && accountId != a.id) + .Select(a => new AssignViewModel() + { + AssignedName = a.Fullname, + AssignedPositionValue = a.Position.PositionValue + }).ToList(), + Sender = x.Sender, + SelfAssigner = x.Sender.Id == accountId ? true : false, + Assigned = x.Assigned, + SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false, + CreateDate = x.CreateDate, + EndTaskDateFA = x.EndTaskDateFA, + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDateGE, + Name = x.Name, + RequestCancel = x.RequestCancel, + RequestTime = x.RequestTime, + Id = x.Id, + CreateTaskDateGE = x.CreateTaskDateGE, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCancelRequest, + ContractingPartyName = x.ContractingPartyName, + MediaCount = x.MediaCount, + SelfName = x.SelfName, + Description = x.Description, + IsDoneRequest = x.IsDoneRequest + + }).ToList(); + + + final = final.Select(x => new TaskViewModel() + { + + Sender = x.Sender, + Assigned = x.Assigned, + CreateDate = x.CreateDate, + EndTaskDateFA = x.EndTaskDateFA, + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDateGE, + Name = x.Name, + RequestCancel = x.RequestCancel, + RequestTime = x.RequestTime, + Id = x.Id, + CreateTaskDateGE = x.CreateTaskDateGE, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCancelRequest, + ContractingPartyName = x.ContractingPartyName, + Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel), + MediaCount = x.MediaCount, + HasAttachment = x.MediaCount > 0, + SelfName = x.SelfName, + SelfAssigned = x.SelfAssigned, + SelfAssigner = x.SelfAssigner, + Description = x.Description, + IsDoneRequest = x.IsDoneRequest, + AssignViewModels = x.AssignViewModels + }).ToList(); + + final = final.Select(x => new TaskViewModel() + { + + + Sender = !(x.SelfAssigned || x.SelfAssigner) + ? new AccountViewModel() + { + PositionValue = 0, + Fullname = "-" + } + : x.Sender, + Assigned = x.Assigned, + CreateDate = x.CreateDate, + EndTaskDateFA = x.EndTaskDateFA, + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDateGE, + Name = x.Name, + RequestCancel = x.RequestCancel, + RequestTime = x.RequestTime, + Id = x.Id, + CreateTaskDateGE = x.CreateTaskDateGE, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCancelRequest, + ContractingPartyName = x.ContractingPartyName, + Color = x.Color, + MediaCount = x.MediaCount, + HasAttachment = x.HasAttachment, + SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName, + EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59" + ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}" + : "", + Description = x.Description, + IsDoneRequest = x.IsDoneRequest, + CanAssign = _positionRepository.GetLastPositionValue() != positionValue, + CanDelete = x.Sender.Id == accountId, + CanEdit = x.Sender.Id == accountId && !(_accountContext.Assigns.Any(a => a.TaskId == x.Id && (a.AcceptedTimeRequest > 0 || a.IsCanceledRequest + || a.IsDoneRequest || a.TimeRequest || a.IsCancel || a.IsDone))), + Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname, + AssignedReceiverViewModel = x.AssignViewModels.Any() + ? x.AssignViewModels.MinBy(a => a.AssignedPositionValue) + : new() + { + AssignedName = "-", + AssignedPositionValue = 0 + }, + + }).ToList(); + return final; + + } + + + + + public List GetSentTasks(TaskSearchModel searchModel) + { + var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); + var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var emptyAcc = new AccountViewModel() + { + Fullname = "-", + PositionValue = 0 + }; + IQueryable query; + + if (positionValue == 1) + { + query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias) + .ThenInclude(x => x.Media) + .Where(x => + x.Task.IsActiveString == "true" && (x.AssignerId == accountId && x.AssignedId != accountId) && (!x.IsCanceledRequest && !x.TimeRequest && !x.IsDoneRequest) && + x.Task.SenderId == accountId) + .Select(x => + new TaskViewModel() + { + AssignedId = x.AssignedId, + AssignerId = x.AssignerId, + CreateDate = x.Task.CreationDate.ToFarsi(), + EndTaskDateFA = x.EndTaskDate.ToFarsi(), + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDate, + Name = x.Task.Title, + RequestCancel = x.IsCanceledRequest, + RequestTime = x.TimeRequest, + Id = x.Task.id, + CreateTaskDateGE = x.Task.CreationDate, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCanceledRequest, + ContractingPartyName = x.Task.ContractingPartyName, + MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), + Description = x.Task.Description, + IsDoneRequest = x.IsDoneRequest, + + }); + + } + else + { + query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias) + .ThenInclude(x => x.Media) + .Where(x => + x.Task.IsActiveString == "true" && x.AssignerId == accountId && (!x.IsCanceledRequest && !x.TimeRequest && !x.IsDoneRequest)) + .Select(x => + new TaskViewModel() + { + AssignedId = x.AssignedId, + AssignerId = x.AssignerId, + CreateDate = x.Task.CreationDate.ToFarsi(), + EndTaskDateFA = x.EndTaskDate.ToFarsi(), + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDate, + Name = x.Task.Title, + RequestCancel = x.IsCanceledRequest, + RequestTime = x.TimeRequest, + Id = x.Task.id, + CreateTaskDateGE = x.Task.CreationDate, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCanceledRequest, + ContractingPartyName = x.Task.ContractingPartyName, + MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), + Description = x.Task.Description, + IsDoneRequest = x.IsDoneRequest, + + }); + + + } + + if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch)) + { + query = query.Where(x => + (x.Description != null && x.Description.Contains(searchModel.GeneralSearch)) + || x.ContractingPartyName.Contains(searchModel.GeneralSearch) + || x.Name.Contains(searchModel.GeneralSearch)); + } + + var res = query.Select(x => new TaskViewModel() + { + Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel() + { + PositionValue = a.Position.PositionValue, + Id = a.id, + Fullname = a.Fullname, + }).FirstOrDefault(a => a.Id == x.AssignerId), + + SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname, + + Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id) + .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId) + .ToList(), + CreateDate = x.CreateDate, EndTaskDateFA = x.EndTaskDateFA, IsDone = x.IsDone, EndTaskDateGE = x.EndTaskDateGE, Name = x.Name, - RequestCancel = x.RequestCancel, RequestTime = x.RequestTime, Id = x.Id, CreateTaskDateGE = x.CreateTaskDateGE, @@ -183,6 +808,8 @@ public class TaskRepository : RepositoryBase, ITaskRepository Description = x.Description, IsDoneRequest = x.IsDoneRequest }); + + #region Search if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate)) { var start = searchModel.StartDate.ToGeorgianDateTime(); @@ -190,74 +817,98 @@ public class TaskRepository : RepositoryBase, ITaskRepository res = res.Where(x => ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) - || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) + || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - (end < x.EndTaskDateGE && x.EndTaskDateGE > start)) - || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + (end < x.EndTaskDateGE && x.EndTaskDateGE > start)) + || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) - || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && + (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) + || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - (end < x.EndTaskDateGE && x.EndTaskDateGE > end))); - } + (end < x.EndTaskDateGE && x.EndTaskDateGE > end))); + } + if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest)) + { + bool isDoneReq = bool.Parse(searchModel.IsDoneRequest); + res = res.Where(x => x.IsDoneRequest == isDoneReq); + } + if (!string.IsNullOrWhiteSpace(searchModel.IsDone)) + { + bool isDone = bool.Parse(searchModel.IsDone); + res = res.Where(x => x.IsDone == isDone); + } - if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest)) - { - bool isDoneReq = bool.Parse(searchModel.IsDoneRequest); - res = res.Where(x => x.IsDoneRequest == isDoneReq); - } + if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled)) + { + bool isCancel = bool.Parse(searchModel.IsCanceled); + res = res.Where(x => x.IsCancel == isCancel); + } - if (!string.IsNullOrWhiteSpace(searchModel.IsDone)) - { - bool isDone = bool.Parse(searchModel.IsDone); - res = res.Where(x => x.IsDone == isDone); - } + if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest)) + { + bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest); + res = res.Where(x => x.RequestTime == isTimeRequest); + } - if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled)) - { - bool isCancel = bool.Parse(searchModel.IsCanceled); - res = res.Where(x => x.IsCancel == isCancel); - } + if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted)) + { + res = res.Where(x => x.AcceptedTimeRequest > 0); + } - if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest)) - { - bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest); - res = res.Where(x => x.RequestTime == isTimeRequest); - } + if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest)) + { + bool isCancelReq = bool.Parse(searchModel.IsCancelRequest); + res = res.Where(x => x.IsCancelRequest == isCancelReq); - if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted)) - { - res = res.Where(x => x.AcceptedTimeRequest > 0); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest)) - { - bool isCancelReq = bool.Parse(searchModel.IsCancelRequest); - res = res.Where(x => x.IsCancelRequest == isCancelReq); - - } + } + #endregion var resEnum = res.AsEnumerable(); - var result = resEnum.GroupBy(x => x.Id).Select(x => x.First()); - - if (searchModel.AccountId > 0) + var result = resEnum.GroupBy(x => x.Id).Select(x => new TaskViewModel() { - result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); - } + Sender = x.First().Sender, + SelfName = x.First().SelfName, + Assigned = x.First().Assigned, + CreateDate = x.First().CreateDate, + EndTaskDateFA = x.Min(e => e.EndTaskDateGE).ToFarsi(), + IsDone = x.All(a => a.IsDone) ? true : false, + EndTaskDateGE = x.All(a => a.IsDone)?x.Min(e=>e.EndTaskDateGE) :x.Where(e=>!e.IsDone).Min(e => e.EndTaskDateGE), + Name = x.First().Name, + RequestTime = x.First().RequestTime, + Id = x.Key, + CreateTaskDateGE = x.First().CreateTaskDateGE, + IsCancel = x.First().IsCancel, + AcceptedTimeRequest = x.First().AcceptedTimeRequest, + IsCancelRequest = x.First().IsCancelRequest, + ContractingPartyName = x.First().ContractingPartyName, + MediaCount = x.First().MediaCount, + Description = x.First().Description, + IsDoneRequest = x.First().IsDoneRequest, + + }); + + if (searchModel.AccountId > 0) + { + result = result.Where(x => + x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); + } - var orderResult = result.OrderBy(x => x.IsDone ? 1 : 0) - .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1); - var finalList = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); + var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0) + .ThenBy(x => x.EndTaskDateGE); - var AddAssign = finalList.Select(x => new TaskViewModel() + + var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); + + final = final.Select(x => new TaskViewModel() { - AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id) + AssignViewModels = _accountContext.Accounts.Include(x => x.Position) + .Where(a => x.Assigned.Contains(a.id) && accountId != a.id) .Select(a => new AssignViewModel() { AssignedName = a.Fullname, @@ -272,7 +923,6 @@ public class TaskRepository : RepositoryBase, ITaskRepository IsDone = x.IsDone, EndTaskDateGE = x.EndTaskDateGE, Name = x.Name, - RequestCancel = x.RequestCancel, RequestTime = x.RequestTime, Id = x.Id, CreateTaskDateGE = x.CreateTaskDateGE, @@ -283,17 +933,13 @@ public class TaskRepository : RepositoryBase, ITaskRepository MediaCount = x.MediaCount, SelfName = x.SelfName, Description = x.Description, - IsDoneRequest = x.IsDoneRequest, + IsDoneRequest = x.IsDoneRequest + + }).ToList(); - - - - }).ToList(); - - - var finalAssign = AddAssign.Select(x => new TaskViewModel() - { + final = final.Select(x => new TaskViewModel() + { AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList() { @@ -307,7 +953,6 @@ public class TaskRepository : RepositoryBase, ITaskRepository IsDone = x.IsDone, EndTaskDateGE = x.EndTaskDateGE, Name = x.Name, - RequestCancel = x.RequestCancel, RequestTime = x.RequestTime, Id = x.Id, CreateTaskDateGE = x.CreateTaskDateGE, @@ -315,32 +960,36 @@ public class TaskRepository : RepositoryBase, ITaskRepository AcceptedTimeRequest = x.AcceptedTimeRequest, IsCancelRequest = x.IsCancelRequest, ContractingPartyName = x.ContractingPartyName, - Color = x.IsCancelRequest || x.RequestTime || x.IsDoneRequest ? SetRequestTasksColors(x.RequestTime, x.IsCancelRequest, x.IsDoneRequest) : "", + Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel), MediaCount = x.MediaCount, - HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0), + HasAttachment = x.MediaCount > 0, SelfName = x.SelfName, SelfAssigned = x.SelfAssigned, SelfAssigner = x.SelfAssigner, Description = x.Description, - IsDoneRequest = x.IsDoneRequest + IsDoneRequest = x.IsDoneRequest, + AssignViewModels = x.AssignViewModels }).ToList(); - var final = finalAssign.Select(x => new TaskViewModel() - { + final = final.Select(x => new TaskViewModel() + { - AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList, - Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel() - { - PositionValue = 0, - Fullname = "-" - } : x.Sender, + AssignList = !(x.SelfAssigned || x.SelfAssigner) + ? ExtraTools.AddAssign(x.AssignList, x.Sender) + : x.AssignList, + Sender = !(x.SelfAssigned || x.SelfAssigner) + ? new AccountViewModel() + { + PositionValue = 0, + Fullname = "-" + } + : x.Sender, Assigned = x.Assigned, CreateDate = x.CreateDate, EndTaskDateFA = x.EndTaskDateFA, IsDone = x.IsDone, EndTaskDateGE = x.EndTaskDateGE, Name = x.Name, - RequestCancel = x.RequestCancel, RequestTime = x.RequestTime, Id = x.Id, CreateTaskDateGE = x.CreateTaskDateGE, @@ -357,582 +1006,25 @@ public class TaskRepository : RepositoryBase, ITaskRepository : "", Description = x.Description, IsDoneRequest = x.IsDoneRequest, - CanCheckRequests = x.Sender.PositionValue >= positionValue, - Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname - }).ToList(); - return final; - } - - public List GetTasks(TaskSearchModel searchModel) - { - var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); - var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var emptyAcc = new AccountViewModel() - { - Fullname = "-", - PositionValue = 0 - }; - IQueryable query; - - if (positionValue == 1) - { - query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media) - .Where(x => - x.Task.IsActiveString == "true" && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest)) - .Select(x => - new TaskViewModel() - { - - AssignedId = x.AssignedId, - AssignerId = x.AssignerId, - CreateDate = x.Task.CreationDate.ToFarsi(), - EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(), - IsDone = x.Task.IsDone, - EndTaskDateGE = x.Task.EndTaskDate, - Name = x.Task.Title, - RequestCancel = x.Task.IsCanceledRequest, - RequestTime = x.Task.TimeRequest, - Id = x.Task.id, - CreateTaskDateGE = x.Task.CreationDate, - IsCancel = x.Task.IsCancel, - AcceptedTimeRequest = x.Task.AcceptedTimeRequest, - IsCancelRequest = x.Task.IsCanceledRequest, - ContractingPartyName = x.Task.ContractingPartyName, - MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), - Description = x.Task.Description, - IsDoneRequest = x.Task.IsDoneRequest, - - }); - } - else - { - query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media) - .Where(x => - x.Task.IsActiveString == "true" && (x.AssignedId == accountId || x.AssignerId == accountId) && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest)) - .Select(x => - new TaskViewModel() - { - - AssignedId = x.AssignedId, - AssignerId = x.AssignerId, - CreateDate = x.Task.CreationDate.ToFarsi(), - EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(), - IsDone = x.Task.IsDone, - EndTaskDateGE = x.Task.EndTaskDate, - Name = x.Task.Title, - RequestCancel = x.Task.IsCanceledRequest, - RequestTime = x.Task.TimeRequest, - Id = x.Task.id, - CreateTaskDateGE = x.Task.CreationDate, - IsCancel = x.Task.IsCancel, - AcceptedTimeRequest = x.Task.AcceptedTimeRequest, - IsCancelRequest = x.Task.IsCanceledRequest, - ContractingPartyName = x.Task.ContractingPartyName, - MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), - Description = x.Task.Description, - IsDoneRequest = x.Task.IsDoneRequest, - - - }); - } - //res = res.GroupBy(x => x.Id).Select(x => x.First()); - //res = res.OrderBy(x => x.IsDone ? 1 : 0) - // .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1); - var res = query.Select(x => new TaskViewModel() - { - Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel() - { - PositionValue = a.Position.PositionValue, - Id = a.id, - Fullname = a.Fullname, - }).FirstOrDefault(a => a.Id == x.AssignerId), - - SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname, - - Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id) - .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId) - .ToList(), - CreateDate = x.CreateDate, - EndTaskDateFA = x.EndTaskDateFA, - IsDone = x.IsDone, - EndTaskDateGE = x.EndTaskDateGE, - Name = x.Name, - RequestCancel = x.RequestCancel, - RequestTime = x.RequestTime, - Id = x.Id, - CreateTaskDateGE = x.CreateTaskDateGE, - IsCancel = x.IsCancel, - AcceptedTimeRequest = x.AcceptedTimeRequest, - IsCancelRequest = x.IsCancelRequest, - ContractingPartyName = x.ContractingPartyName, - MediaCount = x.MediaCount, - Description = x.Description, - IsDoneRequest = x.IsDoneRequest - }); - if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate)) - { - var start = searchModel.StartDate.ToGeorgianDateTime(); - var end = searchModel.EndDate.ToGeorgianDateTime(); - res = res.Where(x => - ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - - (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) - || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - - (end < x.EndTaskDateGE && x.EndTaskDateGE > start)) - || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - - (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) - || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - - (end < x.EndTaskDateGE && x.EndTaskDateGE > end))); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest)) - { - bool isDoneReq = bool.Parse(searchModel.IsDoneRequest); - res = res.Where(x => x.IsDoneRequest == isDoneReq); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsDone)) - { - bool isDone = bool.Parse(searchModel.IsDone); - res = res.Where(x => x.IsDone == isDone); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled)) - { - bool isCancel = bool.Parse(searchModel.IsCanceled); - res = res.Where(x => x.IsCancel == isCancel); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest)) - { - bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest); - res = res.Where(x => x.RequestTime == isTimeRequest); - } - - if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted)) - { - res = res.Where(x => x.AcceptedTimeRequest > 0); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest)) - { - bool isCancelReq = bool.Parse(searchModel.IsCancelRequest); - res = res.Where(x => x.IsCancelRequest == isCancelReq); - - } - - - - var resEnum = res.AsEnumerable(); - var result = resEnum.GroupBy(x => x.Id).Select(x => x.First()); - - if (searchModel.AccountId > 0) - { - result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); - } - - - var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0) - .ThenBy(x => x.EndTaskDateGE); - - - var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); - - final = final.Select(x => new TaskViewModel() - { - AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id) - .Select(a => new AssignViewModel() - { - AssignedName = a.Fullname, - AssignedPositionValue = a.Position.PositionValue - }).ToList(), - Sender = x.Sender, - SelfAssigner = x.Sender.Id == accountId ? true : false, - Assigned = x.Assigned, - SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false, - CreateDate = x.CreateDate, - EndTaskDateFA = x.EndTaskDateFA, - IsDone = x.IsDone, - EndTaskDateGE = x.EndTaskDateGE, - Name = x.Name, - RequestCancel = x.RequestCancel, - RequestTime = x.RequestTime, - Id = x.Id, - CreateTaskDateGE = x.CreateTaskDateGE, - IsCancel = x.IsCancel, - AcceptedTimeRequest = x.AcceptedTimeRequest, - IsCancelRequest = x.IsCancelRequest, - ContractingPartyName = x.ContractingPartyName, - MediaCount = x.MediaCount, - SelfName = x.SelfName, - Description = x.Description, - IsDoneRequest = x.IsDoneRequest - - }).ToList(); - - - final = final.Select(x => new TaskViewModel() - { - - AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList() - { - AssignViewModels = a.ToList(), - PosValue = a.Key - }).ToList(), - Sender = x.Sender, - Assigned = x.Assigned, - CreateDate = x.CreateDate, - EndTaskDateFA = x.EndTaskDateFA, - IsDone = x.IsDone, - EndTaskDateGE = x.EndTaskDateGE, - Name = x.Name, - RequestCancel = x.RequestCancel, - RequestTime = x.RequestTime, - Id = x.Id, - CreateTaskDateGE = x.CreateTaskDateGE, - IsCancel = x.IsCancel, - AcceptedTimeRequest = x.AcceptedTimeRequest, - IsCancelRequest = x.IsCancelRequest, - ContractingPartyName = x.ContractingPartyName, - Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel), - MediaCount = x.MediaCount, - HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false, - SelfName = x.SelfName, - SelfAssigned = x.SelfAssigned, - SelfAssigner = x.SelfAssigner, - Description = x.Description, - IsDoneRequest = x.IsDoneRequest - }).ToList(); - - final = final.Select(x => new TaskViewModel() - { - - AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList, - Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel() - { - PositionValue = 0, - Fullname = "-" - } : x.Sender, - Assigned = x.Assigned, - CreateDate = x.CreateDate, - EndTaskDateFA = x.EndTaskDateFA, - IsDone = x.IsDone, - EndTaskDateGE = x.EndTaskDateGE, - Name = x.Name, - RequestCancel = x.RequestCancel, - RequestTime = x.RequestTime, - Id = x.Id, - CreateTaskDateGE = x.CreateTaskDateGE, - IsCancel = x.IsCancel, - AcceptedTimeRequest = x.AcceptedTimeRequest, - IsCancelRequest = x.IsCancelRequest, - ContractingPartyName = x.ContractingPartyName, - Color = x.Color, - MediaCount = x.MediaCount, - HasAttachment = x.HasAttachment, - SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName, - EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59" - ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}" - : "", - Description = x.Description, - IsDoneRequest = x.IsDoneRequest, - CanAssign = _PositionRepository.GetLastPositionValue() != positionValue, - CanDelete = x.Sender.Id == accountId, - CanEdit = x.Sender.Id == accountId, - Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname - - }).ToList(); - return final; - - } - - public List GetSentTasks(TaskSearchModel searchModel) - { - var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); - var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var emptyAcc = new AccountViewModel() - { - Fullname = "-", - PositionValue = 0 - }; - IQueryable query; - - if (positionValue == 1) - { - query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media) - .Where(x => - x.Task.IsActiveString == "true" && (x.AssignerId == accountId && x.AssignedId != accountId) && x.Task.SenderId == accountId && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest)) - .Select(x => - new TaskViewModel() - { - AssignedId = x.AssignedId, - AssignerId = x.AssignerId, - CreateDate = x.Task.CreationDate.ToFarsi(), - EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(), - IsDone = x.Task.IsDone, - EndTaskDateGE = x.Task.EndTaskDate, - Name = x.Task.Title, - RequestCancel = x.Task.IsCanceledRequest, - RequestTime = x.Task.TimeRequest, - Id = x.Task.id, - CreateTaskDateGE = x.Task.CreationDate, - IsCancel = x.Task.IsCancel, - AcceptedTimeRequest = x.Task.AcceptedTimeRequest, - IsCancelRequest = x.Task.IsCanceledRequest, - ContractingPartyName = x.Task.ContractingPartyName, - MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), - Description = x.Task.Description, - IsDoneRequest = x.Task.IsDoneRequest, - - }); - - } - else - { - query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media) - .Where(x => - x.Task.IsActiveString == "true" && x.AssignerId == accountId) - .Select(x => - new TaskViewModel() - { - AssignedId = x.AssignedId, - AssignerId = x.AssignerId, - CreateDate = x.Task.CreationDate.ToFarsi(), - EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(), - IsDone = x.Task.IsDone, - EndTaskDateGE = x.Task.EndTaskDate, - Name = x.Task.Title, - RequestCancel = x.Task.IsCanceledRequest, - RequestTime = x.Task.TimeRequest, - Id = x.Task.id, - CreateTaskDateGE = x.Task.CreationDate, - IsCancel = x.Task.IsCancel, - AcceptedTimeRequest = x.Task.AcceptedTimeRequest, - IsCancelRequest = x.Task.IsCanceledRequest, - ContractingPartyName = x.Task.ContractingPartyName, - MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), - Description = x.Task.Description, - IsDoneRequest = x.Task.IsDoneRequest, - - }); - - - } - var res = query.Select(x => new TaskViewModel() - { - Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel() - { - PositionValue = a.Position.PositionValue, - Id = a.id, - Fullname = a.Fullname, - }).FirstOrDefault(a => a.Id == x.AssignerId), - - SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname, - - Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id) - .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId) - .ToList(), - CreateDate = x.CreateDate, - EndTaskDateFA = x.EndTaskDateFA, - IsDone = x.IsDone, - EndTaskDateGE = x.EndTaskDateGE, - Name = x.Name, - RequestCancel = x.RequestCancel, - RequestTime = x.RequestTime, - Id = x.Id, - CreateTaskDateGE = x.CreateTaskDateGE, - IsCancel = x.IsCancel, - AcceptedTimeRequest = x.AcceptedTimeRequest, - IsCancelRequest = x.IsCancelRequest, - ContractingPartyName = x.ContractingPartyName, - MediaCount = x.MediaCount, - Description = x.Description, - IsDoneRequest = x.IsDoneRequest - }); - if (!string.IsNullOrWhiteSpace(searchModel.StartDate) && !string.IsNullOrWhiteSpace(searchModel.EndDate)) - { - var start = searchModel.StartDate.ToGeorgianDateTime(); - var end = searchModel.EndDate.ToGeorgianDateTime(); - res = res.Where(x => - ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - - (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) - || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - - (end < x.EndTaskDateGE && x.EndTaskDateGE > start)) - || ((start < x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - - (end > x.EndTaskDateGE && x.EndTaskDateGE > start)) - || ((start > x.CreateTaskDateGE && x.CreateTaskDateGE < end) && - - (end < x.EndTaskDateGE && x.EndTaskDateGE > end))); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsDoneRequest)) - { - bool isDoneReq = bool.Parse(searchModel.IsDoneRequest); - res = res.Where(x => x.IsDoneRequest == isDoneReq); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsDone)) - { - bool isDone = bool.Parse(searchModel.IsDone); - res = res.Where(x => x.IsDone == isDone); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsCanceled)) - { - bool isCancel = bool.Parse(searchModel.IsCanceled); - res = res.Where(x => x.IsCancel == isCancel); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsTimeRequest)) - { - bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest); - res = res.Where(x => x.RequestTime == isTimeRequest); - } - - if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted)) - { - res = res.Where(x => x.AcceptedTimeRequest > 0); - } - - if (!string.IsNullOrWhiteSpace(searchModel.IsCancelRequest)) - { - bool isCancelReq = bool.Parse(searchModel.IsCancelRequest); - res = res.Where(x => x.IsCancelRequest == isCancelReq); - - } - - - - var resEnum = res.AsEnumerable(); - var result = resEnum.GroupBy(x => x.Id).Select(x => x.First()); - - if (searchModel.AccountId > 0) - { - result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); - } - - - var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0) - .ThenBy(x => x.EndTaskDateGE); - - - var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); - - final = final.Select(x => new TaskViewModel() - { - AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id) - .Select(a => new AssignViewModel() - { - AssignedName = a.Fullname, - AssignedPositionValue = a.Position.PositionValue - }).ToList(), - Sender = x.Sender, - SelfAssigner = x.Sender.Id == accountId ? true : false, - Assigned = x.Assigned, - SelfAssigned = x.Assigned.Any(a => a == accountId) ? true : false, - CreateDate = x.CreateDate, - EndTaskDateFA = x.EndTaskDateFA, - IsDone = x.IsDone, - EndTaskDateGE = x.EndTaskDateGE, - Name = x.Name, - RequestCancel = x.RequestCancel, - RequestTime = x.RequestTime, - Id = x.Id, - CreateTaskDateGE = x.CreateTaskDateGE, - IsCancel = x.IsCancel, - AcceptedTimeRequest = x.AcceptedTimeRequest, - IsCancelRequest = x.IsCancelRequest, - ContractingPartyName = x.ContractingPartyName, - MediaCount = x.MediaCount, - SelfName = x.SelfName, - Description = x.Description, - IsDoneRequest = x.IsDoneRequest - - }).ToList(); - - - final = final.Select(x => new TaskViewModel() - { - - AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList() - { - AssignViewModels = a.ToList(), - PosValue = a.Key - }).ToList(), - Sender = x.Sender, - Assigned = x.Assigned, - CreateDate = x.CreateDate, - EndTaskDateFA = x.EndTaskDateFA, - IsDone = x.IsDone, - EndTaskDateGE = x.EndTaskDateGE, - Name = x.Name, - RequestCancel = x.RequestCancel, - RequestTime = x.RequestTime, - Id = x.Id, - CreateTaskDateGE = x.CreateTaskDateGE, - IsCancel = x.IsCancel, - AcceptedTimeRequest = x.AcceptedTimeRequest, - IsCancelRequest = x.IsCancelRequest, - ContractingPartyName = x.ContractingPartyName, - Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel), - MediaCount = x.MediaCount, - HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false, - SelfName = x.SelfName, - SelfAssigned = x.SelfAssigned, - SelfAssigner = x.SelfAssigner, - Description = x.Description, - IsDoneRequest = x.IsDoneRequest - }).ToList(); - - final = final.Select(x => new TaskViewModel() - { - - AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList, - Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel() - { - PositionValue = 0, - Fullname = "-" - } : x.Sender, - Assigned = x.Assigned, - CreateDate = x.CreateDate, - EndTaskDateFA = x.EndTaskDateFA, - IsDone = x.IsDone, - EndTaskDateGE = x.EndTaskDateGE, - Name = x.Name, - RequestCancel = x.RequestCancel, - RequestTime = x.RequestTime, - Id = x.Id, - CreateTaskDateGE = x.CreateTaskDateGE, - IsCancel = x.IsCancel, - AcceptedTimeRequest = x.AcceptedTimeRequest, - IsCancelRequest = x.IsCancelRequest, - ContractingPartyName = x.ContractingPartyName, - Color = x.Color, - MediaCount = x.MediaCount, - HasAttachment = x.HasAttachment, - SelfName = !(x.SelfAssigned || x.SelfAssigner) ? "-" : x.SelfName, - EndTaskTime = $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}:{x.EndTaskDateGE.Second}" != "23:59:59" - ? $"{x.EndTaskDateGE.Hour}:{x.EndTaskDateGE.Minute}" - : "", - Description = x.Description, - IsDoneRequest = x.IsDoneRequest, - CanAssign = _PositionRepository.GetLastPositionValue() != positionValue, - CanDelete = x.Sender.Id == accountId, - CanEdit = x.Sender.Id == accountId, - Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname + CanAssign = _positionRepository.GetLastPositionValue() != positionValue, + CanDelete = x.Sender.Id == accountId, + CanEdit = x.Sender.Id == accountId && !(_accountContext.Assigns.Any(a => a.TaskId == x.Id && (a.AcceptedTimeRequest > 0 || a.IsCanceledRequest + || a.IsDoneRequest || a.TimeRequest || a.IsCancel || a.IsDone))), + Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname, + AssignedReceiverViewModel = x.AssignViewModels.Any() + ? x.AssignViewModels.MinBy(a => a.AssignedPositionValue) + : new() + { + AssignedName = "-", + AssignedPositionValue = 0 + }, }).ToList(); return final; } - public List AllRequestedTasks(TaskSearchModel searchModel) - { + public List AllRequestedTasks(TaskSearchModel searchModel) + { var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); var emptyAcc = new AccountViewModel() @@ -945,29 +1037,29 @@ public class TaskRepository : RepositoryBase, ITaskRepository if (positionValue == 1) { query = _accountContext.Assigns.Include(x => x.Task).Where(x => - x.Task.IsDone == false && x.Task.IsActiveString == "true" && - (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true || x.Task.IsDoneRequest)).Select(x => + !x.IsDone && x.Task.IsActiveString == "true" && + (x.IsCanceledRequest || x.TimeRequest || x.IsDoneRequest)).Select(x => new TaskViewModel() { AssignedId = x.AssignedId, AssignerId = x.AssignerId, CreateDate = x.Task.CreationDate.ToFarsi(), - EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(), - IsDone = x.Task.IsDone, - EndTaskDateGE = x.Task.EndTaskDate, + EndTaskDateFA = x.EndTaskDate.ToFarsi(), + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDate, Name = x.Task.Title, - RequestCancel = x.Task.IsCanceledRequest, - RequestTime = x.Task.TimeRequest, + RequestCancel = x.IsCanceledRequest, + RequestTime = x.TimeRequest, Id = x.Task.id, CreateTaskDateGE = x.Task.CreationDate, - IsCancel = x.Task.IsCancel, - AcceptedTimeRequest = x.Task.AcceptedTimeRequest, - IsCancelRequest = x.Task.IsCanceledRequest, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCanceledRequest, ContractingPartyName = x.Task.ContractingPartyName, MediaCount = x.Task.TaskMedias.Count(m => m.TaskId == x.id), Description = x.Task.Description, - IsDoneRequest = x.Task.IsDoneRequest + IsDoneRequest = x.IsDoneRequest }); } @@ -985,6 +1077,13 @@ public class TaskRepository : RepositoryBase, ITaskRepository || x.ContractingPartyName.Contains(searchModel.GeneralSearch) || x.Name.Contains(searchModel.GeneralSearch)); } + if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch)) + { + query = query.Where(x => + (x.Description != null && x.Description.Contains(searchModel.GeneralSearch)) + || x.ContractingPartyName.Contains(searchModel.GeneralSearch) + || x.Name.Contains(searchModel.GeneralSearch)); + } var res = query.Select(x => new TaskViewModel() { @@ -1083,10 +1182,8 @@ public class TaskRepository : RepositoryBase, ITaskRepository { result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); } - - - var orderResult = result.OrderBy(x => x.IsDone ? 1 : 0) - .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1); + var orderResult = result.OrderByDescending(x => x.IsCancelRequest) + .ThenByDescending(x => x.RequestTime).ThenByDescending(x => x.IsDoneRequest); var finalList = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); var AddAssign = finalList.Select(x => new TaskViewModel() @@ -1151,12 +1248,13 @@ public class TaskRepository : RepositoryBase, ITaskRepository ContractingPartyName = x.ContractingPartyName, Color = x.IsCancelRequest || x.RequestTime || x.IsDoneRequest ? SetRequestTasksColors(x.RequestTime, x.IsCancelRequest, x.IsDoneRequest) : "", MediaCount = x.MediaCount, - HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0), + HasAttachment = x.MediaCount > 0, SelfName = x.SelfName, SelfAssigned = x.SelfAssigned, SelfAssigner = x.SelfAssigner, Description = x.Description, - IsDoneRequest = x.IsDoneRequest + IsDoneRequest = x.IsDoneRequest, + AssignViewModels = x.AssignViewModels }).ToList(); var final = finalAssign.Select(x => new TaskViewModel() @@ -1192,137 +1290,241 @@ public class TaskRepository : RepositoryBase, ITaskRepository Description = x.Description, IsDoneRequest = x.IsDoneRequest, CanCheckRequests = x.Sender.PositionValue >= positionValue, - Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname + Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname, + AssignedReceiverViewModel = x.AssignViewModels.Any() + ? x.AssignViewModels.MinBy(a => a.AssignedPositionValue) + : new() + { + AssignedName = "-", + AssignedPositionValue = 0 + }, }).ToList(); return final; } public string SetTasksColors(DateTime date, bool isCancel) + { + if (isCancel) + { + //return "brown"; + return "green"; + } + + var now = DateTime.Now.Date; + if (date.Date < now) + { + return "dark"; + } + else if (date.Date == now) + { + return "red"; + } + else if (date.Date > now) + { + return "gray"; + } + + return ""; + + } + + public string SetRequestTasksColors(bool timeRequest, bool cancelRequest, bool isDoneRequest) + { + if (timeRequest) + { + return "yellow"; + } + else if (cancelRequest) + { + return "red"; + } + else if (isDoneRequest) + { + return "green"; + } + else + { + return ""; + } + + } + + public int GetRequestedTasksCount() + { + var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); + if (positionValue == 1) + { + return _accountContext.Assigns.Include(x => x.Task).Where(x => + !x.IsDone && x.Task.IsActiveString == "true" && + (x.IsCanceledRequest || x.TimeRequest || x.IsDoneRequest) && accountId == x.Task.SenderId).GroupBy(x => x.TaskId) + .Select(x => x.First()).Count(); + } + else + { + return _accountContext.Assigns.Include(x => x.Task).Where(x => + !x.IsDone && x.Task.IsActiveString == "true" && + (x.IsCanceledRequest == true || x.TimeRequest == true || x.IsDoneRequest) && (accountId == x.Task.SenderId)).GroupBy(x => x.TaskId) + .Select(x => x.First()).Count(); + } + } + + + public EditTask GetRequestDetails(long id) + { + var task = Get(id); + EditTask res; + + if (task.SenderId == _authHelper.CurrentAccountId()) + { + return _accountContext.Tasks.Include(x => x.Assigns).Where(x => x.id == id).Select(x => new EditTask() + { + + Description = x.Description, + Id = x.id, + Title = x.Title, + medias = _accountContext.TaskMedias.Include(z => z.Media).Where(e => e.TaskId == x.id).Select(m => + new MediaViewModel() + { + Path = m.Media.Path, + Type = m.Media.Type, + Category = m.Media.Category, + Id = m.Media.id + }).ToList(), + ContractingPartyName = x.ContractingPartyName, + ReceiverId = _accountContext.Assigns.Where(a => a.TaskId == x.id).Select(a => a.AssignedId).ToList(), + SenderId = x.SenderId, + + AssignViewModels = x.Assigns.Where(a => a.IsCanceledRequest || a.IsDoneRequest || a.TimeRequest).Select( + a => new AssignViewModel() + { + Id = a.id, + EndTaskDateFa = a.EndTaskDate.ToFarsiFull(), + IsCancel = a.IsCancel, + IsCanceledRequest = a.IsCanceledRequest, + IsDone = a.IsDone, + IsDoneRequest = a.IsDoneRequest, + TimeRequest = a.TimeRequest, + AssignedName = a.AssignedName, + AssignedId = a.AssignedId, + RequestDateFa = a.RequestDate.ToFarsi() + + }).ToList(), + TicketViewModel = x.TicketId != null && x.TicketId > 0 + ? _ticketRepository.GetDetails(x.TicketId.Value) + : null, + + }).FirstOrDefault(); + } + else + return new(); + } + + + public string GetWebEnvironmentPath() + { + return _webHostEnvironment.ContentRootPath; + } + + public bool HasOverdueTasks() { - if (isCancel) - { - return "brown"; - } - var now = DateTime.Now.Date; - if (date.Date < now) - { - return "dark"; - } - else if (date.Date == now) - { - return "red"; - } - else if (date.Date > now) - { - return "gray"; - } + var userId = _authHelper.CurrentAccountId(); + var nowDate = DateTime.Now.Date; + var hasOverDueTask = _accountContext.Assigns.Any(x => x.AssignedId == userId && x.EndTaskDate.Date < nowDate && !x.IsCancel && + !x.IsCanceledRequest && !x.IsDone + && !x.IsDoneRequest && !x.TimeRequest); - return ""; - - } - - public string SetRequestTasksColors(bool timeRequest, bool cancelRequest, bool isDoneRequest) - { - if (timeRequest) + var hasOverDueRequest = _accountContext.Assigns.Include(x => x.TaskMessageList) + .Any(x => (x.IsCanceledRequest + || x.IsDoneRequest || x.TimeRequest) && !x.IsCancel && !x.IsDone && + x.TaskMessageList.OrderByDescending(m => m.id).First().CreationDate.Date < nowDate); + if (hasOverDueRequest || hasOverDueTask) { - return "yellow"; - } - else if (cancelRequest) - { - return "red"; - } - else if (isDoneRequest) - { - return "green"; + return true; } else { - return ""; + return false; } } - public int GetRequestedTasksCount() - { - var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); - if (positionValue == 1) - { - return _accountContext.Assigns.Include(x => x.Task).Where(x => - x.Task.IsDone == false && x.Task.IsActiveString == "true" && - (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true || x.Task.IsDoneRequest)&& accountId == x.Task.SenderId).GroupBy(x => x.TaskId) - .Select(x => x.First()).Count(); - } - else - { - return _accountContext.Assigns.Include(x => x.Task).Where(x => - x.Task.IsDone == false && x.Task.IsActiveString == "true" && - (x.Task.IsCanceledRequest == true || x.Task.TimeRequest == true || x.Task.IsDoneRequest) && (accountId == x.Task.SenderId || positionValue < x.AssignerPositionValue)).GroupBy(x => x.TaskId) - .Select(x => x.First()).Count(); - } - } + + // public OperationResult MoveDataFRomTaskToAssign() + // { + // var res = new OperationResult(); + // try + // { + // var tasks = _accountContext.Tasks.ToList(); + + // foreach (var task in tasks) + // { + // var assigns = _accountContext.Assigns.Where(x => x.TaskId == task.id).ToList(); + // foreach (var assign in assigns) + // { + // assign.InsertNewData(task.EndTaskDate, task.TimeRequest, task.AcceptedTimeRequest, task.RequestDate, task.TimeRequestDescription, task.IsCanceledRequest, + // task.IsCancel, task.CancelDescription, task.IsDone, task.IsDoneRequest, task.DoneDescription); + // } + // } + //_positionRepository.SaveChanges(); + // return res.Succcedded(); + // } + // catch (Exception e) + // { + // Console.WriteLine(e); + // return res.Failed("خطای سیستمی"); + // } + + // } - public TaskViewModel GetRequestDetails(long id) - { - return _accountContext.Tasks.Where(x => x.id == id).Select(x => new TaskViewModel() - { - Id = x.id, - Name = x.Title, - ContractingPartyName = x.ContractingPartyName, - TimeRequestDescription = x.TimeRequestDescription, - CancelDescription = x.CancelDescription, - IsDoneDescription = x.DoneDescription, - IsCancelRequest = x.IsDoneRequest, - RequestTime = x.TimeRequest, - IsDoneRequest = x.IsDoneRequest, - RequestTaskDate = x.RequestDate == null ? "" : x.RequestDate.ToFarsi() - }).FirstOrDefault(); - } + public List GetSelfTasks(TaskSearchModel searchModel) + { + var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); + var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var emptyAcc = new AccountViewModel() + { + Fullname = "-", + PositionValue = 0 + }; - public string GetWebEnvironmentPath() - { - return _webHostEnvironment.ContentRootPath; - } + var query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias) + .ThenInclude(x => x.Media) + .Where(x => + x.Task.IsActiveString == "true" && (x.AssignerId == accountId && x.AssignedId == accountId) && + (!x.IsCanceledRequest && !x.TimeRequest && !x.IsDoneRequest)) + .Select(x => + new TaskViewModel() + { + AssignedId = x.AssignedId, + AssignerId = x.AssignerId, + CreateDate = x.Task.CreationDate.ToFarsi(), + EndTaskDateFA = x.EndTaskDate.ToFarsi(), + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDate, + Name = x.Task.Title, + RequestCancel = x.IsCanceledRequest, + RequestTime = x.TimeRequest, + Id = x.Task.id, + CreateTaskDateGE = x.Task.CreationDate, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCanceledRequest, + ContractingPartyName = x.Task.ContractingPartyName, + MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), + Description = x.Task.Description, + IsDoneRequest = x.IsDoneRequest, + }); + if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch)) + { + query = query.Where(x => + (x.Description != null && x.Description.Contains(searchModel.GeneralSearch)) + || x.ContractingPartyName.Contains(searchModel.GeneralSearch) + || x.Name.Contains(searchModel.GeneralSearch)); + } - public List GetSelfTasks(TaskSearchModel searchModel) - { - var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); - var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var emptyAcc = new AccountViewModel() - { - Fullname = "-", - PositionValue = 0 - }; - - var query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media) - .Where(x => - x.Task.IsActiveString == "true" && (x.AssignerId == accountId && x.AssignedId == accountId) && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest)) - .Select(x => - new TaskViewModel() - { - AssignedId = x.AssignedId, - AssignerId = x.AssignerId, - CreateDate = x.Task.CreationDate.ToFarsi(), - EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(), - IsDone = x.Task.IsDone, - EndTaskDateGE = x.Task.EndTaskDate, - Name = x.Task.Title, - RequestCancel = x.Task.IsCanceledRequest, - RequestTime = x.Task.TimeRequest, - Id = x.Task.id, - CreateTaskDateGE = x.Task.CreationDate, - IsCancel = x.Task.IsCancel, - AcceptedTimeRequest = x.Task.AcceptedTimeRequest, - IsCancelRequest = x.Task.IsCanceledRequest, - ContractingPartyName = x.Task.ContractingPartyName, - MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), - Description = x.Task.Description, - IsDoneRequest = x.Task.IsDoneRequest, - - }); var res = query.Select(x => new TaskViewModel() { Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel() @@ -1335,8 +1537,8 @@ public class TaskRepository : RepositoryBase, ITaskRepository SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname, Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id) - .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId) - .ToList(), + .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId) + .ToList(), CreateDate = x.CreateDate, EndTaskDateFA = x.EndTaskDateFA, IsDone = x.IsDone, @@ -1411,24 +1613,25 @@ public class TaskRepository : RepositoryBase, ITaskRepository - var resEnum = res.AsEnumerable(); - var result = resEnum.GroupBy(x => x.Id).Select(x => x.First()); + var result = res.AsEnumerable(); if (searchModel.AccountId > 0) { - result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); + result = result.Where(x => + x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); } var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0) - .ThenBy(x => x.EndTaskDateGE); + .ThenBy(x => x.EndTaskDateGE); var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); final = final.Select(x => new TaskViewModel() { - AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id) + AssignViewModels = _accountContext.Accounts.Include(x => x.Position) + .Where(a => x.Assigned.Contains(a.id) && accountId != a.id) .Select(a => new AssignViewModel() { AssignedName = a.Fullname, @@ -1467,6 +1670,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository AssignViewModels = a.ToList(), PosValue = a.Key }).ToList(), + AssignViewModels = x.AssignViewModels, Sender = x.Sender, Assigned = x.Assigned, CreateDate = x.CreateDate, @@ -1484,7 +1688,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository ContractingPartyName = x.ContractingPartyName, Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel), MediaCount = x.MediaCount, - HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false, + HasAttachment = x.MediaCount > 0, SelfName = x.SelfName, SelfAssigned = x.SelfAssigned, SelfAssigner = x.SelfAssigner, @@ -1524,53 +1728,79 @@ public class TaskRepository : RepositoryBase, ITaskRepository : "", Description = x.Description, IsDoneRequest = x.IsDoneRequest, - CanAssign = _PositionRepository.GetLastPositionValue() != positionValue, + CanAssign = _positionRepository.GetLastPositionValue() != positionValue, CanDelete = x.Sender.Id == accountId, - CanEdit = x.Sender.Id == accountId, - Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname + CanEdit = x.Sender.Id == accountId && !(_accountContext.Assigns.Any(a => a.TaskId == x.Id && (a.AcceptedTimeRequest > 0 || a.IsCanceledRequest + || a.IsDoneRequest || a.TimeRequest || a.IsCancel || a.IsDone))), + Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname, + AssignedReceiverViewModel = x.AssignViewModels.Any() + ? x.AssignViewModels.MinBy(a => a.AssignedPositionValue) + : new() + { + AssignedName = "-", + AssignedPositionValue = 0 + }, }).ToList(); return final; } - public List GetAllNotSelfIncludedTasks(TaskSearchModel searchModel) - { - var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); - var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var emptyAcc = new AccountViewModel() - { - Fullname = "-", - PositionValue = 0 - }; - var query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media) - .Where(x => - x.Task.IsActiveString == "true" && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest) && - x.AssignerId != accountId) - .Select(x => - new TaskViewModel() - { + public List GetReceivedTasks(TaskSearchModel searchModel) + { + var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); + var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var emptyAcc = new AccountViewModel() + { + Fullname = "-", + PositionValue = 0 + }; - AssignedId = x.AssignedId, - AssignerId = x.AssignerId, - CreateDate = x.Task.CreationDate.ToFarsi(), - EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(), - IsDone = x.Task.IsDone, - EndTaskDateGE = x.Task.EndTaskDate, - Name = x.Task.Title, - RequestCancel = x.Task.IsCanceledRequest, - RequestTime = x.Task.TimeRequest, - Id = x.Task.id, - CreateTaskDateGE = x.Task.CreationDate, - IsCancel = x.Task.IsCancel, - AcceptedTimeRequest = x.Task.AcceptedTimeRequest, - IsCancelRequest = x.Task.IsCanceledRequest, - ContractingPartyName = x.Task.ContractingPartyName, - MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), - Description = x.Task.Description, - IsDoneRequest = x.Task.IsDoneRequest, + var raw = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias) + .ThenInclude(x => x.Media) + .Where(x => + x.Task.IsActiveString == "true" && x.AssignedId == accountId && (!x.IsCanceledRequest && !x.TimeRequest && !x.IsDoneRequest)); + if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch)) + { + raw = raw.Where(x => + (x.Task.Description != null && x.Task.Description.Contains(searchModel.GeneralSearch)) + || x.Task.ContractingPartyName.Contains(searchModel.GeneralSearch) + || x.Task.Title.Contains(searchModel.GeneralSearch)); + } + + + + + var query = raw.Select(x => + new TaskViewModel() + { + AssignedId = x.AssignedId, + AssignerId = x.AssignerId, + CreateDate = x.Task.CreationDate.ToFarsi(), + EndTaskDateFA = x.EndTaskDate.ToFarsi(), + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDate, + Name = x.Task.Title, + RequestCancel = x.IsCanceledRequest, + RequestTime = x.TimeRequest, + Id = x.Task.id, + CreateTaskDateGE = x.Task.CreationDate, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCanceledRequest, + ContractingPartyName = x.Task.ContractingPartyName, + MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), + Description = x.Task.Description, + IsDoneRequest = x.IsDoneRequest, + }); + if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch)) + { + query = query.Where(x => + (x.Description != null && x.Description.Contains(searchModel.GeneralSearch)) + || x.ContractingPartyName.Contains(searchModel.GeneralSearch) + || x.Name.Contains(searchModel.GeneralSearch)); + } - }); var res = query.Select(x => new TaskViewModel() { Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel() @@ -1583,8 +1813,8 @@ public class TaskRepository : RepositoryBase, ITaskRepository SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname, Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id) - .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId) - .ToList(), + .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId) + .ToList(), CreateDate = x.CreateDate, EndTaskDateFA = x.EndTaskDateFA, IsDone = x.IsDone, @@ -1659,24 +1889,26 @@ public class TaskRepository : RepositoryBase, ITaskRepository - var resEnum = res.AsEnumerable(); - var result = resEnum.GroupBy(x => x.Id).Select(x => x.First()); + var result = res.AsEnumerable(); + if (searchModel.AccountId > 0) { - result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); + result = result.Where(x => + x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); } var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0) - .ThenBy(x => x.EndTaskDateGE); + .ThenBy(x => x.EndTaskDateGE); var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); final = final.Select(x => new TaskViewModel() { - AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id) + AssignViewModels = _accountContext.Accounts.Include(x => x.Position) + .Where(a => x.Assigned.Contains(a.id) && accountId != a.id) .Select(a => new AssignViewModel() { AssignedName = a.Fullname, @@ -1732,23 +1964,28 @@ public class TaskRepository : RepositoryBase, ITaskRepository ContractingPartyName = x.ContractingPartyName, Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel), MediaCount = x.MediaCount, - HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false, + HasAttachment = x.MediaCount > 0, SelfName = x.SelfName, SelfAssigned = x.SelfAssigned, SelfAssigner = x.SelfAssigner, Description = x.Description, - IsDoneRequest = x.IsDoneRequest + IsDoneRequest = x.IsDoneRequest, + AssignViewModels = x.AssignViewModels }).ToList(); final = final.Select(x => new TaskViewModel() { - AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList, - Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel() - { - PositionValue = 0, - Fullname = "-" - } : x.Sender, + AssignList = !(x.SelfAssigned || x.SelfAssigner) + ? ExtraTools.AddAssign(x.AssignList, x.Sender) + : x.AssignList, + Sender = !(x.SelfAssigned || x.SelfAssigner) + ? new AccountViewModel() + { + PositionValue = 0, + Fullname = "-" + } + : x.Sender, Assigned = x.Assigned, CreateDate = x.CreateDate, EndTaskDateFA = x.EndTaskDateFA, @@ -1772,64 +2009,109 @@ public class TaskRepository : RepositoryBase, ITaskRepository : "", Description = x.Description, IsDoneRequest = x.IsDoneRequest, - CanAssign = _PositionRepository.GetLastPositionValue() != positionValue, + CanAssign = _positionRepository.GetLastPositionValue() != positionValue, CanDelete = x.Sender.Id == accountId, - CanEdit = x.Sender.Id == accountId, - Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname - + CanEdit = x.Sender.Id == accountId && !(_accountContext.Assigns.Any(a => a.TaskId == x.Id && (a.AcceptedTimeRequest > 0 || a.IsCanceledRequest + || a.IsDoneRequest || a.TimeRequest || a.IsCancel || a.IsDone))), + Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname, + AssignedReceiverViewModel = x.AssignViewModels.Any() + ? x.AssignViewModels.MinBy(a => a.AssignedPositionValue) + : new() + { + AssignedName = "-", + AssignedPositionValue = 0 + }, }).ToList(); return final; - - } - public List GetReceivedTasks(TaskSearchModel searchModel) - { - var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); - var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); - var emptyAcc = new AccountViewModel() - { - Fullname = "-", - PositionValue = 0 - }; - - var raw = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias).ThenInclude(x => x.Media) - .Where(x => - x.Task.IsActiveString == "true" && x.AssignedId == accountId && (!x.Task.IsCanceledRequest && !x.Task.TimeRequest && !x.Task.IsDoneRequest)); - if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch)) - { - raw = raw.Where(x => - (x.Task.Description != null && x.Task.Description.Contains(searchModel.GeneralSearch)) - || x.Task.ContractingPartyName.Contains(searchModel.GeneralSearch) - || x.Task.Title.Contains(searchModel.GeneralSearch)); - } + public List GetTasks(TaskSearchModel searchModel) + { + var accountId = long.Parse(_contextAccessor.HttpContext.User.FindFirst("AccountId").Value); + var positionValue = int.Parse(_contextAccessor.HttpContext.User.FindFirst("PositionValue").Value); + var emptyAcc = new AccountViewModel() + { + Fullname = "-", + PositionValue = 0 + }; + IQueryable query; + + if (positionValue == 1) + { + query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias) + .ThenInclude(x => x.Media) + .Where(x => + x.Task.IsActiveString == "true" && (!x.IsCanceledRequest && !x.TimeRequest && !x.IsDoneRequest)) + .Select(x => + new TaskViewModel() + { + AssignedId = x.AssignedId, + AssignerId = x.AssignerId, + CreateDate = x.Task.CreationDate.ToFarsi(), + EndTaskDateFA = x.EndTaskDate.ToFarsi(), + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDate, + Name = x.Task.Title, + RequestCancel = x.IsCanceledRequest, + RequestTime = x.TimeRequest, + Id = x.Task.id, + CreateTaskDateGE = x.Task.CreationDate, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCanceledRequest, + ContractingPartyName = x.Task.ContractingPartyName, + MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), + Description = x.Task.Description, + IsDoneRequest = x.IsDoneRequest, + + }); + } + else + { + query = _accountContext.Assigns.Include(x => x.Task).ThenInclude(x => x.TaskMedias) + .ThenInclude(x => x.Media) + .Where(x => + x.Task.IsActiveString == "true" && (x.AssignedId == accountId || x.AssignerId == accountId)) + .Select(x => + new TaskViewModel() + { + + AssignedId = x.AssignedId, + AssignerId = x.AssignerId, + CreateDate = x.Task.CreationDate.ToFarsi(), + EndTaskDateFA = x.EndTaskDate.ToFarsi(), + IsDone = x.IsDone, + EndTaskDateGE = x.EndTaskDate, + Name = x.Task.Title, + RequestCancel = x.IsCanceledRequest, + RequestTime = x.TimeRequest, + Id = x.Task.id, + CreateTaskDateGE = x.Task.CreationDate, + IsCancel = x.IsCancel, + AcceptedTimeRequest = x.AcceptedTimeRequest, + IsCancelRequest = x.IsCanceledRequest, + ContractingPartyName = x.Task.ContractingPartyName, + MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), + Description = x.Task.Description, + IsDoneRequest = x.IsDoneRequest, - var query = raw.Select(x => - new TaskViewModel() - { - AssignedId = x.AssignedId, - AssignerId = x.AssignerId, - CreateDate = x.Task.CreationDate.ToFarsi(), - EndTaskDateFA = x.Task.EndTaskDate.ToFarsi(), - IsDone = x.Task.IsDone, - EndTaskDateGE = x.Task.EndTaskDate, - Name = x.Task.Title, - RequestCancel = x.Task.IsCanceledRequest, - RequestTime = x.Task.TimeRequest, - Id = x.Task.id, - CreateTaskDateGE = x.Task.CreationDate, - IsCancel = x.Task.IsCancel, - AcceptedTimeRequest = x.Task.AcceptedTimeRequest, - IsCancelRequest = x.Task.IsCanceledRequest, - ContractingPartyName = x.Task.ContractingPartyName, - MediaCount = _accountContext.TaskMedias.Count(m => m.TaskId == x.Task.id), - Description = x.Task.Description, - IsDoneRequest = x.Task.IsDoneRequest, + }); + } - }); + if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch)) + { + query = query.Where(x => + (x.Description != null && x.Description.Contains(searchModel.GeneralSearch)) + || x.ContractingPartyName.Contains(searchModel.GeneralSearch) + || x.Name.Contains(searchModel.GeneralSearch)); + } + + //res = res.GroupBy(x => x.Id).Select(x => x.First()); + //res = res.OrderBy(x => x.IsDone ? 1 : 0) + // .ThenBy(x => x.EndTaskDateGE).ThenBy(x => x.IsCancel ? 0 : 1); var res = query.Select(x => new TaskViewModel() { Sender = _accountContext.Accounts.Include(a => a.Position).Select(a => new AccountViewModel() @@ -1842,8 +2124,8 @@ public class TaskRepository : RepositoryBase, ITaskRepository SelfName = _accountContext.Accounts.FirstOrDefault(a => a.id == accountId).Fullname, Assigned = _accountContext.Assigns.Where(a => a.TaskId == x.Id) - .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId) - .ToList(), + .Where(a => a.AssignedPositionValue >= positionValue).Select(a => a.AssignedId) + .ToList(), CreateDate = x.CreateDate, EndTaskDateFA = x.EndTaskDateFA, IsDone = x.IsDone, @@ -1903,7 +2185,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository bool isTimeRequest = bool.Parse(searchModel.IsTimeRequest); res = res.Where(x => x.RequestTime == isTimeRequest); } - + if (!string.IsNullOrWhiteSpace(searchModel.TimeRequestAccepted)) { res = res.Where(x => x.AcceptedTimeRequest > 0); @@ -1913,7 +2195,7 @@ public class TaskRepository : RepositoryBase, ITaskRepository { bool isCancelReq = bool.Parse(searchModel.IsCancelRequest); res = res.Where(x => x.IsCancelRequest == isCancelReq); - + } @@ -1923,19 +2205,21 @@ public class TaskRepository : RepositoryBase, ITaskRepository if (searchModel.AccountId > 0) { - result = result.Where(x => x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); + result = result.Where(x => + x.Sender.Id == searchModel.AccountId || x.Assigned.Contains(searchModel.AccountId)); } var orderResult = result.OrderByDescending(x => x.IsCancel ? 0 : 1).ThenBy(x => x.IsDone ? 1 : 0) - .ThenBy(x => x.EndTaskDateGE); + .ThenBy(x => x.EndTaskDateGE); var final = orderResult.Skip(searchModel.PageIndex).Take(30).ToList(); final = final.Select(x => new TaskViewModel() { - AssignViewModels = _accountContext.Accounts.Include(x => x.Position).Where(a => x.Assigned.Contains(a.id) && accountId != a.id) + AssignViewModels = _accountContext.Accounts.Include(x => x.Position) + .Where(a => x.Assigned.Contains(a.id) && accountId != a.id) .Select(a => new AssignViewModel() { AssignedName = a.Fullname, @@ -1969,11 +2253,6 @@ public class TaskRepository : RepositoryBase, ITaskRepository final = final.Select(x => new TaskViewModel() { - AssignList = x.AssignViewModels.GroupBy(a => a.AssignedPositionValue).Select(a => new AssignList() - { - AssignViewModels = a.ToList(), - PosValue = a.Key - }).ToList(), Sender = x.Sender, Assigned = x.Assigned, CreateDate = x.CreateDate, @@ -1991,23 +2270,26 @@ public class TaskRepository : RepositoryBase, ITaskRepository ContractingPartyName = x.ContractingPartyName, Color = x.IsDone ? "green" : SetTasksColors(x.EndTaskDateGE, x.IsCancel), MediaCount = x.MediaCount, - HasAttachment = (!string.IsNullOrWhiteSpace(x.Description) || x.MediaCount > 0) ? true : false, + HasAttachment = x.MediaCount > 0, SelfName = x.SelfName, SelfAssigned = x.SelfAssigned, SelfAssigner = x.SelfAssigner, Description = x.Description, - IsDoneRequest = x.IsDoneRequest + IsDoneRequest = x.IsDoneRequest, + AssignViewModels = x.AssignViewModels }).ToList(); final = final.Select(x => new TaskViewModel() { - AssignList = !(x.SelfAssigned || x.SelfAssigner) ? ExtraTools.AddAssign(x.AssignList, x.Sender) : x.AssignList, - Sender = !(x.SelfAssigned || x.SelfAssigner) ? new AccountViewModel() - { - PositionValue = 0, - Fullname = "-" - } : x.Sender, + + Sender = !(x.SelfAssigned || x.SelfAssigner) + ? new AccountViewModel() + { + PositionValue = 0, + Fullname = "-" + } + : x.Sender, Assigned = x.Assigned, CreateDate = x.CreateDate, EndTaskDateFA = x.EndTaskDateFA, @@ -2031,48 +2313,50 @@ public class TaskRepository : RepositoryBase, ITaskRepository : "", Description = x.Description, IsDoneRequest = x.IsDoneRequest, - CanAssign = _PositionRepository.GetLastPositionValue() != positionValue, + CanAssign = _positionRepository.GetLastPositionValue() != positionValue, CanDelete = x.Sender.Id == accountId, - CanEdit = x.Sender.Id == accountId, - Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname + CanEdit = x.Sender.Id == accountId && !(_accountContext.Assigns.Any(a => a.TaskId == x.Id && (a.AcceptedTimeRequest > 0 || a.IsCanceledRequest + || a.IsDoneRequest || a.TimeRequest || a.IsCancel || a.IsDone))), + Assigner = x.Sender.Id == accountId ? emptyAcc.Fullname : x.Sender.Fullname, + AssignedReceiverViewModel = x.AssignViewModels.Any() + ? x.AssignViewModels.MinBy(a => a.AssignedPositionValue) + : new() + { + AssignedName = "-", + AssignedPositionValue = 0 + }, }).ToList(); return final; + } } - - - - - - - public static class ExtraTools { - public static List AddAssign(List list, AccountViewModel acc) - { - list.Add(new AssignList() - { - AssignViewModels = new List() - { - new () - { - AssignedName = acc.Fullname, - AssignedPositionValue = acc.PositionValue - }, - }.ToList(), - PosValue = acc.PositionValue - }); - return list; + public static List AddAssign(List list, AccountViewModel acc) + { + list.Add(new AssignList() + { + AssignViewModels = new List() + { + new () + { + AssignedName = acc.Fullname, + AssignedPositionValue = acc.PositionValue + }, + }.ToList(), + PosValue = acc.PositionValue + }); + return list; - } + } - public static List AddAccountIdToList(List list, long accountId) - { - list.Add(accountId); - return list; - } + public static List AddAccountIdToList(List list, long accountId) + { + list.Add(accountId); + return list; + } } \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TicketAccessAccountRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TicketAccessAccountRepository.cs new file mode 100644 index 00000000..08546027 --- /dev/null +++ b/AccountMangement.Infrastructure.EFCore/Repository/TicketAccessAccountRepository.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using System.Linq; +using _0_Framework.Application; +using _0_Framework.InfraStructure; +using AccountManagement.Application.Contracts.TicketAccessAccount; +using AccountManagement.Domain.TicketAccessAccountAgg; + +namespace AccountMangement.Infrastructure.EFCore.Repository; + +public class TicketAccessAccountRepository:RepositoryBase, ITicketAccessAccountRepository +{ + private readonly AccountContext _accountContext; + + public TicketAccessAccountRepository(AccountContext accountContext):base(accountContext) + { + _accountContext = accountContext; + } + + public bool HasTicketAccess(long accountId) + { + return _accountContext.TicketAccessAccounts.Any(x => x.AccountId == accountId); + } + + public List GetAllAccessedAccounts() + { + return _accountContext.TicketAccessAccounts.Select(x => new TicketAccessAccountViewModel() + { + CreateDateFa = x.CreationDate.ToFarsi(), + Name = _accountContext.Accounts.FirstOrDefault(a => a.id == x.AccountId).Fullname, + AccountId = x.AccountId, + Id = x.id + }).ToList(); + } + + public void Remove(long id) + { + var entity = Get(id); + _accountContext.Remove(entity); + + } +} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs index 368174f9..9419e62c 100644 --- a/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs +++ b/AccountMangement.Infrastructure.EFCore/Repository/TicketRepository.cs @@ -1,13 +1,17 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography.X509Certificates; using _0_Framework.Application; using _0_Framework.InfraStructure; +using AccountManagement.Application.Contracts.Account; using AccountManagement.Application.Contracts.Media; using AccountManagement.Application.Contracts.Ticket; using AccountManagement.Domain.AdminResponseAgg; using AccountManagement.Domain.ClientResponseAgg; using AccountManagement.Domain.ClientResponseMediaAgg; using AccountManagement.Domain.TicketAgg; +using Company.Domain.WorkshopAgg; using Microsoft.EntityFrameworkCore; namespace AccountMangement.Infrastructure.EFCore.Repository; @@ -15,9 +19,15 @@ namespace AccountMangement.Infrastructure.EFCore.Repository; public class TicketRepository : RepositoryBase, ITicketRepository { private readonly AccountContext _accountContext; - public TicketRepository(AccountContext accountContext) : base(accountContext) + private readonly IAuthHelper _authHelper; + private readonly IPasswordHasher _passwordHasher; + private readonly IWorkshopRepository _workshopRepository; + public TicketRepository(AccountContext accountContext, IAuthHelper authHelper, IPasswordHasher passwordHasher, IWorkshopRepository workshopRepository) : base(accountContext) { _accountContext = accountContext; + _authHelper = authHelper; + _passwordHasher = passwordHasher; + _workshopRepository = workshopRepository; } public List GetAll(TicketSearchModel searchModel) @@ -31,45 +41,92 @@ public class TicketRepository : RepositoryBase, ITicketRepository Title = x.Title, TicketType = x.TicketType, Status = x.Status, - TaskId = x.TaskId, CreationDateTimeGr = x.CreationDate, CreationDateTime = x.CreationDate.ToFarsiFull(), - MediaViewModels = _accountContext.TicketMedias.Include(z => z.Media).Where(a => a.TicketId == x.id) - .Select(m => new MediaViewModel() - { - Id = m.Media.id, - Path = m.Media.Path, - Type = m.Media.Type, - }).ToList(), - AdminResponseViewModels = _accountContext.AdminResponses.Include(a => a.AdminResponseMedias) - .Where(a => a.TicketId == x.id).Select(a => new AdminResponseViewModel() - { - MediaViewModels = _accountContext.AdminResponseMedias.Include(d => d.Media) - .Where(d => d.AdminResponseId == a.id).Select(d => new MediaViewModel() - { - Id = d.Media.id, - Path = d.Media.Path, - Type = d.Media.Type, - }).ToList(), - Response = a.Response, - TicketId = a.TicketId - }).ToList(), - ClientResponseViewModels = _accountContext.ClientResponses.Include(a => a.ClientResponseMedias) - .Where(a => a.TicketId == x.id).Select(a => new ClientResponseViewModel() - { - MediaViewModels = _accountContext.ClientResponseMedias.Include(d => d.Media) - .Where(d => d.ClientResponseId == a.id).Select(d => new MediaViewModel() - { - Id = d.Media.id, - Path = d.Media.Path, - Type = d.Media.Type, - }).ToList(), - Response = a.Response, - TicketId = a.TicketId - }).ToList(), - + TicketNumber = $"TKC_{x.TicketNumber}", + WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName, + HasTask = _accountContext.Tasks.Include(t => t.Assigns).Any(t => t.TicketId == x.id && t.Assigns.Any(a => !a.IsDone)), + WorkshopId = x.WorkshopId, + RawTicketNumber = x.TicketNumber }); + #region Search + + + if (!string.IsNullOrWhiteSpace(searchModel.Status)) + { + query = query.Where(x => x.Status == searchModel.Status); + } + + if (!(string.IsNullOrWhiteSpace(searchModel.StartDate) && string.IsNullOrWhiteSpace(searchModel.EndDate))) + { + if (string.IsNullOrWhiteSpace(searchModel.OneDay)) + { + var startDate = searchModel.StartDate.ToGeorgianDateTime(); + var endDate = searchModel.EndDate.ToGeorgianDateTime(); + query = query.Where(x => startDate < x.CreationDateTimeGr && endDate > x.CreationDateTimeGr); + } + } + + if (!string.IsNullOrWhiteSpace(searchModel.OneDay)) + { + var oneDay = searchModel.OneDay.ToGeorgianDateTime(); + query = query.Where(x =>x.CreationDateTimeGr.Date == oneDay.Date); + } + + if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch)) + { + + query = query.Where(x => x.Title.Contains(searchModel.GeneralSearch) ||x.ContractingPartyName.Contains(searchModel.GeneralSearch)||x.WorkshopName.Contains(searchModel.GeneralSearch)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.OneDay)) + { + var day = searchModel.OneDay.ToGeorgianDateTime(); + query = query.Where(x => x.CreationDateTimeGr.Date == day.Date); + } + + if (!string.IsNullOrWhiteSpace(searchModel.ContractingPartyName)) + { + query = query.Where(x => x.ContractingPartyName == searchModel.ContractingPartyName.Trim()); + } + + if (searchModel.WorkshopId>0) + { + query = query.Where(x => x.WorkshopId == searchModel.WorkshopId); + } + + if (!string.IsNullOrWhiteSpace(searchModel.TicketNumber)) + { + query = query.Where(x => x.RawTicketNumber == searchModel.TicketNumber); + } + + if (!string.IsNullOrWhiteSpace(searchModel.Status)) + { + query = query.Where(x => x.Status == searchModel.Status.Trim()); + } + #endregion + + + return query.Skip(searchModel.PageIndex).Take(30).ToList(); + } + + public List GetTicketsForClients(TicketSearchModel searchModel) + { + + var accountId = _authHelper.CurrentAccountId(); + + var workshopSlug = _authHelper.GetWorkshopSlug(); + var workshopId = _passwordHasher.SlugDecrypt(workshopSlug); + IQueryable query; + if (workshopId > 0) + { + query = _accountContext.Tickets.Where(x => x.SenderId == accountId && x.WorkshopId == workshopId); + } + else + { + query = _accountContext.Tickets.Where(x => x.SenderId == accountId); + } if (!string.IsNullOrWhiteSpace(searchModel.ContractingPartyName)) { query = query.Where(x => x.ContractingPartyName.Contains(searchModel.ContractingPartyName)); @@ -86,42 +143,49 @@ public class TicketRepository : RepositoryBase, ITicketRepository { var startDate = searchModel.StartDate.ToGeorgianDateTime(); var endDate = searchModel.EndDate.ToGeorgianDateTime(); - query = query.Where(x => startDate < x.CreationDateTimeGr && endDate > x.CreationDateTimeGr); + query = query.Where(x => startDate < x.CreationDate && endDate > x.CreationDate); } } - if (!string.IsNullOrWhiteSpace(searchModel.Title)) + if (!string.IsNullOrWhiteSpace(searchModel.GeneralSearch)) { - query = query.Where(x => x.Title.Contains(searchModel.Title)); + query = query.Where(x => x.Title.Contains(searchModel.GeneralSearch)); } - if (!string.IsNullOrWhiteSpace(searchModel.TypeOfTicket)) + if (!string.IsNullOrWhiteSpace(searchModel.Status)) { - query = query.Where(x => x.TicketType == searchModel.TypeOfTicket); + query = query.Where(x => x.Status == searchModel.Status); } if (!string.IsNullOrWhiteSpace(searchModel.OneDay)) { var day = searchModel.OneDay.ToGeorgianDateTime(); - query = query.Where(x => x.CreationDateTimeGr.Date == day.Date); + query = query.Where(x => x.CreationDate.Date == day.Date); } - if (!string.IsNullOrWhiteSpace(searchModel.IsAssigned)) + + var res = query.OrderBy(x=>x.Status.Trim()=="بسته شده").ThenByDescending(x => x.CreationDate).Select(x => new TicketViewModel() { - var isAssigned = bool.Parse(searchModel.IsAssigned); - if (isAssigned) - { - query.Where(x => x.TaskId != null); - } - else if (!isAssigned) - { - query.Where(x => x.TaskId == null); - } - } - return query.ToList(); + Description = x.Description, + SenderId = x.SenderId, + ContractingPartyName = x.ContractingPartyName, + Id = x.id, + Title = x.Title, + TicketType = x.TicketType, + Status = x.Status, + CreationDateTimeGr = x.CreationDate, + CreationDateTime = x.CreationDate.ToFarsi(), + TicketNumber = $"TKC_{x.TicketNumber}", + WorkshopName = _workshopRepository.Get(x.WorkshopId).WorkshopFullName + + }); + + + return res.Skip(searchModel.PageIndex).Take(30).ToList(); } + public void CreateAdminResponse(AdminResponse command) { _accountContext.Add(command); @@ -134,48 +198,203 @@ public class TicketRepository : RepositoryBase, ITicketRepository public EditTicket GetDetails(long id) { - return _accountContext.Tickets.Select(x => new EditTicket() + var query = _accountContext.Tickets.Select(x => new EditTicket() { ContractingPartyName = x.ContractingPartyName, Description = x.Description, Id = x.id, SenderId = x.SenderId, + Sender = _accountContext.Accounts.Select(account => new AccountViewModel() + { + Id = account.id, + Fullname = account.Fullname, + }).Where(a => a.Id == x.SenderId).FirstOrDefault(), TicketType = x.TicketType, Title = x.Title, + CreationDateStr = x.CreationDate.ToFarsi(), MediaViewModels = _accountContext.TicketMedias.Include(z => z.Media).Where(a => a.TicketId == x.id) .Select(m => new MediaViewModel() { Id = m.Media.id, Path = m.Media.Path, Type = m.Media.Type, + Category = m.Media.Category, }).ToList(), - ClientResponseViewModels = _accountContext.ClientResponses.Where(c => c.TicketId == x.id) .Select(m => new ClientResponseViewModel() { Response = m.Response, TicketId = m.TicketId, - MediaViewModels = _accountContext.ClientResponseMedias.Include(a => a.Media).Where(a => a.ClientResponseId == m.id).Select(cm => new MediaViewModel() - { - Category = cm.Media.Category, - Path = cm.Media.Path, - Id = cm.Media.id, - Type = cm.Media.Type, - }).ToList(), + MediaViewModels = _accountContext.ClientResponseMedias.Include(a => a.Media) + .Where(a => a.ClientResponseId == m.id).Select(cm => new MediaViewModel() + { + Category = cm.Media.Category, + Path = cm.Media.Path, + Id = cm.Media.id, + Type = cm.Media.Type, + }).ToList(), + CreationDate = m.CreationDate, + Id = m.id, }).ToList(), AdminResponseViewModels = _accountContext.AdminResponses.Where(c => c.TicketId == x.id) .Select(m => new AdminResponseViewModel() { Response = m.Response, + FullName = _accountContext.Accounts.FirstOrDefault(ac => ac.id == m.AdminAccountId).Fullname, TicketId = m.TicketId, - MediaViewModels = _accountContext.AdminResponseMedias.Include(a => a.Media).Where(a => a.AdminResponseId == m.id).Select(cm => new MediaViewModel() - { - Category = cm.Media.Category, - Path = cm.Media.Path, - Id = cm.Media.id, - Type = cm.Media.Type, - }).ToList(), + AdminAccountId = m.AdminAccountId, + MediaViewModels = _accountContext.AdminResponseMedias.Include(a => a.Media) + .Where(a => a.AdminResponseId == m.id).Select(cm => new MediaViewModel() + { + Category = cm.Media.Category, + Path = cm.Media.Path, + Id = cm.Media.id, + Type = cm.Media.Type, + }).ToList(), + CreationDate = m.CreationDate, + Id = m.id, + IsActive = m.IsActiveString, + }).ToList(), + WorkshopId = x.WorkshopId, + TicketNumber = $"TKC_{x.TicketNumber}", + Status = x.Status + }).FirstOrDefault(x => x.Id == id); + + query.ResponseViewModels = MergeResponses(query.ClientResponseViewModels, query.AdminResponseViewModels); + + return query; + } + + public EditTicket GetDetailsForClient(long id) + { + var query = _accountContext.Tickets.Select(x => new EditTicket() + { + ContractingPartyName = x.ContractingPartyName, + Description = x.Description, + Id = x.id, + SenderId = x.SenderId, + Sender = _accountContext.Accounts.Select(account => new AccountViewModel() + { + Id = account.id, + Fullname = account.Fullname, + }).Where(a => a.Id == x.SenderId).FirstOrDefault(), + TicketType = x.TicketType, + Title = x.Title, + CreationDateStr = $"{x.CreationDate.ToFarsi()} {x.CreationDate.DayOfWeek.DayOfWeeKToPersian()}", + MediaViewModels = _accountContext.TicketMedias.Include(z => z.Media).Where(a => a.TicketId == x.id) + .Select(m => new MediaViewModel() + { + Id = m.Media.id, + Path = m.Media.Path, + Type = m.Media.Type, + Category = m.Media.Category, + }).ToList(), + ClientResponseViewModels = _accountContext.ClientResponses.Where(c => c.TicketId == x.id) + .Select(m => new ClientResponseViewModel() + { + Response = m.Response, + TicketId = m.TicketId, + MediaViewModels = _accountContext.ClientResponseMedias.Include(a => a.Media) + .Where(a => a.ClientResponseId == m.id).Select(cm => new MediaViewModel() + { + Category = cm.Media.Category, + Path = cm.Media.Path, + Id = cm.Media.id, + Type = cm.Media.Type, + }).ToList(), + CreationDate = m.CreationDate, + Id = m.id, + }).ToList(), + AdminResponseViewModels = _accountContext.AdminResponses.Where(c => c.TicketId == x.id && c.IsActiveString == "true") + .Select(m => new AdminResponseViewModel() + { + Response = m.Response, + TicketId = m.TicketId, + MediaViewModels = _accountContext.AdminResponseMedias.Include(a => a.Media) + .Where(a => a.AdminResponseId == m.id).Select(cm => new MediaViewModel() + { + Category = cm.Media.Category, + Path = cm.Media.Path, + Id = cm.Media.id, + Type = cm.Media.Type, + }).ToList(), + CreationDate = m.CreationDate, + Id = m.id, + IsActive = m.IsActiveString + }).ToList(), + WorkshopId = x.WorkshopId, + TicketNumber = $"TKC_{x.TicketNumber}", + Status = x.Status + + }).FirstOrDefault(x => x.Id == id); + + query.ResponseViewModels = MergeResponses(query.ClientResponseViewModels, query.AdminResponseViewModels); + + return query; + } + + public int GetLastTicketNumber() + { + var res = _accountContext.Tickets.Any(x => x.TicketNumber != null) ? _accountContext.Tickets.Max(x => Convert.ToInt32(x.TicketNumber)) : 0; + return res; + } + + public AdminResponse GetAdminResponse(long adminResId) + { + return _accountContext.AdminResponses.FirstOrDefault(x => x.id == adminResId); + } + + public ClientResponse GetClientResponse(long clientResId) + { + return _accountContext.ClientResponses.FirstOrDefault(x => x.id == clientResId); + } + + public void RemoveAdminResponse(long adminResId) + { + + var adminRes =_accountContext.AdminResponses.Include(x=>x.AdminResponseMedias).ThenInclude(x=>x.Media).FirstOrDefault(x => x.id == adminResId); + if (adminRes != null) + { + _accountContext.RemoveRange(adminRes.AdminResponseMedias); + _accountContext.Remove(adminRes); + } + + } + + public List MergeResponses(List clientResponseList, List adminResponseList) + { + var list = new List(); + var adminList = adminResponseList.Select(x => new Response() + { + TicketId = x.TicketId, + ResponseMessage = x.Response, + IsClient = false, + IsAdmin = true, + IsActive = x.IsActive, + FullName = x.FullName, + CreationDate = x.CreationDate, + CreationDateStr =$"{x.CreationDate.ToFarsi()} {x.CreationDate.DayOfWeek.DayOfWeeKToPersian()} {x.CreationDate.Hour}:{x.CreationDate.Minute}" , + MediaViewModels = x.MediaViewModels, + AdminResponseId = x.Id, + AdminAccountId = x.AdminAccountId + }).ToList(); + var clientList = clientResponseList.Select(x => new Response() + { + TicketId = x.TicketId, + ResponseMessage = x.Response, + IsClient = true, + IsAdmin = false, + CreationDateStr = $"{x.CreationDate.ToFarsi()} {x.CreationDate.DayOfWeek.DayOfWeeKToPersian()} {x.CreationDate.Hour}:{x.CreationDate.Minute}", + CreationDate = x.CreationDate, + MediaViewModels = x.MediaViewModels, + ClientResponseId = x.Id + }).ToList(); + + list.Capacity = (adminList.Count + clientList.Count); + list.AddRange(adminList); + list.AddRange(clientList); + return list.OrderBy(x => x.CreationDate).ToList(); } } \ No newline at end of file diff --git a/Company.Domain/Error/ErrorViewModel.cs b/Company.Domain/Error/ErrorViewModel.cs new file mode 100644 index 00000000..e4ffaa9e --- /dev/null +++ b/Company.Domain/Error/ErrorViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CompanyManagment.App.Contracts.Error; +public class ErrorViewModel +{ + public bool IsSuccedded { get; set; } + public string WorkshopFullName { get; set; } + public string Message { get; set; } +} diff --git a/CompanyManagment.App.Contracts/HolidayItem/IHolidayItemApplication.cs b/CompanyManagment.App.Contracts/HolidayItem/IHolidayItemApplication.cs index 37b0e40f..d5b058c3 100644 --- a/CompanyManagment.App.Contracts/HolidayItem/IHolidayItemApplication.cs +++ b/CompanyManagment.App.Contracts/HolidayItem/IHolidayItemApplication.cs @@ -10,6 +10,12 @@ public interface IHolidayItemApplication OperationResult Edit(EditHolidayItem command); EditHolidayItem GetDetails(long id); List GetHolidayItem(string year); + + #region Mahan + + bool IsHoliday(DateTime holidayCheck); + + #endregion bool GetHoliday(DateTime holidayCheck); List Search(HolidayItemSearchModel searchModel); } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/RollCallEmployee/RollCallEmployeeViewModel.cs b/CompanyManagment.App.Contracts/RollCallEmployee/RollCallEmployeeViewModel.cs index b7f04225..5b330634 100644 --- a/CompanyManagment.App.Contracts/RollCallEmployee/RollCallEmployeeViewModel.cs +++ b/CompanyManagment.App.Contracts/RollCallEmployee/RollCallEmployeeViewModel.cs @@ -8,4 +8,24 @@ namespace CompanyManagment.App.Contracts.RollCallEmployee; public class RollCallEmployeeViewModel : EditRollCallEmployee { public string NationalCode { get; set; } + public string ImagePath { get; set; } + + // check the contract & checkout + public string PersonName { get; set; } + public bool ContractPerson { get; set; } + public bool InsurancePerson { get; set; } + public long WorkshopId { get; set; } + public long EmployeeId { get; set; } + public bool ContractLeft { get; set; } + public bool InsurancetLeft { get; set; } + public bool Black { get; set; } + public DateTime StartWork { get; set; } + public long PersonelCode { get; set; } + //نحوه محاسبه مزد مرخصی + public string ComputeOptions { get; set; } + //نحوه محاسبه عیدی + public string BonusesOptions { get; set; } + //نحوه محاسبه سنوات + public string YearsOptions { get; set; } + public string EmployeeSlug { get; set; } } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/Workshop/TakePictureModel.cs b/CompanyManagment.App.Contracts/Workshop/TakePictureModel.cs index fde15cee..e9ea2295 100644 --- a/CompanyManagment.App.Contracts/Workshop/TakePictureModel.cs +++ b/CompanyManagment.App.Contracts/Workshop/TakePictureModel.cs @@ -13,5 +13,6 @@ namespace CompanyManagment.App.Contracts.Workshop public long EmployeeId { get; set; } public string Name { get; set; } public IFormFile ProfilePhoto { get; set; } + public bool HasPicture { get; set; } } } diff --git a/CompanyManagment.Application/HolidayItemApplication.cs b/CompanyManagment.Application/HolidayItemApplication.cs index 7ba86066..6acda26c 100644 --- a/CompanyManagment.Application/HolidayItemApplication.cs +++ b/CompanyManagment.Application/HolidayItemApplication.cs @@ -49,6 +49,11 @@ public class HolidayItemApplication : IHolidayItemApplication return _holidayItemRepository.GetHolidayItem(year); } + public bool IsHoliday(DateTime holidayCheck) + { + return _holidayItemRepository.GetHoliday(holidayCheck); + } + public bool GetHoliday(DateTime holidayCheck) { return _holidayItemRepository.GetHoliday(holidayCheck); diff --git a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs index 2425cc4a..61521129 100644 --- a/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs +++ b/CompanyManagment.EFCore/Repository/RollCallMandatoryRepository.cs @@ -42,7 +42,6 @@ public class RollCallMandatoryRepository : RepositoryBase, IRoll string SumWorkeTime = string.Empty; var weeklyTime = new TimeSpan(); string shift1Hourse = "0"; - string shift1Minuts = "0"; string overMandatoryHours = "0"; string overMandatoryMinuts = "0"; string shiftOver22Hours = "0"; diff --git a/ServiceHost/Areas/Admin/Pages/Shared/_Menu.cshtml b/ServiceHost/Areas/Admin/Pages/Shared/_Menu.cshtml index eb2407cd..b7a19eef 100644 --- a/ServiceHost/Areas/Admin/Pages/Shared/_Menu.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Shared/_Menu.cshtml @@ -1,6 +1,9 @@ @using System.Reflection.Metadata +@using AccountManagement.Domain.TicketAccessAccountAgg +@using Microsoft.AspNetCore.Mvc.TagHelpers @*@using _0_Framework.Infrastructure*@ @inject _0_Framework.Application.IAuthHelper AuthHelper; +@inject ITicketAccessAccountRepository TicketAccessAccount; @{
- +
@@ -50,7 +68,7 @@
-
+
@@ -58,7 +76,8 @@
- +@* *@ + - + diff --git a/ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateModal.cshtml b/ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateModal.cshtml new file mode 100644 index 00000000..3a8e2127 --- /dev/null +++ b/ServiceHost/Areas/AdminNew/Pages/Company/Task/CreateModal.cshtml @@ -0,0 +1,338 @@ +@model AccountManagement.Application.Contracts.Task.CreateTaskModal +@* @model ServiceHost.Areas.AdminNew.Pages.Company.Task.CreateModel *@ +@using Version = _0_Framework.Application.Version + +@{ + ViewData["title"] = " - وظیفه جدید"; +} + + + + + + + + + + + +@* -
-@*شنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -@*یکشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*دوشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -@*سه شنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*چهارشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*پنجشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*جمعه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-@*شنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -@*یکشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*دوشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -@*سه شنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*چهارشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*پنجشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*جمعه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-@*شنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -@*یکشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*دوشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -@*سه شنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*چهارشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*پنجشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*جمعه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - -
-@*Header*@ -
- - - - - - مقطع اول کار - - - - - - مدت استراحت - - - - - - - - مقطع دوم کار - - - - - - - - - - -
- -@*شنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -@*یکشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*دوشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -@*سه شنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*چهارشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*پنجشنبه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-@*جمعه*@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - -@*آدرس*@ -
-
-
-
- محل انجام کار 1 - -
-
- محل انجام کار 2 - -
-
-
-
- تست محاسبه -
- - ذخیره - ذخیره - -
- - - - - - - - + + + @**@ \ No newline at end of file + $(window).on("load", part2()); + function part2() { + $(".dateMask").mask("0000/00/00"); + var shiftnumber = $('#shiftWork').val(); + var tow = $('.tow'); + ///////////////////////////// Shift Control Database value///////////////////// + //حالات شیفت بالا بر اساس ولیو + if (shiftnumber === "1") { + $('#Sh1').addClass("shiftActive"); + $('#NormalShift').addClass("shiftCateoryActive"); + towDeactive(); + + } + if (shiftnumber === "2") { + $('#Sh2').addClass("shiftActive"); + $('#NormalShift').addClass("shiftCateoryActive"); + restDeactive(); + } + if (shiftnumber === "4") { + $('#Sh4').addClass("shiftActive"); + $('#RotatingShift').addClass("shiftCateoryActive"); + $('#OneAndTowFildset').addClass("shiftDisplayNone"); + $('#ComplexFildset').addClass("shiftDisplayNone"); + $('#WeeklyFildset').removeClass("shiftDisplayNone"); + towActive(); + restActive(); + + + + } + if (shiftnumber === "5") { + $('#Sh5').addClass("shiftActive"); + $('#ComplexShift').addClass("shiftCateoryActive"); + $('#OneAndTowFildset').addClass("shiftDisplayNone"); + $('#ComplexFildset').removeClass("shiftDisplayNone"); + } + if (shiftnumber === "6") { + $('#Sh6').addClass("shiftActive"); + $('#ComplexShift').addClass("shiftCateoryActive"); + $('#OneAndTowFildset').addClass("shiftDisplayNone"); + $('#ComplexFildset').removeClass("shiftDisplayNone"); + } + if (shiftnumber === "7") { + $('#Sh7').addClass("shiftActive"); + $('#ComplexShift').addClass("shiftCateoryActive"); + $('#OneAndTowFildset').addClass("shiftDisplayNone"); + $('#ComplexFildset').removeClass("shiftDisplayNone"); + } + if (shiftnumber === "8") { + $('#Sh8').addClass("shiftActive"); + $('#ComplexShift').addClass("shiftCateoryActive"); + $('#OneAndTowFildset').addClass("shiftDisplayNone"); + $('#ComplexFildset').removeClass("shiftDisplayNone"); + } + ////////////////////////////default ///////////////////// + if (shiftnumber === "") { + + $('.dayNumber').addClass("btn-active"); + $('#Sh1').addClass("shiftActive"); + $('#NormalShift').addClass("shiftCateoryActive"); + //دیسبل کردن سطر جمعه + $('#jomehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + + }); + $('#jomehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + + }); + $('#jomehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + + }); + $('#jomehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + + }); + $('#jomehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + + }); + $('#jomehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + + }); + $('#shiftWork').val("1"); + $('#f').prop('checked', true); + $('#f1').prop('checked', true); + $('#f2').prop('checked', true); + $('#f3').prop('checked', true); + $('#f4').prop('checked', true); + $('#f5').prop('checked', true); + $('#f6').prop('checked', false); + + weeklyBtnDefault(); + //دیسیبل کردن اینپوت ساعت های شیفت دو + towDeactive(); + + ///////////////////////////day of week on database value///////////// + } else {// روشن کردن روزهای هفته بر اساس ولیو + if (shiftnumber === "1" || shiftnumber === "2") { + if ($('#f').is(":checked")) {//شنبه + $('#shanbeh').addClass("btn-active"); + } else { + $('#shanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#shanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + } + if ($('#f1').is(":checked")) {//یکشنبه + $('#yekshanbeh').addClass("btn-active"); + } else { + $('#yekshanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#yekshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + } + if ($('#f2').is(":checked")) {//دوشنبه + $('#doshanbeh').addClass("btn-active"); + } else { + $('#doshanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#doshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + + } + if ($('#f3').is(":checked")) {//سه شنبه + $('#seshanbeh').addClass("btn-active"); + } else { + $('#seshanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#seshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + } + if ($('#f4').is(":checked")) {//چهارشنبه + $('#cheharshanbeh').addClass("btn-active"); + } else { + $('#cheharshanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#cheharshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + } + if ($('#f5').is(":checked")) {//پنجشنبه + $('#panjshanbeh').addClass("btn-active"); + + } else { + $('#panjshanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#panjshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + } + if ($('#f6').is(":checked")) {//جمعه + $('#jomeh').addClass("btn-active"); + } else { + $('#jomehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#jomehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + + } + }else if (shiftnumber === "4" ) { + // روشن کردن روزها بر اساس ولیو + //week1 days by value + if ($('#fw1').is(":checked")) {//شنبه + $('#shanbehw1').addClass("btn-active"); + } else { + $('#shanbehw1').removeClass("btn-active"); + $('#shanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#shanbehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f1w1').is(":checked")) {//یکشنبه + $('#yekshanbehw1').addClass("btn-active"); + } else { + $('#yekshanbehw1').removeClass("btn-active"); + $('#yekshanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#yekshanbehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f2w1').is(":checked")) {//دوشنبه + $('#doshanbehw1').addClass("btn-active"); + } else { + $('#doshanbehw1').removeClass("btn-active"); + $('#doshanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#doshanbehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + + } + if ($('#f3w1').is(":checked")) {//سه شنبه + $('#seshanbehw1').addClass("btn-active"); + } else { + $('#seshanbehw1').removeClass("btn-active"); + $('#seshanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#seshanbehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f4w1').is(":checked")) {//چهارشنبه + $('#cheharshanbehw1').addClass("btn-active"); + } else { + $('#cheharshanbehw1').removeClass("btn-active"); + $('#cheharshanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#cheharshanbehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f5w1').is(":checked")) {//پنجشنبه + $('#panjshanbehw1').addClass("btn-active"); + + } else { + $('#panjshanbehw1').removeClass("btn-active"); + $('#panjshanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#panjshanbehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f6w1').is(":checked")) {//جمعه + $('#jomehw1').addClass("btn-active"); + } else { + $('#jomehw1').removeClass("btn-active"); + $('#jomehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + + } + //week2 days by value + if ($('#fw2').is(":checked")) {//شنبه + $('#shanbehw2').addClass("btn-active"); + } else { + $('#shanbehw2').removeClass("btn-active"); + $('#shanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#shanbehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f1w2').is(":checked")) {//یکشنبه + $('#yekshanbehw2').addClass("btn-active"); + } else { + $('#yekshanbehw2').removeClass("btn-active"); + $('#yekshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#yekshanbehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f2w2').is(":checked")) {//دوشنبه + $('#doshanbehw2').addClass("btn-active"); + } else { + $('#doshanbehw2').removeClass("btn-active"); + $('#doshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#doshanbehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + + } + if ($('#f3w2').is(":checked")) {//سه شنبه + $('#seshanbehw2').addClass("btn-active"); + } else { + $('#seshanbehw2').removeClass("btn-active"); + $('#seshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#seshanbehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f4w2').is(":checked")) {//چهارشنبه + $('#cheharshanbehw2').addClass("btn-active"); + } else { + $('#cheharshanbehw2').removeClass("btn-active"); + $('#cheharshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#cheharshanbehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f5w2').is(":checked")) {//پنجشنبه + $('#panjshanbehw2').addClass("btn-active"); + + } else { + $('#panjshanbehw2').removeClass("btn-active"); + $('#panjshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#panjshanbehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f6w2').is(":checked")) {//جمعه + $('#jomehw2').addClass("btn-active"); + } else { + $('#jomehw2').removeClass("btn-active"); + $('#jomehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + + } + + //week3 days by value + if ($('#fw3').is(":checked")) {//شنبه + $('#shanbehw3').addClass("btn-active"); + } else { + $('#shanbehw3').removeClass("btn-active"); + $('#shanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#shanbehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f1w3').is(":checked")) {//یکشنبه + $('#yekshanbehw3').addClass("btn-active"); + } else { + $('#yekshanbehw3').removeClass("btn-active"); + $('#yekshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#yekshanbehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f2w3').is(":checked")) {//دوشنبه + $('#doshanbehw3').addClass("btn-active"); + } else { + $('#doshanbehw3').removeClass("btn-active"); + $('#doshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#doshanbehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + + } + if ($('#f3w3').is(":checked")) {//سه شنبه + $('#seshanbehw3').addClass("btn-active"); + } else { + $('#seshanbehw3').removeClass("btn-active"); + $('#seshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#seshanbehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f4w3').is(":checked")) {//چهارشنبه + $('#cheharshanbehw3').addClass("btn-active"); + } else { + $('#cheharshanbehw3').removeClass("btn-active"); + $('#cheharshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#cheharshanbehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f5w3').is(":checked")) {//پنجشنبه + $('#panjshanbehw3').addClass("btn-active"); + + } else { + $('#panjshanbehw3').removeClass("btn-active"); + $('#panjshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#panjshanbehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f6w3').is(":checked")) {//جمعه + $('#jomehw3').addClass("btn-active"); + } else { + $('#jomehw3').removeClass("btn-active"); + $('#jomehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + + } + + //week4 days by value + if ($('#fw4').is(":checked")) {//شنبه + $('#shanbehw4').addClass("btn-active"); + } else { + $('#shanbehw4').removeClass("btn-active"); + $('#shanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#shanbehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f1w4').is(":checked")) {//یکشنبه + $('#yekshanbehw4').addClass("btn-active"); + } else { + $('#yekshanbehw4').removeClass("btn-active"); + $('#yekshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#yekshanbehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f2w4').is(":checked")) {//دوشنبه + $('#doshanbehw4').addClass("btn-active"); + } else { + $('#doshanbehw4').removeClass("btn-active"); + $('#doshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#doshanbehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + + } + if ($('#f3w4').is(":checked")) {//سه شنبه + $('#seshanbehw4').addClass("btn-active"); + } else { + $('#seshanbehw4').removeClass("btn-active"); + $('#seshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#seshanbehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f4w4').is(":checked")) {//چهارشنبه + $('#cheharshanbehw4').addClass("btn-active"); + } else { + $('#cheharshanbehw4').removeClass("btn-active"); + $('#cheharshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#cheharshanbehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f5w4').is(":checked")) {//پنجشنبه + $('#panjshanbehw4').addClass("btn-active"); + + } else { + + $('#panjshanbehw4').removeClass("btn-active"); + $('#panjshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#panjshanbehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + if ($('#f6w4').is(":checked")) {//جمعه + $('#jomehw4').addClass("btn-active"); + } else { + $('#jomehw4').removeClass("btn-active"); + $('#jomehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + + } + } + + + } + + /////////////////// OnClick yelow-textts /////////// + ////رویداد کلیک بر روی شیفت ها ////// + $('#RadioSh1').on('click', function () { + $('#Sh1').addClass("shiftActive"); + $('#Sh2').removeClass("shiftActive"); + $('#Sh4').removeClass("shiftActive"); + $('#Sh5').removeClass("shiftActive"); + $('#Sh6').removeClass("shiftActive"); + $('#Sh7').removeClass("shiftActive"); + $('#Sh8').removeClass("shiftActive"); + + $('#NormalShift').addClass("shiftCateoryActive"); + $('#RotatingShift').removeClass("shiftCateoryActive"); + $('#ComplexShift').removeClass("shiftCateoryActive"); + + $('#OneAndTowFildset').removeClass("shiftDisplayNone"); + $('#ComplexFildset').addClass("shiftDisplayNone"); + $('#WeeklyFildset').addClass("shiftDisplayNone"); + towDeactive(); + restActive(); + $('#shiftWork').val("1"); + $('#f6').prop('checked', false); + $('#jomehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + $('#jomeh').removeClass('btn-active'); + $('.time').val(""); + restReset(); + $('#f').prop("checked", true); + $('#f1').prop("checked", true); + $('#f2').prop("checked", true); + $('#f3').prop("checked", true); + $('#f4').prop("checked", true); + $('#f5').prop("checked", true); + $('#f6').prop("checked", false); + if (!$('#shanbeh').hasClass('btn-active')) { + $('#shanbeh').addClass('btn-active'); + }; + if (!$('#yekshanbeh').hasClass('btn-active')) { + $('#yekshanbeh').addClass('btn-active'); + }; + if (!$('#doshanbeh').hasClass('btn-active')) { + $('#doshanbeh').addClass('btn-active'); + }; + if (!$('#seshanbeh').hasClass('btn-active')) { + $('#seshanbeh').addClass('btn-active'); + }; + if (!$('#cheharshanbeh').hasClass('btn-active')) { + $('#cheharshanbeh').addClass('btn-active'); + }; + if (!$('#panjshanbeh').hasClass('btn-active')) { + $('#panjshanbeh').addClass('btn-active'); + }; + }); + $('#RadioSh2').on('click', function () { + $('#Sh1').removeClass("shiftActive"); + $('#Sh2').addClass("shiftActive"); + $('#Sh4').removeClass("shiftActive"); + $('#Sh5').removeClass("shiftActive"); + $('#Sh6').removeClass("shiftActive"); + $('#Sh7').removeClass("shiftActive"); + $('#Sh8').removeClass("shiftActive"); + + + $('#NormalShift').addClass("shiftCateoryActive"); + $('#RotatingShift').removeClass("shiftCateoryActive"); + $('#ComplexShift').removeClass("shiftCateoryActive"); + + $('#OneAndTowFildset').removeClass("shiftDisplayNone"); + $('#ComplexFildset').addClass("shiftDisplayNone"); + $('#WeeklyFildset').addClass("shiftDisplayNone"); + + towActive(); + restDeactive(); + $('#shiftWork').val("2"); + $('#jomehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + $('#jomeh').removeClass('btn-active'); + $('.time').val(""); + $('#f').prop("checked", true); + $('#f1').prop("checked", true); + $('#f2').prop("checked", true); + $('#f3').prop("checked", true); + $('#f4').prop("checked", true); + $('#f5').prop("checked", true); + $('#f6').prop("checked", false); + if (!$('#shanbeh').hasClass('btn-active')) { + $('#shanbeh').addClass('btn-active'); + }; + if (!$('#yekshanbeh').hasClass('btn-active')) { + $('#yekshanbeh').addClass('btn-active'); + }; + if (!$('#doshanbeh').hasClass('btn-active')) { + $('#doshanbeh').addClass('btn-active'); + }; + if (!$('#seshanbeh').hasClass('btn-active')) { + $('#seshanbeh').addClass('btn-active'); + }; + if (!$('#cheharshanbeh').hasClass('btn-active')) { + $('#cheharshanbeh').addClass('btn-active'); + }; + if (!$('#panjshanbeh').hasClass('btn-active')) { + $('#panjshanbeh').addClass('btn-active'); + }; + + }); + + $('#RadioSh4').on('click', function () { + $('#Sh1').removeClass("shiftActive"); + $('#Sh2').removeClass("shiftActive"); + $('#Sh4').addClass("shiftActive"); + $('#Sh5').removeClass("shiftActive"); + $('#Sh6').removeClass("shiftActive"); + $('#Sh7').removeClass("shiftActive"); + $('#Sh8').removeClass("shiftActive"); + + + $('#NormalShift').removeClass("shiftCateoryActive"); + $('#RotatingShift').addClass("shiftCateoryActive"); + $('#ComplexShift').removeClass("shiftCateoryActive"); + + $('#OneAndTowFildset').addClass("shiftDisplayNone"); + $('#ComplexFildset').addClass("shiftDisplayNone"); + $('#WeeklyFildset').removeClass("shiftDisplayNone"); + $('#shiftWork').val("4"); + towActive(); + $('#jomehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#jomehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#jomehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#jomehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + }); + $('#jomehRow3w1 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + $('#jomehRow3w2 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + $('#jomehRow3w3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + $('#jomehRow3w4 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + weeklyBtnDefault(); + $('.dayNumber').addClass("btn-active"); + restActive(); + restReset(); + $('#fw1').prop("checked", true); + $('#f1w1').prop("checked", true); + $('#f2w1').prop("checked", true); + $('#f3w1').prop("checked", true); + $('#f4w1').prop("checked", true); + $('#f5w1').prop("checked", true); + $('#f6w1').prop("checked", false); + $('#fw2').prop("checked", true); + $('#f1w2').prop("checked", true); + $('#f2w2').prop("checked", true); + $('#f3w2').prop("checked", true); + $('#f4w2').prop("checked", true); + $('#f5w2').prop("checked", true); + $('#f6w2').prop("checked", false); + $('#fw3').prop("checked", true); + $('#f1w3').prop("checked", true); + $('#f2w3').prop("checked", true); + $('#f3w3').prop("checked", true); + $('#f4w3').prop("checked", true); + $('#f5w3').prop("checked", true); + $('#f6w3').prop("checked", false); + $('#fw4').prop("checked", true); + $('#f1w4').prop("checked", true); + $('#f2w4').prop("checked", true); + $('#f3w4').prop("checked", true); + $('#f4w4').prop("checked", true); + $('#f5w4').prop("checked", true); + $('#f6w4').prop("checked", false); + oneActive(); + }); + $('#RadioSh5').on('click', function () { + $('#Sh1').removeClass("shiftActive"); + $('#Sh2').removeClass("shiftActive"); + $('#Sh4').removeClass("shiftActive"); + $('#Sh5').addClass("shiftActive"); + $('#Sh6').removeClass("shiftActive"); + $('#Sh7').removeClass("shiftActive"); + $('#Sh8').removeClass("shiftActive"); + + + $('#NormalShift').removeClass("shiftCateoryActive"); + $('#RotatingShift').removeClass("shiftCateoryActive"); + $('#ComplexShift').addClass("shiftCateoryActive"); + + $('#OneAndTowFildset').addClass("shiftDisplayNone"); + $('#ComplexFildset').removeClass("shiftDisplayNone"); + $('#WeeklyFildset').addClass("shiftDisplayNone"); + + $('#shiftWork').val("5"); + + }); + $('#RadioSh6').on('click', function () { + $('#Sh1').removeClass("shiftActive"); + $('#Sh2').removeClass("shiftActive"); + $('#Sh4').removeClass("shiftActive"); + $('#Sh5').removeClass("shiftActive"); + $('#Sh6').addClass("shiftActive"); + $('#Sh7').removeClass("shiftActive"); + $('#Sh8').removeClass("shiftActive"); + + + $('#NormalShift').removeClass("shiftCateoryActive"); + $('#RotatingShift').removeClass("shiftCateoryActive"); + $('#ComplexShift').addClass("shiftCateoryActive"); + + $('#OneAndTowFildset').addClass("shiftDisplayNone"); + $('#ComplexFildset').removeClass("shiftDisplayNone"); + $('#shiftWork').val("6"); + }); + $('#RadioSh7').on('click', function () { + $('#Sh1').removeClass("shiftActive"); + $('#Sh2').removeClass("shiftActive"); + $('#Sh4').removeClass("shiftActive"); + $('#Sh5').removeClass("shiftActive"); + $('#Sh6').removeClass("shiftActive"); + $('#Sh7').addClass("shiftActive"); + $('#Sh8').removeClass("shiftActive"); + + + $('#NormalShift').removeClass("shiftCateoryActive"); + $('#RotatingShift').removeClass("shiftCateoryActive"); + $('#ComplexShift').addClass("shiftCateoryActive"); + + $('#OneAndTowFildset').addClass("shiftDisplayNone"); + $('#ComplexFildset').removeClass("shiftDisplayNone"); + $('#WeeklyFildset').addClass("shiftDisplayNone"); + $('#shiftWork').val("7"); + }); + $('#RadioSh8').on('click', function () { + $('#Sh1').removeClass("shiftActive"); + $('#Sh2').removeClass("shiftActive"); + $('#Sh4').removeClass("shiftActive"); + $('#Sh5').removeClass("shiftActive"); + $('#Sh6').removeClass("shiftActive"); + $('#Sh7').removeClass("shiftActive"); + $('#Sh8').addClass("shiftActive"); + + + $('#NormalShift').removeClass("shiftCateoryActive"); + $('#RotatingShift').removeClass("shiftCateoryActive"); + $('#ComplexShift').addClass("shiftCateoryActive"); + + $('#OneAndTowFildset').addClass("shiftDisplayNone"); + $('#ComplexFildset').removeClass("shiftDisplayNone"); + $('#WeeklyFildset').addClass("shiftDisplayNone"); + $('#shiftWork').val("8"); + }); + //////////day btn Click yelow-textts////////////// + // رویداد کلیک بر روی روزها + $('#f').on('change', function () { + let shift = $('#shiftWork').val(); + if ($(this).is(":checked")) {//شنبه + $('#shanbeh').addClass("btn-active"); + if (shift === "1") { + + $('#shanbehRow1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + $('#shanbehRow3 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + }else if (shift === "2") { + $('#shanbehRow3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + $('#shanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + } else { + $('#shanbeh').removeClass("btn-active"); + $('#shanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#shanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + }); + + + $('#f1').on('change', function () { + let shift = $('#shiftWork').val(); + if ($(this).is(":checked")) {//یکشنبه + $('#yekshanbeh').addClass("btn-active"); + if (shift === "1") { + + $('#yekshanbehRow1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + $('#yekshanbehRow3 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + }else if (shift === "2") { + $('#yekshanbehRow3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + $('#yekshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + } else { + $('#yekshanbeh').removeClass("btn-active"); + $('#yekshanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#yekshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + }); + + $('#f2').on('change', function () { + let shift = $('#shiftWork').val(); + if ($(this).is(":checked")) {//یکشنبه + $('#doshanbeh').addClass("btn-active"); + if (shift === "1") { + + $('#doshanbehRow1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + $('#doshanbehRow3 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + }else if (shift === "2") { + $('#doshanbehRow3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + $('#doshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + } else { + $('#doshanbeh').removeClass("btn-active"); + $('#doshanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#doshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + }); + + $('#f3').on('change', function () { + let shift = $('#shiftWork').val(); + if ($(this).is(":checked")) {//یکشنبه + $('#seshanbeh').addClass("btn-active"); + if (shift === "1") { + + $('#seshanbehRow1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + $('#seshanbehRow3 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + }else if (shift === "2") { + $('#seshanbehRow3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + $('#seshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + } else { + $('#seshanbeh').removeClass("btn-active"); + $('#seshanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#seshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f4').on('change', function () { + let shift = $('#shiftWork').val(); + if ($(this).is(":checked")) {//یکشنبه + $('#cheharshanbeh').addClass("btn-active"); + if (shift === "1") { + + $('#cheharshanbehRow1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + $('#cheharshanbehRow3 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + }else if (shift === "2") { + $('#cheharshanbehRow3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + $('#cheharshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + } else { + $('#cheharshanbeh').removeClass("btn-active"); + $('#cheharshanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#cheharshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f5').on('change', function () { + let shift = $('#shiftWork').val(); + if ($(this).is(":checked")) {//یکشنبه + $('#panjshanbeh').addClass("btn-active"); + if (shift === "1") { + + $('#panjshanbehRow1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + $('#panjshanbehRow3 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + }else if (shift === "2") { + $('#panjshanbehRow3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + $(this).val(""); + }); + $('#panjshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + } else { + $('#panjshanbeh').removeClass("btn-active"); + $('#panjshanbehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#panjshanbehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f6').on('change', function () { + let shift = $('#shiftWork').val(); + if ($(this).is(":checked")) {//یکشنبه + $('#jomeh').addClass("btn-active"); + if (shift === "1") { + + $('#jomehRow1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + $('#jomehRow3 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + }else if (shift === "2") { + $('#jomehRow3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + $('#jomehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + } else { + $('#jomeh').removeClass("btn-active"); + $('#jomehRow3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3 .rest').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + }); + } + }); + + // کلیک بر روی روز های چهار هفته ای + //week 1 + $('#fw1').on('change', function () { + + if ($(this).is(":checked")) { + $('#shanbehw1').addClass("btn-active"); + + $('#shanbehRow3w1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + } else { + $('#shanbehw1').removeClass("btn-active"); + $('#shanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#shanbehRow3w1 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f1w1').on('change', function () { + + if ($(this).is(":checked")) { + $('#yekshanbehw1').addClass("btn-active"); + + $('#yekshanbehRow3w1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + } else { + $('#yekshanbehw1').removeClass("btn-active"); + $('#yekshanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#yekshanbehRow3w1 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f2w1').on('change', function () { + + if ($(this).is(":checked")) { + $('#doshanbehw1').addClass("btn-active"); + + $('#doshanbehRow3w1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#doshanbehw1').removeClass("btn-active"); + $('#doshanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#doshanbehRow3w1 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f3w1').on('change', function () { + + if ($(this).is(":checked")) { + $('#seshanbehw1').addClass("btn-active"); + + $('#seshanbehRow3w1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#seshanbehw1').removeClass("btn-active"); + $('#seshanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#seshanbehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f4w1').on('change', function () { + + if ($(this).is(":checked")) { + $('#cheharshanbehw1').addClass("btn-active"); + + $('#cheharshanbehRow3w1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#cheharshanbehw1').removeClass("btn-active"); + $('#cheharshanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#cheharshanbehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f5w1').on('change', function () { + + if ($(this).is(":checked")) { + $('#panjshanbehw1').addClass("btn-active"); + + $('#panjshanbehRow3w1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + $(this).val(""); + }); + + } else { + $('#panjshanbehw1').removeClass("btn-active"); + $('#panjshanbehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#panjshanbehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f6w1').on('change', function () { + + if ($(this).is(":checked")) { + $('#jomehw1').addClass("btn-active"); + + $('#jomehRow3w1 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + $('#jomehRow3w1 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#jomehw1').removeClass("btn-active"); + $('#jomehRow3w1 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w1 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + + ////week 2 + $('#fw2').on('change', function () { + + if ($(this).is(":checked")) { + $('#shanbehw2').addClass("btn-active"); + + $('#shanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#shanbehw2').removeClass("btn-active"); + $('#shanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#shanbehRow3w2 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f1w2').on('change', function () { + + if ($(this).is(":checked")) { + $('#yekshanbehw2').addClass("btn-active"); + + $('#yekshanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + } else { + $('#yekshanbehw2').removeClass("btn-active"); + $('#yekshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#yekshanbehRow3w2 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f2w2').on('change', function () { + + if ($(this).is(":checked")) { + $('#doshanbehw2').addClass("btn-active"); + + $('#doshanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#doshanbehw2').removeClass("btn-active"); + $('#doshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#doshanbehRow3w2 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f3w2').on('change', function () { + + if ($(this).is(":checked")) { + $('#seshanbehw2').addClass("btn-active"); + + $('#seshanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#seshanbehw2').removeClass("btn-active"); + $('#seshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#seshanbehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f4w2').on('change', function () { + + if ($(this).is(":checked")) { + $('#cheharshanbehw2').addClass("btn-active"); + + $('#cheharshanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#cheharshanbehw2').removeClass("btn-active"); + $('#cheharshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#cheharshanbehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f5w2').on('change', function () { + + if ($(this).is(":checked")) { + $('#panjshanbehw2').addClass("btn-active"); + + $('#panjshanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + $(this).val(""); + }); + + } else { + $('#panjshanbehw2').removeClass("btn-active"); + $('#panjshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#panjshanbehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f6w2').on('change', function () { + + if ($(this).is(":checked")) { + $('#jomehw2').addClass("btn-active"); + + $('#jomehRow3w2 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + $('#jomehRow3w2 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#jomehw2').removeClass("btn-active"); + $('#jomehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w2 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + + ////week 3 + $('#fw3').on('change', function () { + + if ($(this).is(":checked")) { + $('#shanbehw3').addClass("btn-active"); + + $('#shanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + } else { + $('#shanbehw3').removeClass("btn-active"); + $('#shanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#shanbehRow3w3 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f1w3').on('change', function () { + + if ($(this).is(":checked")) { + $('#yekshanbehw3').addClass("btn-active"); + + $('#yekshanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + } else { + $('#yekshanbehw3').removeClass("btn-active"); + $('#yekshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#yekshanbehRow3w3 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f2w3').on('change', function () { + + if ($(this).is(":checked")) { + $('#doshanbehw3').addClass("btn-active"); + + $('#doshanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#doshanbehw3').removeClass("btn-active"); + $('#doshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#doshanbehRow3w3 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f3w3').on('change', function () { + + if ($(this).is(":checked")) { + $('#seshanbehw3').addClass("btn-active"); + + $('#seshanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#seshanbehw3').removeClass("btn-active"); + $('#seshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#seshanbehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f4w3').on('change', function () { + + if ($(this).is(":checked")) { + $('#cheharshanbehw3').addClass("btn-active"); + + $('#cheharshanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#cheharshanbehw3').removeClass("btn-active"); + $('#cheharshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#cheharshanbehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f5w3').on('change', function () { + + if ($(this).is(":checked")) { + $('#panjshanbehw3').addClass("btn-active"); + + $('#panjshanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + $(this).val(""); + }); + + } else { + $('#panjshanbehw3').removeClass("btn-active"); + $('#panjshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#panjshanbehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f6w3').on('change', function () { + + if ($(this).is(":checked")) { + $('#jomehw3').addClass("btn-active"); + + $('#jomehRow3w3 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + $('#jomehRow3w3 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#jomehw3').removeClass("btn-active"); + $('#jomehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w3 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + + ////week 4 + $('#fw4').on('change', function () { + + if ($(this).is(":checked")) { + $('#shanbehw4').addClass("btn-active"); + + $('#shanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + } else { + $('#shanbehw4').removeClass("btn-active"); + $('#shanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#shanbehRow3w4 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f1w4').on('change', function () { + + if ($(this).is(":checked")) { + $('#yekshanbehw4').addClass("btn-active"); + + $('#yekshanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + } else { + $('#yekshanbehw4').removeClass("btn-active"); + $('#yekshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#yekshanbehRow3w4 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f2w4').on('change', function () { + + if ($(this).is(":checked")) { + $('#doshanbehw4').addClass("btn-active"); + + $('#doshanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#doshanbehw4').removeClass("btn-active"); + $('#doshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#doshanbehRow3w4 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f3w4').on('change', function () { + + if ($(this).is(":checked")) { + $('#seshanbehw4').addClass("btn-active"); + + $('#seshanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#seshanbehw4').removeClass("btn-active"); + $('#seshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#seshanbehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f4w4').on('change', function () { + + if ($(this).is(":checked")) { + $('#cheharshanbehw4').addClass("btn-active"); + + $('#cheharshanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + }); + + } else { + $('#cheharshanbehw4').removeClass("btn-active"); + $('#cheharshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#cheharshanbehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f5w4').on('change', function () { + + if ($(this).is(":checked")) { + $('#panjshanbehw4').addClass("btn-active"); + + $('#panjshanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + $(this).val(""); + }); + + } else { + $('#panjshanbehw4').removeClass("btn-active"); + $('#panjshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#panjshanbehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + $('#f6w4').on('change', function () { + + if ($(this).is(":checked")) { + $('#jomehw4').addClass("btn-active"); + + $('#jomehRow3w4 input').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + $('#jomehRow3w4 .rest').each(function() { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#jomehw4').removeClass("btn-active"); + $('#jomehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w4 .rest').each(function() { + $(this).prop('selectedIndex', 0); + }); + } + }); + ////////////////////Copy and valid Check time inputs///////////////////// + + var timeValid = true; + + //اینپوت ساعت شروع شیفت یک + $('#SingleShift1').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1').is(":checked")) { + $("#SingleShift1Yekshanbeh").val(timeInput); + } + if ($('#f2').is(":checked")) { + $("#SingleShift1Doshanbeh").val(timeInput); + } + if ($('#f3').is(":checked")) { + $("#SingleShift1Seshanbeh").val(timeInput); + } + if ($('#f4').is(":checked")) { + $("#SingleShift1Cheharshanbeh").val(timeInput); + } + if ($('#f5').is(":checked")) { + $("#SingleShift1Panjshanbeh").val(timeInput); + } + if ($('#f6').is(":checked")) { + $("#SingleShift1Jomeh").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت پایان شیفت یک + $('#SingleShift2').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput == "") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + timeValid = true; + if ($('#f1').is(":checked")) { + $("#SingleShift2Yekshanbeh").val(timeInput); + } + if ($('#f2').is(":checked")) { + $("#SingleShift2Doshanbeh").val(timeInput); + } + if ($('#f3').is(":checked")) { + $("#SingleShift2Seshanbeh").val(timeInput); + } + if ($('#f4').is(":checked")) { + $("#SingleShift2Cheharshanbeh").val(timeInput); + } + if ($('#f5').is(":checked")) { + $("#SingleShift2Panjshanbeh").val(timeInput); + } + if ($('#f6').is(":checked")) { + $("#SingleShift2Jomeh").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت شروع شیفت دو + $('#TowShifts1').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput == "") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + timeValid = true; + if ($('#f1').is(":checked")) { + $("#TowShifts1Yekshanbeh").val(timeInput); + } + if ($('#f2').is(":checked")) { + $("#TowShifts1Doshanbeh").val(timeInput); + } + if ($('#f3').is(":checked")) { + $("#TowShifts1Seshanbeh").val(timeInput); + } + if ($('#f4').is(":checked")) { + $("#TowShifts1Cheharshanbeh").val(timeInput); + } + if ($('#f5').is(":checked")) { + $("#TowShifts1Panjshanbeh").val(timeInput); + } + if ($('#f6').is(":checked")) { + $("#TowShifts1Jomeh").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت پایان شیفت دو + $('#TowShifts2').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput == "") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + timeValid = true; + if ($('#f1').is(":checked")) { + $("#TowShifts2Yekshanbeh").val(timeInput); + } + if ($('#f2').is(":checked")) { + $("#TowShifts2Doshanbeh").val(timeInput); + } + if ($('#f3').is(":checked")) { + $("#TowShifts2Seshanbeh").val(timeInput); + } + if ($('#f4').is(":checked")) { + $("#TowShifts2Cheharshanbeh").val(timeInput); + } + if ($('#f5').is(":checked")) { + $("#TowShifts2Panjshanbeh").val(timeInput); + } + if ($('#f6').is(":checked")) { + $("#TowShifts2Jomeh").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + ///// copy and ValidCheck Weekly time input////////////////// + //هفته اول + //اینپوت ساعت شروع شیفت یک week1 + $('#SingleShift1w1').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w1').is(":checked")) { + $("#SingleShift1Yekshanbehw1").val(timeInput); + } + if ($('#f2w1').is(":checked")) { + $("#SingleShift1Doshanbehw1").val(timeInput); + } + if ($('#f3w1').is(":checked")) { + $("#SingleShift1Seshanbehw1").val(timeInput); + } + if ($('#f4w1').is(":checked")) { + $("#SingleShift1Cheharshanbehw1").val(timeInput); + } + if ($('#f5w1').is(":checked")) { + $("#SingleShift1Panjshanbehw1").val(timeInput); + } + if ($('#f6w1').is(":checked")) { + $("#SingleShift1Jomehw1").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت پایان شیفت یک week1 + $('#SingleShift2w1').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w1').is(":checked")) { + $("#SingleShift2Yekshanbehw1").val(timeInput); + } + if ($('#f2w1').is(":checked")) { + $("#SingleShift2Doshanbehw1").val(timeInput); + } + if ($('#f3w1').is(":checked")) { + $("#SingleShift2Seshanbehw1").val(timeInput); + } + if ($('#f4w1').is(":checked")) { + $("#SingleShift2Cheharshanbehw1").val(timeInput); + } + if ($('#f5w1').is(":checked")) { + $("#SingleShift2Panjshanbehw1").val(timeInput); + } + if ($('#f6w1').is(":checked")) { + $("#SingleShift2Jomehw1").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت شروع شیفت دو week1 + $('#TowShifts1w1').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w1').is(":checked")) { + $("#TowShifts1Yekshanbehw1").val(timeInput); + } + if ($('#f2w1').is(":checked")) { + $("#TowShifts1Doshanbehw1").val(timeInput); + } + if ($('#f3w1').is(":checked")) { + $("#TowShifts1Seshanbehw1").val(timeInput); + } + if ($('#f4w1').is(":checked")) { + $("#TowShifts1Cheharshanbehw1").val(timeInput); + } + if ($('#f5w1').is(":checked")) { + $("#TowShifts1Panjshanbehw1").val(timeInput); + } + if ($('#f6w1').is(":checked")) { + $("#TowShifts1Jomehw1").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت پایان شیفت دو week1 + $('#TowShifts2w1').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w1').is(":checked")) { + $("#TowShifts2Yekshanbehw1").val(timeInput); + } + if ($('#f2w1').is(":checked")) { + $("#TowShifts2Doshanbehw1").val(timeInput); + } + if ($('#f3w1').is(":checked")) { + $("#TowShifts2Seshanbehw1").val(timeInput); + } + if ($('#f4w1').is(":checked")) { + $("#TowShifts2Cheharshanbehw1").val(timeInput); + } + if ($('#f5w1').is(":checked")) { + $("#TowShifts2Panjshanbehw1").val(timeInput); + } + if ($('#f6w1').is(":checked")) { + $("#TowShifts2Jomehw1").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + + //هفته دوم + //اینپوت ساعت شروع شیفت یک week2 + $('#SingleShift1w2').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w2').is(":checked")) { + $("#SingleShift1Yekshanbehw2").val(timeInput); + } + if ($('#f2w2').is(":checked")) { + $("#SingleShift1Doshanbehw2").val(timeInput); + } + if ($('#f3w2').is(":checked")) { + $("#SingleShift1Seshanbehw2").val(timeInput); + } + if ($('#f4w2').is(":checked")) { + $("#SingleShift1Cheharshanbehw2").val(timeInput); + } + if ($('#f5w2').is(":checked")) { + $("#SingleShift1Panjshanbehw2").val(timeInput); + } + if ($('#f6w2').is(":checked")) { + $("#SingleShift1Jomehw2").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت پایان شیفت یک week2 + $('#SingleShift2w2').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w2').is(":checked")) { + $("#SingleShift2Yekshanbehw2").val(timeInput); + } + if ($('#f2w2').is(":checked")) { + $("#SingleShift2Doshanbehw2").val(timeInput); + } + if ($('#f3w2').is(":checked")) { + $("#SingleShift2Seshanbehw2").val(timeInput); + } + if ($('#f4w2').is(":checked")) { + $("#SingleShift2Cheharshanbehw2").val(timeInput); + } + if ($('#f5w2').is(":checked")) { + $("#SingleShift2Panjshanbehw2").val(timeInput); + } + if ($('#f6w2').is(":checked")) { + $("#SingleShift2Jomehw2").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت شروع شیفت دو week2 + $('#TowShifts1w2').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w2').is(":checked")) { + $("#TowShifts1Yekshanbehw2").val(timeInput); + } + if ($('#f2w2').is(":checked")) { + $("#TowShifts1Doshanbehw2").val(timeInput); + } + if ($('#f3w2').is(":checked")) { + $("#TowShifts1Seshanbehw2").val(timeInput); + } + if ($('#f4w2').is(":checked")) { + $("#TowShifts1Cheharshanbehw2").val(timeInput); + } + if ($('#f5w2').is(":checked")) { + $("#TowShifts1Panjshanbehw2").val(timeInput); + } + if ($('#f6w2').is(":checked")) { + $("#TowShifts1Jomehw2").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت پایان شیفت دو week2 + $('#TowShifts2w2').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w2').is(":checked")) { + $("#TowShifts2Yekshanbehw2").val(timeInput); + } + if ($('#f2w2').is(":checked")) { + $("#TowShifts2Doshanbehw2").val(timeInput); + } + if ($('#f3w2').is(":checked")) { + $("#TowShifts2Seshanbehw2").val(timeInput); + } + if ($('#f4w2').is(":checked")) { + $("#TowShifts2Cheharshanbehw2").val(timeInput); + } + if ($('#f5w2').is(":checked")) { + $("#TowShifts2Panjshanbehw2").val(timeInput); + } + if ($('#f6w2').is(":checked")) { + $("#TowShifts2Jomehw2").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + + //هفته سوم + $('#TowShifts2w3').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w3').is(":checked")) { + $("#TowShifts2Yekshanbehw3").val(timeInput); + } + if ($('#f2w3').is(":checked")) { + $("#TowShifts2Doshanbehw3").val(timeInput); + } + if ($('#f3w3').is(":checked")) { + $("#TowShifts2Seshanbehw3").val(timeInput); + } + if ($('#f4w3').is(":checked")) { + $("#TowShifts2Cheharshanbehw3").val(timeInput); + } + if ($('#f5w3').is(":checked")) { + $("#TowShifts2Panjshanbehw3").val(timeInput); + } + if ($('#f6w3').is(":checked")) { + $("#TowShifts2Jomehw3").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + + //هفته دوم + //اینپوت ساعت شروع شیفت یک week3 + $('#SingleShift1w3').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w3').is(":checked")) { + $("#SingleShift1Yekshanbehw3").val(timeInput); + } + if ($('#f2w3').is(":checked")) { + $("#SingleShift1Doshanbehw3").val(timeInput); + } + if ($('#f3w3').is(":checked")) { + $("#SingleShift1Seshanbehw3").val(timeInput); + } + if ($('#f4w3').is(":checked")) { + $("#SingleShift1Cheharshanbehw3").val(timeInput); + } + if ($('#f5w3').is(":checked")) { + $("#SingleShift1Panjshanbehw3").val(timeInput); + } + if ($('#f6w3').is(":checked")) { + $("#SingleShift1Jomehw3").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت پایان شیفت یک week3 + $('#SingleShift2w3').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w3').is(":checked")) { + $("#SingleShift2Yekshanbehw3").val(timeInput); + } + if ($('#f2w3').is(":checked")) { + $("#SingleShift2Doshanbehw3").val(timeInput); + } + if ($('#f3w3').is(":checked")) { + $("#SingleShift2Seshanbehw3").val(timeInput); + } + if ($('#f4w3').is(":checked")) { + $("#SingleShift2Cheharshanbehw3").val(timeInput); + } + if ($('#f5w3').is(":checked")) { + $("#SingleShift2Panjshanbehw3").val(timeInput); + } + if ($('#f6w3').is(":checked")) { + $("#SingleShift2Jomehw3").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت شروع شیفت دو week3 + $('#TowShifts1w3').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w3').is(":checked")) { + $("#TowShifts1Yekshanbehw3").val(timeInput); + } + if ($('#f2w3').is(":checked")) { + $("#TowShifts1Doshanbehw3").val(timeInput); + } + if ($('#f3w3').is(":checked")) { + $("#TowShifts1Seshanbehw3").val(timeInput); + } + if ($('#f4w3').is(":checked")) { + $("#TowShifts1Cheharshanbehw3").val(timeInput); + } + if ($('#f5w3').is(":checked")) { + $("#TowShifts1Panjshanbehw3").val(timeInput); + } + if ($('#f6w3').is(":checked")) { + $("#TowShifts1Jomehw3").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت پایان شیفت دو week3 + $('#TowShifts2w3').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w3').is(":checked")) { + $("#TowShifts2Yekshanbehw3").val(timeInput); + } + if ($('#f2w3').is(":checked")) { + $("#TowShifts2Doshanbehw3").val(timeInput); + } + if ($('#f3w3').is(":checked")) { + $("#TowShifts2Seshanbehw3").val(timeInput); + } + if ($('#f4w3').is(":checked")) { + $("#TowShifts2Cheharshanbehw3").val(timeInput); + } + if ($('#f5w3').is(":checked")) { + $("#TowShifts2Panjshanbehw3").val(timeInput); + } + if ($('#f6w3').is(":checked")) { + $("#TowShifts2Jomehw3").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + + + //هفته چهارم + //اینپوت ساعت شروع شیفت یک week4 + $('#SingleShift1w4').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w4').is(":checked")) { + $("#SingleShift1Yekshanbehw4").val(timeInput); + } + if ($('#f2w4').is(":checked")) { + $("#SingleShift1Doshanbehw4").val(timeInput); + } + if ($('#f3w4').is(":checked")) { + $("#SingleShift1Seshanbehw4").val(timeInput); + } + if ($('#f4w4').is(":checked")) { + $("#SingleShift1Cheharshanbehw4").val(timeInput); + } + if ($('#f5w4').is(":checked")) { + $("#SingleShift1Panjshanbehw4").val(timeInput); + } + if ($('#f6w4').is(":checked")) { + $("#SingleShift1Jomehw4").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت پایان شیفت یک week4 + $('#SingleShift2w4').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w4').is(":checked")) { + $("#SingleShift2Yekshanbehw4").val(timeInput); + } + if ($('#f2w4').is(":checked")) { + $("#SingleShift2Doshanbehw4").val(timeInput); + } + if ($('#f3w4').is(":checked")) { + $("#SingleShift2Seshanbehw4").val(timeInput); + } + if ($('#f4w4').is(":checked")) { + $("#SingleShift2Cheharshanbehw4").val(timeInput); + } + if ($('#f5w4').is(":checked")) { + $("#SingleShift2Panjshanbehw4").val(timeInput); + } + if ($('#f6w4').is(":checked")) { + $("#SingleShift2Jomehw4").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت شروع شیفت دو week4 + $('#TowShifts1w4').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w4').is(":checked")) { + $("#TowShifts1Yekshanbehw4").val(timeInput); + } + if ($('#f2w4').is(":checked")) { + $("#TowShifts1Doshanbehw4").val(timeInput); + } + if ($('#f3w4').is(":checked")) { + $("#TowShifts1Seshanbehw4").val(timeInput); + } + if ($('#f4w4').is(":checked")) { + $("#TowShifts1Cheharshanbehw4").val(timeInput); + } + if ($('#f5w4').is(":checked")) { + $("#TowShifts1Panjshanbehw4").val(timeInput); + } + if ($('#f6w4').is(":checked")) { + $("#TowShifts1Jomehw4").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + //اینپوت ساعت پایان شیفت دو week4 + $('#TowShifts2w4').on('change', + function() { + let timeInput = $(this).val(); + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(timeInput); + + if (isValid || timeInput =="") { + if (timeInput != "") { + $(this).css("background-color", "#a6e9a6"); + }else + { + $(this).css("background-color", "#fff"); + } + + timeValid = true; + if ($('#f1w4').is(":checked")) { + $("#TowShifts2Yekshanbehw4").val(timeInput); + } + if ($('#f2w4').is(":checked")) { + $("#TowShifts2Doshanbehw4").val(timeInput); + } + if ($('#f3w4').is(":checked")) { + $("#TowShifts2Seshanbehw4").val(timeInput); + } + if ($('#f4w4').is(":checked")) { + $("#TowShifts2Cheharshanbehw4").val(timeInput); + } + if ($('#f5w4').is(":checked")) { + $("#TowShifts2Panjshanbehw4").val(timeInput); + } + if ($('#f6w4').is(":checked")) { + $("#TowShifts2Jomehw4").val(timeInput); + } + + } else { + $(this).css("background-color", "#f94c4c"); + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + }); + ////////////////////copy Rest Times/////////RestTimeMin + $('#restTime').on('click', + function() { + let selected = $(this).prop('selectedIndex'); + if ($('#f1').is(":checked")) { + $('#RestTimeYekshanbeh').prop('selectedIndex', selected); + } + if ($('#f2').is(":checked")) { + $('#RestTimeDoshanbeh').prop('selectedIndex', selected); + } + if ($('#f3').is(":checked")) { + $('#RestTimeSeshanbeh').prop('selectedIndex', selected); + } + if ($('#f4').is(":checked")) { + $('#RestTimeCheharshanbeh').prop('selectedIndex', selected); + } + if ($('#f5').is(":checked")) { + $('#RestTimePanjshanbeh').prop('selectedIndex', selected); + } + if ($('#f6').is(":checked")) { + $('#RestTimeJomeh').prop('selectedIndex', selected); + } + }); + + $('#RestTimeMin').on('click', + function() { + let selected = $(this).prop('selectedIndex'); + if ($('#f1').is(":checked")) { + $('#RestTimeYekshanbehMin').prop('selectedIndex', selected); + } + if ($('#f2').is(":checked")) { + $('#RestTimeDoshanbehMin').prop('selectedIndex', selected); + } + if ($('#f3').is(":checked")) { + $('#RestTimeSeshanbehMin').prop('selectedIndex', selected); + } + if ($('#f4').is(":checked")) { + $('#RestTimeCheharshanbehMin').prop('selectedIndex', selected); + } + if ($('#f5').is(":checked")) { + $('#RestTimePanjshanbehMin').prop('selectedIndex', selected); + } + if ($('#f6').is(":checked")) { + $('#RestTimeJomehMin').prop('selectedIndex', selected); + } + }); + + //غیرفعال کردن شیفت دو + function towDeactive() { + $('input.tow').each(function () { + $(this).attr("disabled","disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + $(this).removeProp("style"); + + + }); + } + //فعال کردن شیفت دو + function towActive() { + $('input.tow').each(function () { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + + }); + } + function oneActive() { + $('input.one').each(function () { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + + }); + } + //غیرفعال کردن ساعت استراحت + function restDeactive() { + $('.restActive').each(function () { + $(this).attr("disabled","disabled"); + $(this).addClass("input-deactive"); + $(this).prop('selectedIndex', 0); + + + }); + } + // خالی کردن ساعت استرحت + function restReset() { + $('.restActive').each(function () { + + $(this).prop('selectedIndex', 0); + + + }); + } + //فعال کردن ساعت استراحت + function restActive() { + $('.restActive').each(function () { + $(this).removeAttr("disabled"); + $(this).removeClass("input-deactive"); + + + }); + } + function weeklyBtnDefault() { + $('#fw1').prop('checked', true); + $('#f1w1').prop('checked', true); + $('#f2w1').prop('checked', true); + $('#f3w1').prop('checked', true); + $('#f4w1').prop('checked', true); + $('#f5w1').prop('checked', true); + $('#f6w1').prop('checked', false); + + $('#fw2').prop('checked', true); + $('#f1w2').prop('checked', true); + $('#f2w2').prop('checked', true); + $('#f3w2').prop('checked', true); + $('#f4w2').prop('checked', true); + $('#f5w2').prop('checked', true); + $('#f6w2').prop('checked', false); + + $('#fw3').prop('checked', true); + $('#f1w3').prop('checked', true); + $('#f2w3').prop('checked', true); + $('#f3w3').prop('checked', true); + $('#f4w3').prop('checked', true); + $('#f5w3').prop('checked', true); + $('#f6w3').prop('checked', false); + + $('#fw4').prop('checked', true); + $('#f1w4').prop('checked', true); + $('#f2w4').prop('checked', true); + $('#f3w4').prop('checked', true); + $('#f4w4').prop('checked', true); + $('#f5w4').prop('checked', true); + $('#f6w4').prop('checked', false); + } + }; + + $(window).on("load", part3()); + + function part3() { + $('#copyToOtherWeeks').on("click", function() { + + // shanbe + if ($('#fw1').is(":checked")) { + $('#fw2').prop("checked", true); + $('#fw3').prop("checked", true); + $('#fw4').prop("checked", true); + //copy shanbe to w2 + $('#restTimew2').val($('#restTimew1').val()); + $('#RestTimeMinw2').val($('#RestTimeMinw1').val()); + $('#SingleShift1w2').val($('#SingleShift1w1').val()); + $('#SingleShift2w2').val($('#SingleShift2w1').val()); + $('#TowShifts1w2').val($('#TowShifts1w1').val()); + $('#TowShifts2w2').val($('#TowShifts2w1').val()); + $('#shanbehw2').addClass("btn-active"); + $('#shanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy shanbe to w3 + $('#restTimew3').val($('#restTimew1').val()); + $('#RestTimeMinw3').val($('#RestTimeMinw1').val()); + $('#SingleShift1w3').val($('#SingleShift1w1').val()); + $('#SingleShift2w3').val($('#SingleShift2w1').val()); + $('#TowShifts1w3').val($('#TowShifts1w1').val()); + $('#TowShifts2w3').val($('#TowShifts2w1').val()); + $('#shanbehw3').addClass("btn-active"); + $('#shanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy shanbe to w4 + $('#restTimew4').val($('#restTimew1').val()); + $('#RestTimeMinw4').val($('#RestTimeMinw1').val()); + $('#SingleShift1w4').val($('#SingleShift1w1').val()); + $('#SingleShift2w4').val($('#SingleShift2w1').val()); + $('#TowShifts1w4').val($('#TowShifts1w1').val()); + $('#TowShifts2w4').val($('#TowShifts2w1').val()); + $('#shanbehw4').addClass("btn-active"); + $('#shanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#fw2').prop("checked", false); + $('#fw3').prop("checked", false); + $('#fw4').prop("checked", false); + //copy shanbe to w2 + $('#shanbehw2').removeClass("btn-active"); + $('#shanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#shanbehRow3w2 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy shanbe to w3 + $('#shanbehw3').removeClass("btn-active"); + $('#shanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#shanbehRow3w3 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy shanbe to w4 + $('#shanbehw4').removeClass("btn-active"); + $('#shanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#shanbehRow3w4 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + + // yekshanbe + if ($('#f1w1').is(":checked")) { + $('#f1w2').prop("checked", true); + $('#f1w3').prop("checked", true); + $('#f1w4').prop("checked", true); + //copy yekshanbe to w2 + $('#RestTimeYekshanbehw2').val($('#RestTimeYekshanbehw1').val()); + $('#RestTimeYekshanbehMinw2').val($('#RestTimeYekshanbehMinw1').val()); + $('#SingleShift1Yekshanbehw2').val($('#SingleShift1Yekshanbehw1').val()); + $('#SingleShift2Yekshanbehw2').val($('#SingleShift2Yekshanbehw1').val()); + $('#TowShifts1Yekshanbehw2').val($('#TowShifts1Yekshanbehw1').val()); + $('#TowShifts2Yekshanbehw2').val($('#TowShifts2Yekshanbehw1').val()); + $('#yekshanbehw2').addClass("btn-active"); + $('#yekshanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy yekshanbe to w3 + $('#RestTimeYekshanbehw3').val($('#RestTimeYekshanbehw1').val()); + $('#RestTimeYekshanbehMinw3').val($('#RestTimeYekshanbehMinw1').val()); + $('#SingleShift1Yekshanbehw3').val($('#SingleShift1Yekshanbehw1').val()); + $('#SingleShift2Yekshanbehw3').val($('#SingleShift2Yekshanbehw1').val()); + $('#TowShifts1Yekshanbehw3').val($('#TowShifts1Yekshanbehw1').val()); + $('#TowShifts2Yekshanbehw3').val($('#TowShifts2Yekshanbehw1').val()); + $('#yekshanbehw3').addClass("btn-active"); + $('#yekshanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy yekshanbe to w4 + $('#RestTimeYekshanbehw4').val($('#RestTimeYekshanbehw1').val()); + $('#RestTimeYekshanbehMinw4').val($('#RestTimeYekshanbehMinw1').val()); + $('#SingleShift1Yekshanbehw4').val($('#SingleShift1Yekshanbehw1').val()); + $('#SingleShift2Yekshanbehw4').val($('#SingleShift2Yekshanbehw1').val()); + $('#TowShifts1Yekshanbehw4').val($('#TowShifts1Yekshanbehw1').val()); + $('#TowShifts2Yekshanbehw4').val($('#TowShifts2Yekshanbehw1').val()); + $('#yekshanbehw4').addClass("btn-active"); + $('#yekshanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#f1w2').prop("checked", false); + $('#f1w3').prop("checked", false); + $('#f1w4').prop("checked", false); + //copy yekshanbe to w2 + $('#yekshanbehw2').removeClass("btn-active"); + $('#yekshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#yekshanbehRow3w2 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy yekshanbe to w3 + $('#yekshanbehw3').removeClass("btn-active"); + $('#yekshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#yekshanbehRow3w3 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy yekshanbe to w4 + $('#yekshanbehw4').removeClass("btn-active"); + $('#yekshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#yekshanbehRow3w4 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + + + // doshanbe + if ($('#f2w1').is(":checked")) { + $('#f2w2').prop("checked", true); + $('#f2w3').prop("checked", true); + $('#f2w4').prop("checked", true); + //copy doshanbe to w2 + $('#RestTimeDoshanbehw2').val($('#RestTimeDoshanbehw1').val()); + $('#RestTimeDoshanbehMinw2').val($('#RestTimeDoshanbehMinw1').val()); + $('#SingleShift1Doshanbehw2').val($('#SingleShift1Doshanbehw1').val()); + $('#SingleShift2Doshanbehw2').val($('#SingleShift2Doshanbehw1').val()); + $('#TowShifts1Doshanbehw2').val($('#TowShifts1Doshanbehw1').val()); + $('#TowShifts2Doshanbehw2').val($('#TowShifts2Doshanbehw1').val()); + $('#doshanbehw2').addClass("btn-active"); + $('#doshanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy doshanbe to w3 + $('#RestTimeDoshanbehw3').val($('#RestTimeDoshanbehw1').val()); + $('#RestTimeDoshanbehMinw3').val($('#RestTimeDoshanbehMinw1').val()); + $('#SingleShift1Doshanbehw3').val($('#SingleShift1Doshanbehw1').val()); + $('#SingleShift2Doshanbehw3').val($('#SingleShift2Doshanbehw1').val()); + $('#TowShifts1Doshanbehw3').val($('#TowShifts1Doshanbehw1').val()); + $('#TowShifts2Doshanbehw3').val($('#TowShifts2Doshanbehw1').val()); + $('#doshanbehw3').addClass("btn-active"); + $('#doshanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy doshanbe to w4 + $('#RestTimeDoshanbehw4').val($('#RestTimeDoshanbehw1').val()); + $('#RestTimeDoshanbehMinw4').val($('#RestTimeDoshanbehMinw1').val()); + $('#SingleShift1Doshanbehw4').val($('#SingleShift1Doshanbehw1').val()); + $('#SingleShift2Doshanbehw4').val($('#SingleShift2Doshanbehw1').val()); + $('#TowShifts1Doshanbehw4').val($('#TowShifts1Doshanbehw1').val()); + $('#TowShifts2Doshanbehw4').val($('#TowShifts2Doshanbehw1').val()); + $('#doshanbehw4').addClass("btn-active"); + $('#doshanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#f2w2').prop("checked", false); + $('#f2w3').prop("checked", false); + $('#f2w4').prop("checked", false); + //copy doshanbe to w2 + $('#doshanbehw2').removeClass("btn-active"); + $('#doshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#doshanbehRow3w2 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy doshanbe to w3 + $('#doshanbehw3').removeClass("btn-active"); + $('#doshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#doshanbehRow3w3 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy doshanbe to w4 + $('#doshanbehw4').removeClass("btn-active"); + $('#doshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#doshanbehRow3w4 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + + // seshanbe + if ($('#f3w1').is(":checked")) { + $('#f3w2').prop("checked", true); + $('#f3w3').prop("checked", true); + $('#f3w4').prop("checked", true); + //copy seshanbe to w2 + $('#RestTimeSeshanbehw2').val($('#RestTimeSeshanbehw1').val()); + $('#RestTimeSeshanbehMinw2').val($('#RestTimeSeshanbehMinw1').val()); + $('#SingleShift1Seshanbehw2').val($('#SingleShift1Seshanbehw1').val()); + $('#SingleShift2Seshanbehw2').val($('#SingleShift2Seshanbehw1').val()); + $('#TowShifts1Seshanbehw2').val($('#TowShifts1Seshanbehw1').val()); + $('#TowShifts2Seshanbehw2').val($('#TowShifts2Seshanbehw1').val()); + $('#seshanbehw2').addClass("btn-active"); + $('#seshanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy seshanbe to w3 + $('#RestTimeSeshanbehw3').val($('#RestTimeSeshanbehw1').val()); + $('#RestTimeSeshanbehMinw3').val($('#RestTimeSeshanbehMinw1').val()); + $('#SingleShift1Seshanbehw3').val($('#SingleShift1Seshanbehw1').val()); + $('#SingleShift2Seshanbehw3').val($('#SingleShift2Seshanbehw1').val()); + $('#TowShifts1Seshanbehw3').val($('#TowShifts1Seshanbehw1').val()); + $('#TowShifts2Seshanbehw3').val($('#TowShifts2Seshanbehw1').val()); + $('#seshanbehw3').addClass("btn-active"); + $('#seshanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy seshanbe to w4 + $('#RestTimeSeshanbehw4').val($('#RestTimeSeshanbehw1').val()); + $('#RestTimeSeshanbehMinw4').val($('#RestTimeSeshanbehMinw1').val()); + $('#SingleShift1Seshanbehw4').val($('#SingleShift1Seshanbehw1').val()); + $('#SingleShift2Seshanbehw4').val($('#SingleShift2Seshanbehw1').val()); + $('#TowShifts1Seshanbehw4').val($('#TowShifts1Seshanbehw1').val()); + $('#TowShifts2Seshanbehw4').val($('#TowShifts2Seshanbehw1').val()); + $('#seshanbehw4').addClass("btn-active"); + $('#seshanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#f3w2').prop("checked", false); + $('#f3w3').prop("checked", false); + $('#f3w4').prop("checked", false); + //copy seshanbe to w2 + $('#seshanbehw2').removeClass("btn-active"); + $('#seshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#seshanbehRow3w2 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy seshanbe to w3 + $('#seshanbehw3').removeClass("btn-active"); + $('#seshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#seshanbehRow3w3 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy seshanbe to w4 + $('#seshanbehw4').removeClass("btn-active"); + $('#seshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#seshanbehRow3w4 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + // CheharShanbe + if ($('#f4w1').is(":checked")) { + $('#f4w2').prop("checked", true); + $('#f4w3').prop("checked", true); + $('#f4w4').prop("checked", true); + //copy CHeharshanbe to w2 + $('#RestTimeCheharshanbehw2').val($('#RestTimeCheharshanbehw1').val()); + $('#RestTimeCheharshanbehMinw2').val($('#RestTimeCheharshanbehMinw1').val()); + $('#SingleShift1Cheharshanbehw2').val($('#SingleShift1Cheharshanbehw1').val()); + $('#SingleShift2Cheharshanbehw2').val($('#SingleShift2Cheharshanbehw1').val()); + $('#TowShifts1Cheharshanbehw2').val($('#TowShifts1Cheharshanbehw1').val()); + $('#TowShifts2Cheharshanbehw2').val($('#TowShifts2Cheharshanbehw1').val()); + $('#cheharshanbehw2').addClass("btn-active"); + $('#cheharshanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy cheharshanbe to w3 + $('#RestTimeCheharshanbehw3').val($('#RestTimeCheharshanbehw1').val()); + $('#RestTimeCheharshanbehMinw3').val($('#RestTimeCheharshanbehMinw1').val()); + $('#SingleShift1Cheharshanbehw3').val($('#SingleShift1Cheharshanbehw1').val()); + $('#SingleShift2Cheharshanbehw3').val($('#SingleShift2Cheharshanbehw1').val()); + $('#TowShifts1Cheharshanbehw3').val($('#TowShifts1Cheharshanbehw1').val()); + $('#TowShifts2Cheharshanbehw3').val($('#TowShifts2Cheharshanbehw1').val()); + $('#cheharshanbehw3').addClass("btn-active"); + $('#cheharshanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy cheharshanbe to w4 + $('#RestTimeCheharshanbehw4').val($('#RestTimeCheharshanbehw1').val()); + $('#RestTimeCheharshanbehMinw4').val($('#RestTimeCheharshanbehMinw1').val()); + $('#SingleShift1Cheharshanbehw4').val($('#SingleShift1Cheharshanbehw1').val()); + $('#SingleShift2Cheharshanbehw4').val($('#SingleShift2Cheharshanbehw1').val()); + $('#TowShifts1Cheharshanbehw4').val($('#TowShifts1Cheharshanbehw1').val()); + $('#TowShifts2Cheharshanbehw4').val($('#TowShifts2Cheharshanbehw1').val()); + $('#cheharshanbehw4').addClass("btn-active"); + $('#cheharshanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#f4w2').prop("checked", false); + $('#f4w3').prop("checked", false); + $('#f4w4').prop("checked", false); + //copy cheharshanbe to w2 + $('#cheharshanbehw2').removeClass("btn-active"); + $('#cheharshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#cheharshanbehRow3w2 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy cheharshanbe to w3 + $('#cheharshanbehw3').removeClass("btn-active"); + $('#cheharshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#cheharshanbehRow3w3 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy cheharshanbe to w4 + $('#cheharshanbehw4').removeClass("btn-active"); + $('#cheharshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#cheharshanbehRow3w4 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + // PanjShanbe + if ($('#f5w1').is(":checked")) { + $('#f5w2').prop("checked", true); + $('#f5w3').prop("checked", true); + $('#f5w4').prop("checked", true); + //copy Panjshanbe to w2 + $('#RestTimePanjshanbehw2').val($('#RestTimePanjshanbehw1').val()); + $('#RestTimePanjshanbehMinw2').val($('#RestTimePanjshanbehMinw1').val()); + $('#SingleShift1Panjshanbehw2').val($('#SingleShift1Panjshanbehw1').val()); + $('#SingleShift2Panjshanbehw2').val($('#SingleShift2Panjshanbehw1').val()); + $('#TowShifts1Panjshanbehw2').val($('#TowShifts1Panjshanbehw1').val()); + $('#TowShifts2Panjshanbehw2').val($('#TowShifts2Panjshanbehw1').val()); + $('#panjshanbehw2').addClass("btn-active"); + $('#panjshanbehRow3w2 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy Panjshanbe to w3 + $('#RestTimePanjshanbehw3').val($('#RestTimePanjshanbehw1').val()); + $('#RestTimePanjshanbehMinw3').val($('#RestTimePanjshanbehMinw1').val()); + $('#SingleShift1Panjshanbehw3').val($('#SingleShift1Panjshanbehw1').val()); + $('#SingleShift2Panjshanbehw3').val($('#SingleShift2Panjshanbehw1').val()); + $('#TowShifts1Panjshanbehw3').val($('#TowShifts1Panjshanbehw1').val()); + $('#TowShifts2Panjshanbehw3').val($('#TowShifts2Panjshanbehw1').val()); + $('#panjshanbehw3').addClass("btn-active"); + $('#panjshanbehRow3w3 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy Panjshanbe to w4 + $('#RestTimePanjshanbehw4').val($('#RestTimePanjshanbehw1').val()); + $('#RestTimePanjshanbehMinw4').val($('#RestTimePanjshanbehMinw1').val()); + $('#SingleShift1Panjshanbehw4').val($('#SingleShift1Panjshanbehw1').val()); + $('#SingleShift2Panjshanbehw4').val($('#SingleShift2Panjshanbehw1').val()); + $('#TowShifts1Panjshanbehw4').val($('#TowShifts1Panjshanbehw1').val()); + $('#TowShifts2Panjshanbehw4').val($('#TowShifts2Panjshanbehw1').val()); + $('#panjshanbehw4').addClass("btn-active"); + $('#panjshanbehRow3w4 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#f5w2').prop("checked", false); + $('#f5w3').prop("checked", false); + $('#f5w4').prop("checked", false); + //copy Panjshanbeh to w2 + $('#panjshanbehw2').removeClass("btn-active"); + $('#panjshanbehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#panjshanbehRow3w2 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy panjshanbeh to w3 + $('#panjshanbehw3').removeClass("btn-active"); + $('#panjshanbehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#panjshanbehRow3w3 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy panjshanbeh to w4 + $('#panjshanbehw4').removeClass("btn-active"); + $('#panjshanbehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#panjshanbehRow3w4 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + + + // jome + if ($('#f6w1').is(":checked")) { + $('#f6w2').prop("checked", true); + $('#f6w3').prop("checked", true); + $('#f6w4').prop("checked", true); + //copy jome to w2 + $('#RestTimeJomehw2').val($('#RestTimeJomehw1').val()); + $('#RestTimeJomehMinw2').val($('#RestTimeJomehMinw1').val()); + $('#SingleShift1Jomehw2').val($('#SingleShift1Jomehw1').val()); + $('#SingleShift2Jomehw2').val($('#SingleShift2Jomehw1').val()); + $('#TowShifts1Jomehw2').val($('#TowShifts1Jomehw1').val()); + $('#TowShifts2Jomehw2').val($('#TowShifts2Jomehw1').val()); + $('#jomehw2').addClass("btn-active"); + $('#jomehRow3w2 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + $('#jomehRow3w2 .rest').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy jome to w3 + $('#RestTimeJomehw3').val($('#RestTimeJomehw1').val()); + $('#RestTimeJomehMinw3').val($('#RestTimeJomehMinw1').val()); + $('#SingleShift1Jomehw3').val($('#SingleShift1Jomehw1').val()); + $('#SingleShift2Jomehw3').val($('#SingleShift2Jomehw1').val()); + $('#TowShifts1Jomehw3').val($('#TowShifts1Jomehw1').val()); + $('#TowShifts2Jomehw3').val($('#TowShifts2Jomehw1').val()); + $('#jomehw3').addClass("btn-active"); + $('#jomehRow3w3 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + $('#jomehRow3w3 .rest').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + //copy jome to w4 + $('#RestTimeJomehw4').val($('#RestTimeJomehw1').val()); + $('#RestTimeJomehMinw4').val($('#RestTimeJomehMinw1').val()); + $('#SingleShift1Jomehw4').val($('#SingleShift1Jomehw1').val()); + $('#SingleShift2Jomehw4').val($('#SingleShift2Jomehw1').val()); + $('#TowShifts1Jomehw4').val($('#TowShifts1Jomehw1').val()); + $('#TowShifts2Jomehw4').val($('#TowShifts2Jomehw1').val()); + $('#jomehw4').addClass("btn-active"); + $('#jomehRow3w4 input').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + $('#jomehRow3w4 .rest').each(function() { + $(this).removeAttr("disabled", "disabled"); + $(this).removeClass("input-deactive"); + }); + + } else { + $('#f6w2').prop("checked", false); + $('#f6w3').prop("checked", false); + $('#f6w4').prop("checked", false); + //copy jome to w2 + $('#jomehw2').removeClass("btn-active"); + $('#jomehRow3w2 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w2 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy jome to w3 + $('#jomehw3').removeClass("btn-active"); + $('#jomehRow3w3 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w3 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + + //copy jome to w4 + $('#jomehw4').removeClass("btn-active"); + $('#jomehRow3w4 input').each(function() { + $(this).attr("disabled", "disabled"); + $(this).addClass("input-deactive"); + $(this).val(""); + }); + $('#jomehRow3w4 .rest').each(function() { + + $(this).prop('selectedIndex', 0); + }); + } + + + + }); + } + ///// کپی ساعت استراحت هفتگی//// + function CopyRestTimeHw1(inputField) {// کپی ساعت week1 + let selected = inputField.selectedIndex; + if ($('#f1w1').is(":checked")) { + $('#RestTimeYekshanbehw1').prop('selectedIndex', selected); + } + if ($('#f2w1').is(":checked")) { + $('#RestTimeDoshanbehw1').prop('selectedIndex', selected); + } + if ($('#f3w1').is(":checked")) { + $('#RestTimeSeshanbehw1').prop('selectedIndex', selected); + } + if ($('#f4w1').is(":checked")) { + $('#RestTimeCheharshanbehw1').prop('selectedIndex', selected); + } + if ($('#f5w1').is(":checked")) { + $('#RestTimePanjshanbehw1').prop('selectedIndex', selected); + } + if ($('#f6w1').is(":checked")) { + $('#RestTimeJomehw1').prop('selectedIndex', selected); + } + } + function CopyRestTimeMw1(inputField) {// کپی دقیقه week1 + let selected = inputField.selectedIndex; + if ($('#f1w1').is(":checked")) { + $('#RestTimeYekshanbehMinw1').prop('selectedIndex', selected); + } + if ($('#f2w1').is(":checked")) { + $('#RestTimeDoshanbehMinw1').prop('selectedIndex', selected); + } + if ($('#f3w1').is(":checked")) { + $('#RestTimeSeshanbehMinw1').prop('selectedIndex', selected); + } + if ($('#f4w1').is(":checked")) { + $('#RestTimeCheharshanbehMinw1').prop('selectedIndex', selected); + } + if ($('#f5w1').is(":checked")) { + $('#RestTimePanjshanbehMinw1').prop('selectedIndex', selected); + } + if ($('#f6w1').is(":checked")) { + $('#RestTimeJomehMinw1').prop('selectedIndex', selected); + } + + } + //week 2 + function CopyRestTimeHw2(inputField) {// کپی ساعت week2 + let selected = inputField.selectedIndex; + if ($('#f1w2').is(":checked")) { + $('#RestTimeYekshanbehw2').prop('selectedIndex', selected); + } + if ($('#f2w2').is(":checked")) { + $('#RestTimeDoshanbehw2').prop('selectedIndex', selected); + } + if ($('#f3w2').is(":checked")) { + $('#RestTimeSeshanbehw2').prop('selectedIndex', selected); + } + if ($('#f4w2').is(":checked")) { + $('#RestTimeCheharshanbehw2').prop('selectedIndex', selected); + } + if ($('#f5w2').is(":checked")) { + $('#RestTimePanjshanbehw2').prop('selectedIndex', selected); + } + if ($('#f6w2').is(":checked")) { + $('#RestTimeJomehw2').prop('selectedIndex', selected); + } + } + function CopyRestTimeMw2(inputField) {// کپی دقیقه week2 + let selected = inputField.selectedIndex; + if ($('#f1w2').is(":checked")) { + $('#RestTimeYekshanbehMinw2').prop('selectedIndex', selected); + } + if ($('#f2w2').is(":checked")) { + $('#RestTimeDoshanbehMinw2').prop('selectedIndex', selected); + } + if ($('#f3w1').is(":checked")) { + $('#RestTimeSeshanbehMinw2').prop('selectedIndex', selected); + } + if ($('#f4w2').is(":checked")) { + $('#RestTimeCheharshanbehMinw2').prop('selectedIndex', selected); + } + if ($('#f5w2').is(":checked")) { + $('#RestTimePanjshanbehMinw2').prop('selectedIndex', selected); + } + if ($('#f6w2').is(":checked")) { + $('#RestTimeJomehMinw2').prop('selectedIndex', selected); + } + + } + //week 3 + function CopyRestTimeHw3(inputField) {// کپی ساعت week3 + let selected = inputField.selectedIndex; + if ($('#f1w3').is(":checked")) { + $('#RestTimeYekshanbehw3').prop('selectedIndex', selected); + } + if ($('#f2w3').is(":checked")) { + $('#RestTimeDoshanbehw3').prop('selectedIndex', selected); + } + if ($('#f3w3').is(":checked")) { + $('#RestTimeSeshanbehw3').prop('selectedIndex', selected); + } + if ($('#f4w3').is(":checked")) { + $('#RestTimeCheharshanbehw3').prop('selectedIndex', selected); + } + if ($('#f5w3').is(":checked")) { + $('#RestTimePanjshanbehw3').prop('selectedIndex', selected); + } + if ($('#f6w3').is(":checked")) { + $('#RestTimeJomehw3').prop('selectedIndex', selected); + } + } + function CopyRestTimeMw3(inputField) {// کپی دقیقه week3 + let selected = inputField.selectedIndex; + if ($('#f1w3').is(":checked")) { + $('#RestTimeYekshanbehMinw3').prop('selectedIndex', selected); + } + if ($('#f2w3').is(":checked")) { + $('#RestTimeDoshanbehMinw3').prop('selectedIndex', selected); + } + if ($('#f3w1').is(":checked")) { + $('#RestTimeSeshanbehMinw3').prop('selectedIndex', selected); + } + if ($('#f4w3').is(":checked")) { + $('#RestTimeCheharshanbehMinw3').prop('selectedIndex', selected); + } + if ($('#f5w3').is(":checked")) { + $('#RestTimePanjshanbehMinw3').prop('selectedIndex', selected); + } + if ($('#f6w3').is(":checked")) { + $('#RestTimeJomehMinw3').prop('selectedIndex', selected); + } + + } + //week 4 + function CopyRestTimeHw4(inputField) {// کپی ساعت week4 + let selected = inputField.selectedIndex; + if ($('#f1w4').is(":checked")) { + $('#RestTimeYekshanbehw4').prop('selectedIndex', selected); + } + if ($('#f2w4').is(":checked")) { + $('#RestTimeDoshanbehw4').prop('selectedIndex', selected); + } + if ($('#f3w4').is(":checked")) { + $('#RestTimeSeshanbehw4').prop('selectedIndex', selected); + } + if ($('#f4w4').is(":checked")) { + $('#RestTimeCheharshanbehw4').prop('selectedIndex', selected); + } + if ($('#f5w4').is(":checked")) { + $('#RestTimePanjshanbehw4').prop('selectedIndex', selected); + } + if ($('#f6w4').is(":checked")) { + $('#RestTimeJomehw4').prop('selectedIndex', selected); + } + } + function CopyRestTimeMw4(inputField) {// کپی دقیقه week4 + let selected = inputField.selectedIndex; + if ($('#f1w4').is(":checked")) { + $('#RestTimeYekshanbehMinw4').prop('selectedIndex', selected); + } + if ($('#f2w4').is(":checked")) { + $('#RestTimeDoshanbehMinw4').prop('selectedIndex', selected); + } + if ($('#f3w1').is(":checked")) { + $('#RestTimeSeshanbehMinw4').prop('selectedIndex', selected); + } + if ($('#f4w4').is(":checked")) { + $('#RestTimeCheharshanbehMinw4').prop('selectedIndex', selected); + } + if ($('#f5w4').is(":checked")) { + $('#RestTimePanjshanbehMinw4').prop('selectedIndex', selected); + } + if ($('#f6w4').is(":checked")) { + $('#RestTimeJomehMinw4').prop('selectedIndex', selected); + } + + } + + /////////////////Time Input Validate && Complex Copy input///////////////// + function validateHM(inputField) { + /*var isValid = /^\d{1}?\d{1}:\d{1}?\d{1}$/.test(inputField.value);*/ + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(inputField.value); + let isEmpty = inputField.value; + + if (isValid || isEmpty == "") { + if (isEmpty != "") { + inputField.style.backgroundColor = '#a6e9a6'; + } else { + inputField.style.backgroundColor = '#fff'; + } + var st = inputField.value; + timeValid = true; + if (document.getElementById("shiftWork").value == "5" || document.getElementById("shiftWork").value == "7") { + let [hour, minute] = st.split(':'); + var hPlus = Number(hour); + + if (hPlus >= 0 && hPlus < 12) { + hPlus += 12; + } else { + hPlus -= 12; + } + document.getElementById("EndComplex").value = hPlus + ':' + minute; + } + if (document.getElementById("shiftWork").value == "6" || document.getElementById("shiftWork").value == "8") { + document.getElementById("EndComplex").value = st; + } + + + } else { + inputField.style.backgroundColor = '#f94c4c'; + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + + } + function validateHM2(inputField) { + /*var isValid = /^\d{1}?\d{1}:\d{1}?\d{1}$/.test(inputField.value);*/ + var isValid = /^([2][0-3]|[1][0-9]|[0-9]|[0][0-9])([:][0-5][0-9])$/.test(inputField.value); + let isEmpty = inputField.value; + + if (isValid || isEmpty == "") { + if (isEmpty != "") { + inputField.style.backgroundColor = '#a6e9a6'; + } else { + inputField.style.backgroundColor = '#fff'; + } + + + timeValid = true; + + + } else { + inputField.style.backgroundColor = '#f94c4c'; + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا ساعت را بصورت صحیح وارد کنید"); + timeValid = false; + } + return isValid; + + } + + + + + diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/ChangeCode.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/ChangeCode.cshtml index c5ffe94d..75daab98 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/ChangeCode.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/ChangeCode.cshtml @@ -1,6 +1,8 @@ -@model CompanyManagment.App.Contracts.Checkout.CreateCheckout +@using _0_Framework.Application +@model CompanyManagment.App.Contracts.Checkout.CreateCheckout @{ - } @{ - - - - - - - + + + + + + + + } \ No newline at end of file + + }, + failure: function (response) { + console.log(5, response); + + } + }); + } + + } + + + + + + + diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/ContractCheckoutStatus.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/ContractCheckoutStatus.cshtml index 7a67aa75..82592633 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/ContractCheckoutStatus.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/ContractCheckoutStatus.cshtml @@ -1,17 +1,19 @@ -@using Version = _0_Framework.Application.Version -@model CompanyManagment.App.Contracts.Workshop.ContractStatusViewModel +@model CompanyManagment.App.Contracts.Workshop.ContractStatusViewModel +@using System.Globalization +@using global::Company.Domain.EmployeeAgg +@using Version = _0_Framework.Application.Version @{ - var index = 1; + int index = 1; - - - - - - - // + + + + + + // + } @@ -340,681 +341,687 @@ \ No newline at end of file + $(document).ready(function () { + $("#divEdit #close").click(function () { + $("#divEdit").slideUp(500); + }) + handleScroll(); + $('.error-message').hide(); + $('.error-icon').hide(); + + $(".listPrev").css({ + 'background-color': "#c7c0c0ba", + 'color': '#000000b8', + 'box-shadow': 'none' + }); + + let state = document.getElementById('State').value; + let city = document.getElementById('hide2').value; + iranwebsv(state); + $(`#city option:contains("${city}")`).attr("selected", true); + }) + $("#close , .close").on('click', function () { + $(".datepicker-container").hide(); + }); + + + + + $('#fakeSave').hide(); + $('.listForm1 .input').on('keyup', function () { + const errorMessage = $(this).parent().find('.error-message'); + const errorIcon = $(this).parent().find('.error-icon'); + if (this.validity.patternMismatch) { + errorMessage.show(); + errorIcon.show(); + $(this).addClass('errored'); + $(this).addClass('patternMisMatch'); + + } else { + errorMessage.hide(); + errorIcon.hide(); + $(this).removeClass('errored'); + $(this).removeClass('patternMisMatch'); + } + }); + $('.listForm1 .items').on('keyup', function () { + const errorMessage = $(this).parent().find('.error-message'); + const errorIcon = $(this).parent().find('.error-icon'); + if (this.validity.patternMismatch) { + errorMessage.show(); + errorIcon.show(); + $(this).addClass('errored'); + $(this).addClass('patternMisMatch'); + + } else { + errorMessage.hide(); + errorIcon.hide(); + $(this).removeClass('errored'); + $(this).removeClass('patternMisMatch'); + } + }); + $(".persianDateInput").on('keyup', function () { + if (event.which !== 8 && event.which !== 46) { + let value = $(this).val(); + let lengthValue = value.length; + if (lengthValue === 4) { + value += '/' + } + if (lengthValue === 7) { + value += '/' + } + $(this).val(value); + } + }); + + $(".persianDateInput").on('blur', function () { + let value = $(this).val(); + let lengthValue = value.length; + if (!dateValidCheck(this)) { + $(this).addClass("errored"); + } + else { + $(this).removeClass("errored"); + } + }); + + + + $('.form-box input[name="Gender"]').on('change', function () { + let selectedGender = $('input[name="Gender"]:checked').val(); + if (selectedGender === 'مرد') { + $('#soldier').prop('disabled', false); + } else { + $('#soldier').prop('disabled', true); + } + }) + + $(".listNext").click(function () { + + if ($("#divGender").find('input[type="radio"]:checked').length === 0) { + // allInputsFilled = false; + $("#divGender").addClass('errored'); + } + + if ($("#divMarried").find('input[type="radio"]:checked').length === 0) { + // allInputsFilled = false; + $("#divMarried").addClass('errored'); + } + + + var option1 = document.getElementById("city").options.selectedIndex; + if (option1 == 0) { + $("#divCity .select2-selection").addClass('errored'); + } else { + $("#divCity .select2-selection").removeClass('errored'); + } + var option2 = document.getElementById("State").options.selectedIndex; + if (option2 == 0) { + $("#divState .select2-selection").addClass('errored'); + } else { + $("#divState .select2-selection").removeClass('errored'); + } + + $('.listForm1').find('.not-empty').each(function () { + if ($(this).val() === '') { + $(this).addClass('errored'); + } else { + $(this).removeClass('errored'); + } + }); + $(".persianDateInput").on('keyup', function () { + if (event.which !== 8 && event.which !== 46) { + let value = $(this).val(); + let lengthValue = value.length; + if (lengthValue === 4) { + value += '/' + } + if (lengthValue === 7) { + value += '/' + } + $(this).val(value); + } + }); + + $(".persianDateInput").on('blur', function () { + let value = $(this).val(); + let lengthValue = value.length; + if (!dateValidCheck(this)) { + $(this).addClass("errored"); + } + else { + $(this).removeClass("errored"); + } + }); + if ($('.listForm1 .errored').length > 0 || $('.listForm1 input.patternMisMAtch').length > 0 ) { + $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', "لطفا موارد اجباری را تکمیل کنید."); + + } + + else{ + if ($('.listForm2').css('left') == '0px') { + $(".listNext").css({ + 'background-color': "#c7c0c0ba", + 'color': '#000000b8', + 'box-shadow': 'none' + }) + } else if ($('.listForm2').css('left') == '3000px') { + $(".listNext").css({ + 'background-color': "#c7c0c0ba", + 'color': '#000000b8', + 'box-shadow': 'none' + }) + $(".listPrev").css({ + 'background-color': "white", + 'color': '#0f9500' + }) + $(".progressBar").css({ + 'width': '100%' + + }) + $(".listForm1").css({ + right: '3000px' + }) + $(".listForm2").css({ + left: '0' + }) + } + } + + + + + }) + + $(".listPrev").click(function () { + $(".listNext").css({ + 'background-color': "white", + 'color': '#1763b1' + }) + if ($('.listForm2').css('left') == '3000px') { + $(".listPrev").css({ + 'background-color': "#c7c0c0ba", + 'color': '#000000b8', + 'box-shadow': 'none' + }) + } else if ($('.listForm2').css('left') == '0px') { + $(".progressBar").css({ + 'width': '50%', + 'border-top-right-radius': '0px' + }) + $(".listPrev").css({ + 'background-color': "#c7c0c0ba", + 'color': '#000000b8', + 'box-shadow': 'none' + }) + $(".listForm2").css({ + left: '3000px' + }) + $(".listForm1").css({ + right: 'initial' + }) + } + }) + function handleScroll() { + let rows = $(".listForm1").find("#children-container tbody").find("tr"); + $(".listForm1").find("#children-container tbody").find("tr"); + let rowCount = rows.length; + if (rowCount > 3) { + $('#children-container').removeClass('hide-scrollbar'); + } else { + $('#children-container').addClass('hide-scrollbar'); + } + } + function updateRowNumbers() { + let tbody = $(".listForm1 #children tbody"); + let rows = tbody.find("tr"); + rows.each(function (index) { + $(this).find("td:last-child").text(index + 1); + }); + } + + + function addChildren() { + $(".listForm1").find('.childBirth').each(function () { + if ($(this).val() === '' || $(this).val().length < 10) { + $(this).addClass('errored'); + } else { + $(this).removeClass('errored'); + } + }); + $(".listForm1").find('.childName').each(function () { + if ($(this).val() === '') { + $(this).addClass('errored'); + } else { + $(this).removeClass('errored'); + } + }); + + + if ($('.listForm1 #children-container').find('input.patternMisMatch').length > 0 || $('.listForm1 #children-container').find('input.errored').length > 0 ) { + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا موارد اجباری را تکمیل کنید."); + } + else { + addRow(); + updateRowNumbers(); + handleScroll(); + } + + + } + + $(".listForm1").find(".trash-icon").on("mouseenter", function () { + $(this).animate({ left: "-10px" }, 50) + .animate({ left: "-4px" }, 50) + .animate({ left: "-7px" }, 50); + }); + $(".listForm1").find(".trash-icon").on("mouseleave", function () { + $(this).stop(true).animate({ left: "-7px" }, 50); + }); + $(".listForm1").find('.delete').click(function () { + + $(this).closest('tr').fadeOut(200, function () { + $(this).hide(); + updateRowNumbers(); + handleScroll(); + + }); + var id=$(this).attr('id').replace('delete_',''); + $(this).append(' '); + }); + + + function addRow() { + let tbody = $(".listForm1 #children tbody"); + let rowCount = tbody.find("tr").length; + + + let newRow =''; + + var a = $(".trcreate").length; + newRow = '' + + '' + + '
' + + '' + + '
' + + '
' + + '' + + '' + + '' + + '
' + + '' + + '' + + '
' + + '' + + '
' + + '' + + '' + (rowCount + 1) + '' + + ''; + + tbody.append(newRow); + var dynamicInput = $(".items.childInput.childName"); + dynamicInput.attr("pattern", "[؀-ۿ\\s]*"); + + $('.items').on('keyup', function () { + if (this.validity.patternMismatch) { + $(this).addClass('errored'); + $(this).addClass('patternMisMatch'); + + } else { + $(this).removeClass('errored'); + $(this).removeClass('patternMisMatch'); + } + }); + $(".persianDateInput").on('keyup', function () { + if (event.which !== 8 && event.which !== 46) { + let value = $(this).val(); + let lengthValue = value.length; + if (lengthValue === 4) { + value += '/' + } + if (lengthValue === 7) { + value += '/' + } + $(this).val(value); + } + }); + + $(".persianDateInput").on('blur', function () { + let value = $(this).val(); + let lengthValue = value.length; + if (!dateValidCheck(this)) { + $(this).addClass("errored"); + } + else { + $(this).removeClass("errored"); + } + }); + } + + + $('.listForm1 input[name=Gender]').on('change', function () { + $(".listForm1 #divGender").removeClass('errored'); + }); + + $('.listForm1 input[name=MaritalStatus]').on('change', function () { + $(".listForm1 #divMarried").removeClass('errored'); + }); + + $("#save").click(function () { + //var allInputsFilled = true; + $('#save').hide(); + $('#fakeSave').show(); + if ($(".listForm1 #divGender").find('input[type="radio"]:checked').length === 0) { + // allInputsFilled = false; + $(".listForm1 #divGender").addClass('errored'); + } + + if ($(".listForm1 #divMarried").find('input[type="radio"]:checked').length === 0) { + // allInputsFilled = false; + $(".listForm1 #divMarried").addClass('errored'); + } + //var option1 = document.getElementById("city").options.selectedIndex; + //if (option1 == 0) { + // $("#divCity .select2-selection").addClass('errored'); + //} else { + // $("#divCity .select2-selection").removeClass('errored'); + //} + //var option2 = document.getElementById("State").options.selectedIndex; + //if (option2 == 0) { + // $("#divState .select2-selection").addClass('errored'); + //} else { + // $("#divState .select2-selection").removeClass('errored'); + //} + + $('.listForm1').find('.not-empty').each(function () { + if ($(this).val() === '') { + // allInputsFilled = false; + $(this).addClass('errored'); + } else { + $(this).removeClass('errored'); + } + }); + $(".listForm1").find('input.persianDateInput').each(function () { + let value = $(this).val(); + let lengthValue = value.length; + if (lengthValue < 10 && lengthValue !== 0) { + $(this).addClass('errored'); + } else { + $(this).removeClass('errored'); + } + }); + if ($('.listForm1 input.errored').length > 0 || $('.listForm1 input.patternMisMAtch').length > 0) { + $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', "لطفا موارد اجباری را تکمیل کنید."); + $('#fakeSave').hide(); + $('#save').show(); + } + else { + $("#saveEmployee").submit(); + setTimeout(function () { + + $(".datepicker-container").hide(); + }, 500); + setTimeout(function () { + + $('#save').show(); + $('#fakeSave').hide(); + }, 3000); + } + }); + + $('#saveEmployee').submit(function (e) { + e.preventDefault(); + e.stopImmediatePropagation(); + $.ajax({ + type: "POST", + url: $(this).attr('action'), + data: $(this).serialize(), + success: function (response) { + if (response.isSuccedded == true) { + $.Notification.autoHideNotify('success', 'top right', response.message); + + $("#MainModal").modal('hide'); + getEmployeeList(); + } + else { + $.Notification.autoHideNotify('error', 'top right', response.message); + } + } + }); + return false; + }); + function checkEnValid(fixDate1) { + + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = fixDate1; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + for (let i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let kabiseh = false; + if (month <= 6 && day > 31) { + return false; + } + else if (month > 6 && month < 12 && day > 30) { + return false; + } else if (month === 12) { + + switch (year) { + case 1346: + kabiseh = true; + break; + case 1350: + kabiseh = true; + break; + case 1354: + kabiseh = true; + break; + case 1358: + kabiseh = true; + break; + case 1362: + kabiseh = true; + break; + case 1366: + kabiseh = true; + break; + case 1370: + kabiseh = true; + break; + case 1375: + kabiseh = true; + break; + case 1379: + kabiseh = true; + break; + case 1383: + kabiseh = true; + break; + case 1387: + kabiseh = true; + break; + case 1391: + kabiseh = true; + break; + case 1395: + kabiseh = true; + break; + case 1399: + kabiseh = true; + break; + case 1403: + kabiseh = true; + break; + case 1408: + kabiseh = true; + break; + case 1412: + kabiseh = true; + break; + case 1416: + kabiseh = true; + break; + case 1420: + kabiseh = true; + break; + case 1424: + kabiseh = true; + break; + case 1428: + kabiseh = true; + break; + case 1432: + kabiseh = true; + break; + case 1436: + kabiseh = true; + break; + case 1441: + kabiseh = true; + break; + case 1445: + kabiseh = true; + break; + default: + kabiseh = false; + + } + if (kabiseh == true && day > 30) { + return false; + } else if (kabiseh == false && day > 29) { + return false; + } else { + return true; + } + } else { + return true; + } + + } + function dateValidcheck(inputField1) { + let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g], + arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g], + fixNumbers = function (str) { + if (typeof str === 'string') { + for (var i = 0; i < 10; i++) { + str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i); + } + } + return str; + }; + let getdate = inputField1.value; + + let m1, m2; + let y1, y2, y3, y4; + let d1, d2; + let s1, s2; + for (var i = 0; i < getdate.length; i++) { + if (i === 0) { + y1 = fixNumbers(getdate[i]); + } + if (i === 1) { + y2 = fixNumbers(getdate[i]); + } + if (i === 2) { + y3 = fixNumbers(getdate[i]); + } + if (i === 3) { + y4 = fixNumbers(getdate[i]); + } + if (i === 4) { + s1 = fixNumbers(getdate[i]); + } + if (i === 5) { + m1 = fixNumbers(getdate[i]); + } + if (i === 6) { + m2 = fixNumbers(getdate[i]); + } + if (i === 7) { + s2 = fixNumbers(getdate[i]); + } + if (i === 8) { + d1 = fixNumbers(getdate[i]); + } + if (i === 9) { + d2 = fixNumbers(getdate[i]); + } + + } + let yRes = y1 + y2 + y3 + y4; + let year = parseInt(yRes); + let mRes = m1 + m2; + let month = parseInt(mRes); + let dRes = d1 + d2; + let day = parseInt(dRes); + let fixResult = yRes + s1 + mRes + s2 + dRes; + let test1 = checkEnValid(inputField1.value); + + let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult); + + + if (isValid && test1) { + //inputField1.addClass("errored"); + inputField1.style.boxShadow = 'none'; + inputField1.style.border = '1px solid #c7c7c7'; + start1valid = true; + } else { + if (inputField1.value != "") { + //inputField1.addClass("errored"); + inputField1.style.boxShadow = 'inset 0 0 2px #eb3434, 0 0 5px #eb3434'; + inputField1.style.border = '1px solid #eb3434'; + $.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید"); + start1valid = false; + } + } + return start1valid; + } + + + function changecity(element){ + var text = $(element).children("option").filter(":selected").text(); + $("#hide2").val(text); + } + diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/EditSick.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/EditSick.cshtml index c349521f..0664b0be 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/EditSick.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/EditSick.cshtml @@ -2,365 +2,365 @@ @{ } - +
- -
-
+ + + @**@ + +
+ + + + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/EmployeeList.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/EmployeeList.cshtml index bdc610ab..3a4bae75 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/EmployeeList.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/EmployeeList.cshtml @@ -2,28 +2,28 @@ @{ } - - - - - - - @**@ - - - - - - - @if (Model != null) - { - var i = 1; - @foreach (var item in Model) - { - - - - @* + + } + } + else + { + + + } + +
#نام و نام خانوادگی نام خانوادگیعملیات
@i + + + + + + + @**@ + + + + + + + @if (Model != null) + { + int i = 1; + @foreach (var item in Model) + { + + + + @* *@ - - - - @{ - i++; - } - + + + @{ + i++; + } + - - } - } - else - { - - - - } - -
#نام و نام خانوادگی نام خانوادگیعملیات
@i

@item.FName @@ -43,27 +43,27 @@

-
-

- @item.EmployeeFullName -

- - @item.EmployeeFullName - -
-
- + + - @* + + @*

@@ -138,7 +139,7 @@
*@ - @* + @*

@@ -164,154 +165,160 @@
}*@ - - -
اطلاعاتی جهت نمایش موجود نمی باشد
+ +
اطلاعاتی جهت نمایش موجود نمی باشد
+ \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/Index.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/Index.cshtml index f1a80f9d..c860a22d 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/Index.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/Index.cshtml @@ -1,21 +1,21 @@ @page @using Version = _0_Framework.Application.Version -@model IndexModel +@model ServiceHost.Areas.Client.Pages.Company.Employees.IndexModel @{ - Layout = "Shared/_ClientLayout"; - ViewData["title"] = " - عملیات مربوط به پرسنل"; - var index = 1; + Layout = "Shared/_ClientLayout"; + ViewData["title"] = " - عملیات مربوط به پرسنل"; + int index = 1; } @section Styles { - - - - - - - } @@ -2449,6 +2454,12 @@ $(".select2Option").select2({ language: "fa", dir: "rtl", + templateResult: function (data, container) { + if (data.element) { + $(container).addClass($(data.element).attr("class")); + } + return data.text; + } }); function formatSelection(val) { @@ -2457,7 +2468,13 @@ $($('#employeeSelect').val()).select2({ formatSelection: formatSelection, - width: 300 + width: 300, + templateResult: function (data, container) { + if (data.element) { + $(container).addClass($(data.element).attr("class")); + } + return data.text; + } }); $($('#employeeSelectMobile').val()).select2({ @@ -2477,7 +2494,8 @@ var employeeOptionsHtml = ``; employees.forEach(function (employee) { - employeeOptionsHtml += ``; + var black = employee.black ? "blackSelect" : ""; + employeeOptionsHtml += ``; }); $('#employeeSelect').html(employeeOptionsHtml); $('#employeeSelectMobile').html(employeeOptionsHtml); diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml.cs index 61596562..bd91b6d6 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/Leave.cshtml.cs @@ -354,18 +354,27 @@ namespace ServiceHost.Areas.Client.Pages.Company.Employees #region Load All Personal by ajax (EmployeeList) public IActionResult OnGetEmployeeList(long workshopId) { - var filteredBlackResult = _workshopApplication.GetConnectedPersonnels(workshopId) - .Where(x => !x.Black && x.ContractPerson) - .GroupBy(x => x.EmployeeId) - .Select(x => x.First()) - .OrderBy(x => x.PersonelCode) - .ToList(); + var result = _workshopApplication.GetConnectedPersonnels(workshopId); + var r = result.GroupBy(x => x.PersonName).Select(x => x.First()).ToList(); personleList = new ConnectedPersonnelViewModel() { - ConnectedPersonnelViewModels = filteredBlackResult, + ConnectedPersonnelViewModels = r.OrderBy(x => x.Black ? 1 : 0).ThenBy(x => x.PersonelCode).ToList(), }; + // لیست پرسنلی که قرارداد ندارند + //var filteredBlackResult = _workshopApplication.GetConnectedPersonnels(workshopId) + // .Where(x => !x.Black && x.ContractPerson) + // .GroupBy(x => x.EmployeeId) + // .Select(x => x.First()) + // .OrderBy(x => x.PersonelCode) + // .ToList(); + + //personleList = new ConnectedPersonnelViewModel() + //{ + // ConnectedPersonnelViewModels = filteredBlackResult, + //}; + return new JsonResult(new { personleList }); } #endregion diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/LeaveCreateModal.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/LeaveCreateModal.cshtml index f3be63eb..e100c2cb 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/LeaveCreateModal.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/LeaveCreateModal.cshtml @@ -13,6 +13,9 @@ display: none; } + .blackSelect { + background-color: #cbd5e1; + } } @@ -183,7 +186,13 @@ $(".select2Option").select2({ language: "fa", dir: "rtl", - dropdownParent: $('#MainModal') + dropdownParent: $('#MainModal'), + templateResult: function (data, container) { + if (data.element) { + $(container).addClass($(data.element).attr("class")); + } + return data.text; + } }); @@ -723,7 +732,8 @@ var employees = response.connectedPersonnel.connectedPersonnelViewModels; var employeeOptionsHtml = ''; employees.forEach(function (employee) { - employeeOptionsHtml += ''; + var black = employee.black ? "blackSelect" : ""; + employeeOptionsHtml += ``; }); $('#employeeSelect').html(employeeOptionsHtml); }, diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/LeavePrintAll.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/LeavePrintAll.cshtml index fa8c52a4..0a2d6d25 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/LeavePrintAll.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/LeavePrintAll.cshtml @@ -1,8 +1,8 @@ @page -@model LeavePrintAllModel +@model ServiceHost.Areas.Client.Pages.Company.Employees.LeavePrintAllModel @{ - - + }
- + -
-
+
+ + +
+
+
+
+

سوابق مرخصی استحقاقی

+
+
+
+
+ +
+
+
+
+
+
+ + + @**@ + + +
+
+ + + @**@ + @**@ + +
+
\ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/PaidLeaveList.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/PaidLeaveList.cshtml index e4c31a07..b8441a4c 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/PaidLeaveList.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/PaidLeaveList.cshtml @@ -1,94 +1,92 @@ @model List -@{ - var i = 1; +@{ + int i = 1; } - - - - - - - - - - - - - @foreach (var item in Model) - { - - - - - - - @{ - i++; - } - - - } - -
# تاریخ شروع تاریخ پایان نوع مدت مرخصی مدت زمان(ساعت) عملیات
@i @item.StartLeave - @item.EndLeave - - @item.PaidLeaveType - - @item.LeaveHourses - - - - - - - -
- -
-
- + + + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + @{ + i++; + } + + + } + +
# تاریخ شروع تاریخ پایان نوع مدت مرخصی مدت زمان(ساعت) عملیات
@i @item.StartLeave + @item.EndLeave + + @item.PaidLeaveType + + @item.LeaveHourses + + + + + +
+ +
+
+ \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAll.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAll.cshtml index 189bf777..a5ee9c85 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAll.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAll.cshtml @@ -1,6 +1,6 @@ @model CompanyManagment.App.Contracts.Leave.GroupLeavePrintViewModel @{ - } + + + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllDetailsPersonnelInfoMobile.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllDetailsPersonnelInfoMobile.cshtml index 8406f32b..6e7b67be 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllDetailsPersonnelInfoMobile.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllDetailsPersonnelInfoMobile.cshtml @@ -1,7 +1,7 @@ @model CompanyManagment.App.Contracts.Workshop.PersonnelInfoPrintViewModel @{ - var i = 1; - } + + + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllList.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllList.cshtml index 0a32bcc1..ffaeb63b 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllList.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllList.cshtml @@ -1,10 +1,12 @@ -@model CompanyManagment.App.Contracts.Leave.GroupLeavePrintViewModel; +@using _0_Framework.Application +@using Version = _0_Framework.Application.Version +@model CompanyManagment.App.Contracts.Leave.GroupLeavePrintViewModel; @* *@ @{ - - var index = 1; + int index = 1; } - \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllPersonnelInfo.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllPersonnelInfo.cshtml index beb656cf..5a792e80 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllPersonnelInfo.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllPersonnelInfo.cshtml @@ -1,7 +1,7 @@ @model CompanyManagment.App.Contracts.Workshop.PersonnelInfoPrintViewModel @{ - var i = 1; - } + + - - - - - + + + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllPersonnelInfoMobile.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllPersonnelInfoMobile.cshtml index 5a9fba6b..43ca2eed 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllPersonnelInfoMobile.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintAllPersonnelInfoMobile.cshtml @@ -1,7 +1,7 @@ @model CompanyManagment.App.Contracts.Workshop.PersonnelInfoPrintViewModel @{ - var i = 1; - } - + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintOne.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintOne.cshtml index 12733176..4d7ccd42 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintOne.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintOne.cshtml @@ -204,7 +204,7 @@
- - + - - - +
@@ -361,27 +357,27 @@ \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintOneMobile.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintOneMobile.cshtml index 87a4d5cf..0cefc3dc 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/PrintOneMobile.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/PrintOneMobile.cshtml @@ -208,7 +208,7 @@
- + - + - +
@@ -366,35 +362,33 @@ \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/SickLeave.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/SickLeave.cshtml index edee2a4b..65235529 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/SickLeave.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/SickLeave.cshtml @@ -1,72 +1,72 @@ @model CompanyManagment.App.Contracts.Leave.CreateLeave @{ - var i = 1; + int i = 1; } @{ - + } - +
- -
- + + + - - @**@ - + + @**@ + -
+ -
-
- + +
+ - + - -
- - @*
+
+ +@*
\ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/SickLeaveList.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/SickLeaveList.cshtml index 8c805c16..4a6dcc86 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/SickLeaveList.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/SickLeaveList.cshtml @@ -1,99 +1,97 @@ @model List -@{ - var i = 1; +@{ + int i = 1; } -
-
-
-

سوابق مرخصی استعلاجی

-
-
-
-
- - - - - - - - - - - @foreach (var item in Model) - { - - - - - @{ - i++; - } - - - } - -
# تاریخ شروع تاریخ پایان عملیات
@i @item.StartLeave - @item.EndLeave - - - - - - - -
- -
-
-
-
-
-
-
- +
+
+
+

سوابق مرخصی استعلاجی

+
+
+
+
+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + @{ + i++; + } + + + } + +
# تاریخ شروع تاریخ پایان عملیات
@i @item.StartLeave + @item.EndLeave + + + + + +
+ +
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/WorkshopList.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/WorkshopList.cshtml index 0502c4c5..2daaddec 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/WorkshopList.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/WorkshopList.cshtml @@ -1,57 +1,53 @@ @page -@model WorkshopListModel +@model ServiceHost.Areas.Client.Pages.Company.Employees.WorkshopListModel @{ } - - - + + + -
+
-
- +
+
-
-
- -

لطفا کارگاه مورد نظر را انتخاب کنید

-
+
+
+ +

لطفا کارگاه مورد نظر را انتخاب کنید

+
- @if (Model.Workshops != null && Model.Workshops.Count > 0) - { - var index = 1; - foreach (var item in Model.Workshops) - { -
-

- کارگاه شماره@index -

-

- @item.WorkshopName -

- - -
+ @if (Model.Workshops != null && Model.Workshops.Count > 0) + { + int index = 1; + foreach (var item in Model.Workshops) + { +
+

کارگاه شماره@index

+

@item.WorkshopName

+ + +
- index = index + 1; - } - } -
+ index = index + 1; + } + } +
-
-
+
+
@section Script { - + - function getWorkshopList(){ - } + function getWorkshopList(){ + } } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/WorkshopList.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/Employees/WorkshopList.cshtml.cs index b085d873..e45dd73b 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/WorkshopList.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/WorkshopList.cshtml.cs @@ -1,24 +1,27 @@ +using System.Collections.Generic; +using System.Linq; using _0_Framework.Application; using CompanyManagment.App.Contracts.Workshop; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace ServiceHost.Areas.Client.Pages.Company.Employees; - -public class WorkshopListModel : PageModel +namespace ServiceHost.Areas.Client.Pages.Company.Employees { - private readonly IAuthHelper _authHelper; - private readonly IWorkshopApplication _workshopApplication; - public List Workshops; + public class WorkshopListModel : PageModel + { + public List Workshops; + private readonly IWorkshopApplication _workshopApplication; - public WorkshopListModel(IAuthHelper authHelper, IWorkshopApplication workshopApplication) - { - _workshopApplication = workshopApplication; - _authHelper = authHelper; - } - - public void OnGet() - { - var searchModel = new WorkshopSearchModel(); - Workshops = _workshopApplication.SearchForClient(searchModel).ToList(); - } -} \ No newline at end of file + private readonly IAuthHelper _authHelper; + public WorkshopListModel(IAuthHelper authHelper, IWorkshopApplication workshopApplication) + { + _workshopApplication = workshopApplication; + _authHelper = authHelper; + } + public void OnGet() + { + WorkshopSearchModel searchModel = new WorkshopSearchModel(); + Workshops = _workshopApplication.SearchForClient(searchModel).ToList(); + } + } +} diff --git a/ServiceHost/Areas/Client/Pages/Company/Employees/alert.cshtml b/ServiceHost/Areas/Client/Pages/Company/Employees/alert.cshtml index 31fced75..b6789b8f 100644 --- a/ServiceHost/Areas/Client/Pages/Company/Employees/alert.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/Employees/alert.cshtml @@ -1,130 +1,138 @@ @model CompanyManagment.App.Contracts.Checkout.CreateCheckout @{ - var i = 1; - var b = 0; + + int i = 1; + int b = 0; } @if (Model.Contracts != null) { - @foreach (var item in Model.Contracts) - { - - @if (item.RedColor) - { - - } - @if (item.MoreThanOneMonth && item.Waiting == false) - { - - } - else if (item.Waiting && item.MoreThanOneMonth == false) - { - - } - else if (item.Waiting && item.MoreThanOneMonth) - { - - } + @foreach (var item in Model.Contracts) + { + + @if (item.RedColor) + { + + } + @if (item.MoreThanOneMonth && item.Waiting == false) + { + + } + else if (item.Waiting && item.MoreThanOneMonth == false) + { + + } + else if (item.Waiting && item.MoreThanOneMonth) + { + + } - - @i - - + + @i + + - @if (item.Extension) - { - - b++; - } - else - { - @if (item.RedColor) - { - - } - else - { - - } - } - - - - - - @item.EmployeeName - - @{ - i++; - } - - } + @if (item.Extension) + { + + + b++; + } + else + { + @if (item.RedColor) + { + + } + else + { + + } + + } + + + + + + @item.EmployeeName + + @{ + i++; + } + + } } + + - // ); - //} - //var checkboxes3 = document.getElementsByName('Waiting'); - //for (var a = 0, f = checkboxes3.length; a < f; a++) { - // $('#alarm').append( - // '
از آخرین قرارداد  ' + checkboxes3[a].value + '   تا تاریخ تبدیل انتخاب شده هیچ قراردادی وجود ندارد
' - // ); - //} - /*ff8f8d*/ - \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/Error/_ErrorModal.cshtml b/ServiceHost/Areas/Client/Pages/Company/Error/_ErrorModal.cshtml new file mode 100644 index 00000000..970c0bcb --- /dev/null +++ b/ServiceHost/Areas/Client/Pages/Company/Error/_ErrorModal.cshtml @@ -0,0 +1,29 @@ +@model CompanyManagment.App.Contracts.Error.ErrorViewModel + +@{ + +} + + \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/InsuranceList/EmployeeDatatable.cshtml b/ServiceHost/Areas/Client/Pages/Company/InsuranceList/EmployeeDatatable.cshtml index 4814ccae..79c3b249 100644 --- a/ServiceHost/Areas/Client/Pages/Company/InsuranceList/EmployeeDatatable.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/InsuranceList/EmployeeDatatable.cshtml @@ -1,134 +1,132 @@ -@using _0_Framework.Application + +@using _0_Framework.Application @model CompanyManagment.App.Contracts.InsuranceList.MainEmployeeDetailsViewModel @{ } @if (Model.EmployeeDetailsForInsuranceList != null) -{ - var index = 1; -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @foreach (var item in Model.EmployeeDetailsForInsuranceList) - { - if (item.LeftWorkDate == item.StartMonthCurrent) - { - - +
تاریخ ترک کار تاریخ آغاز بکار شغل حق بیمه سهم بیمه شده حقوق و مزایای ماهیانه مشمول و غیر مشمول حقوق و مزایای ماهیانه مشمول مزایای ماهیانه مشمول حقوق ماهیانه مشمول دستمزد روزانه روزهای کارکرد ش شناسنامه تاریخ تولد محل صدور کدملی نام پدر جنسیت نام خانوادگی نام شماره بیمه #
- - @* +{ int index = 1; +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach (var item in Model.EmployeeDetailsForInsuranceList) + { + if (item.LeftWorkDate == item.StartMonthCurrent) + { + + - - - - - - - - - - - - - - - - - - - - - - } - else - { - - + + + + + + + + + + + + + + + + + + + + + + } + else + { + + - - - - - - - - - - - - - - - - - - - - - - } - index = index + 1; - } + + + + + + + + + + + + + + + + + + + + + + + } + index = index + 1; + } - -
تاریخ ترک کار تاریخ آغاز بکار شغل حق بیمه سهم بیمه شده حقوق و مزایای ماهیانه مشمول و غیر مشمول حقوق و مزایای ماهیانه مشمول مزایای ماهیانه مشمول حقوق ماهیانه مشمول دستمزد روزانه روزهای کارکرد ش شناسنامه تاریخ تولد محل صدور کدملی نام پدر جنسیت نام خانوادگی نام شماره بیمه #
+ + @* *@ - @item.LeftWorkDate@item.StartWorkDate@item.JobName00 0 0 000@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue@item.NationalCode@item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
- - @* + @item.LeftWorkDate@item.StartWorkDate@item.JobName00 0 0 000@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue@item.NationalCode@item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
+ + @* *@ - @item.LeftWorkDate@item.StartWorkDate@item.JobName@item.InsuranceShare.ToMoney()@item.IncludedAndNotIncluded.ToMoney() @item.BenefitsIncludedContinuous.ToMoney() @item.MonthlyBenefits.ToMoney() @(item.HasConfilictJobs ? "" : item.MonthlySalary.ToMoney())@(item.HasConfilictJobs ? "" : item.DailyWageStr)@item.WorkingDays@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue@item.NationalCode@item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
@item.LeftWorkDate@item.StartWorkDate@item.JobName@item.InsuranceShare.ToMoney()@item.IncludedAndNotIncluded.ToMoney() @item.BenefitsIncludedContinuous.ToMoney() @item.MonthlyBenefits.ToMoney() @(item.HasConfilictJobs?"":item.MonthlySalary.ToMoney())@(item.HasConfilictJobs?"":item.DailyWageStr)@item.WorkingDays@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue@item.NationalCode@item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
+
} @@ -173,18 +171,18 @@ }); }); - @if (Model != null && Model.IsExist) - { - + @if (Model != null && Model.IsExist==true) + { + $("#resultExistPersonel").show(); $("#ddlYear").addClass("errored"); $("#ddlMonth").addClass("errored"); $("#resultExistPersonel").html('برای این کارگاه در ماه و سال انتخاب شده لیست بیمه تنظیم گردیده است، در صورت نیاز به ثبت این لیست،لیست قبلی را حذف نمایید.'); - } + } else { - + $("#resultExistPersonel").hide(); $("#ddlYear").removeClass("errored"); $("#ddlMonth").removeClass("errored"); diff --git a/ServiceHost/Areas/Client/Pages/Company/InsuranceList/EmployeeListForEdit.cshtml b/ServiceHost/Areas/Client/Pages/Company/InsuranceList/EmployeeListForEdit.cshtml index 0442bb79..7f70cd81 100644 --- a/ServiceHost/Areas/Client/Pages/Company/InsuranceList/EmployeeListForEdit.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/InsuranceList/EmployeeListForEdit.cshtml @@ -5,123 +5,122 @@ @if (Model.EmployeeDetailsForInsuranceList != null) { - var index = 1; -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @foreach (var item in Model.EmployeeDetailsForInsuranceList) - { - if (item.HasLeftWorkInMonth && item.LeftWorkDate == item.StartMonthCurrent) - { - - - - - - - - - - - - - - - - - - - - - - - - } - else - { - - - - - - - - - - - - - - - - - - - - - - - - } - index = index + 1; - } -
تاریخ ترک کار تاریخ آغاز بکار شغل حق بیمه سهم بیمه شده حقوق و مزایای ماهیانه مشمول و غیر مشمول حقوق و مزایای ماهیانه مشمول مزایای ماهیانه مشمول حقوق ماهیانه مشمول دستمزد روزانه روزهای کارکرد ش شناسنامه تاریخ تولد محل صدور کدملی نام پدر جنسیت نام خانوادگی نام شماره بیمه #
- - @item.LeftWorkDate@item.StartWorkDate@item.JobName00 0 0 000@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue@item.NationalCode@item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
- - @item.LeftWorkDate@item.StartWorkDate@item.JobName@item.InsuranceShare.ToMoney()@item.IncludedAndNotIncluded.ToMoney() @item.BenefitsIncludedContinuous.ToMoney() @item.MonthlyBenefits.ToMoney() @(item.HasConfilictJobs ? "" : item.MonthlySalary.ToMoney())@(item.HasConfilictJobs ? "" : item.DailyWageStr)@item.WorkingDays@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue @item.NationalCode @item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
+ int index = 1; +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach (var item in Model.EmployeeDetailsForInsuranceList) + { + if (item.HasLeftWorkInMonth && item.LeftWorkDate == item.StartMonthCurrent) + { + + + + + + + + + + + + + + + + + + + + + + + + } + else + { + + + + + + + + + + + + + + + + + + + + + + + + } + index = index + 1; + } +
تاریخ ترک کار تاریخ آغاز بکار شغل حق بیمه سهم بیمه شده حقوق و مزایای ماهیانه مشمول و غیر مشمول حقوق و مزایای ماهیانه مشمول مزایای ماهیانه مشمول حقوق ماهیانه مشمول دستمزد روزانه روزهای کارکرد ش شناسنامه تاریخ تولد محل صدور کدملی نام پدر جنسیت نام خانوادگی نام شماره بیمه #
+ + @item.LeftWorkDate@item.StartWorkDate@item.JobName00 0 0 000@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue@item.NationalCode@item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
+ + @item.LeftWorkDate@item.StartWorkDate@item.JobName@item.InsuranceShare.ToMoney()@item.IncludedAndNotIncluded.ToMoney() @item.BenefitsIncludedContinuous.ToMoney() @item.MonthlyBenefits.ToMoney() @(item.HasConfilictJobs?"":item.MonthlySalary.ToMoney())@(item.HasConfilictJobs?"":item.DailyWageStr)@item.WorkingDays@item.IdNumber@item.DateOfBirth@item.PlaceOfIssue @item.NationalCode @item.FatherName@item.Gender@item.LName@item.FName@item.InsuranceCode@index
} + - - + + + - + + + + + + + + + + } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Pages/Company/InsuranceList/Index.cshtml.cs b/ServiceHost/Areas/Client/Pages/Company/InsuranceList/Index.cshtml.cs index 31249fad..9e61c886 100644 --- a/ServiceHost/Areas/Client/Pages/Company/InsuranceList/Index.cshtml.cs +++ b/ServiceHost/Areas/Client/Pages/Company/InsuranceList/Index.cshtml.cs @@ -1,1076 +1,1097 @@ -using System.Security.Claims; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; using _0_Framework.Application; +using CompanyManagment.App.Contracts.Checkout; using CompanyManagment.App.Contracts.Employee; +using CompanyManagment.App.Contracts.EmployeeInsurancListData; using CompanyManagment.App.Contracts.Employer; +using CompanyManagment.App.Contracts.InsuranceEmployeeInfo; +using CompanyManagment.App.Contracts.Workshop; using CompanyManagment.App.Contracts.InsuranceList; using CompanyManagment.App.Contracts.InsuranceWorkshopInfo; using CompanyManagment.App.Contracts.Job; -using CompanyManagment.App.Contracts.Workshop; +using CompanyManagment.App.Contracts.LeftWorkInsurance; +using CompanyManagment.App.Contracts.PersonnleCode; using CompanyManagment.App.Contracts.YearlySalary; +using MD.PersianDateTime.Standard; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.Rendering; +using SocialExplorer.IO.FastDBF; +using CompanyManagment.App.Contracts.Contract; +using Company.Domain.InsuranceListAgg; +using System.Security.Claims; -namespace ServiceHost.Areas.Client.Pages.Company.InsuranceList; - -public class IndexModel : PageModel +namespace ServiceHost.Areas.Client.Pages.Company.InsuranceList { - private readonly IEmployeeApplication _employeeApplication; - private readonly IEmployerApplication _employerApplication; - private readonly IInsuranceListApplication _insuranceListApplication; - private readonly IInsuranceWorkshopInfoApplication _insuranceWorkshopInfoApplication; - private readonly IJobApplication _jobApplication; - - private readonly IPasswordHasher _passwordHasher; - - //private readonly IInsuranceEmployeeInfoApplication _insuranceEmployeeInfoApplication; - private readonly IWebHostEnvironment _webHostEnvironment; - private readonly IWorkshopApplication _workshopApplication; - private readonly IYearlySalaryApplication _yearlySalaryApplication; - public string BeforCurrentMonth_; - - - public string CurrentYear_; - public List InsurancList; - public string Month; - public int PageIndex; - - public InsuranceListSearchModel SearchModel; - public string Sorting; - - public string TypeOfInsurance; - //public static string workshopName { get; set; } - //public static string typeOfInsuranceSend { get; set; } - //public static bool fixedSalary { get; set; } - //public static string workshopCode { get; set; } - //public static string WorkshopFullName { get; set; } - - public EditWorkshop workshop; - public long WorkshopId; - public string WorkshopName; - public string Year; - public List YearlyList; - - public IndexModel(IInsuranceListApplication insuranceListApplication, IWorkshopApplication workshopApplication, - IYearlySalaryApplication yearlySalaryApplication, IEmployerApplication employerApplication, - IInsuranceWorkshopInfoApplication insuranceWorkshopInfoApplication, IEmployeeApplication employeeApplication, - IJobApplication jobApplication, IWebHostEnvironment webHostEnvironment, - IPasswordHasher passwordHasher) // , IInsuranceEmployeeInfoApplication insuranceEmployeeInfoApplication ) - { - _jobApplication = jobApplication; - _insuranceListApplication = insuranceListApplication; - _workshopApplication = workshopApplication; - _yearlySalaryApplication = yearlySalaryApplication; - _employerApplication = employerApplication; - _insuranceWorkshopInfoApplication = insuranceWorkshopInfoApplication; - _employeeApplication = employeeApplication; - //_insuranceEmployeeInfoApplication = insuranceEmployeeInfoApplication; - _webHostEnvironment = webHostEnvironment; - _passwordHasher = passwordHasher; - } - - public static long workshopId_ { get; set; } - - public IActionResult OnGet(InsuranceListSearchModel searchModel) - { - if (User.Identity.IsAuthenticated) - { - var workshopSlugCliam = User.FindFirstValue("WorkshopSlug"); - var workshopId = _passwordHasher.SlugDecrypt(workshopSlugCliam); - if (workshopId > 0) - { - searchModel.Sorting = string.IsNullOrWhiteSpace(searchModel.Sorting) - ? "CreationDate-Max" - : searchModel.Sorting; - searchModel.PageIndex = 0; - Year = searchModel.Year; - Month = searchModel.Month; - WorkshopId = workshopId == 0 ? searchModel.WorkshopId : workshopId; - searchModel.WorkshopId = WorkshopId; - Sorting = string.IsNullOrWhiteSpace(searchModel.Sorting) ? "CreationDate-Max" : searchModel.Sorting; - var workshopInfo = _workshopApplication.GetWorkshopInfo(WorkshopId); - //workshop = _workshopApplication.GetDetails(workshopId_); - WorkshopName = workshopInfo.WorkshopFullName; - searchModel.FixedSalary = workshopInfo.FixedSalary; - searchModel.TypeOfInsuranceSend = workshopInfo.TypeOfInsuranceSend; - searchModel.WorkShopCode = workshopInfo.InsuranceCode; - TypeOfInsurance = workshopInfo.InsuranceCode; - - #region OldConvertYearAndMonth - - //string date = DateTime.Now.ToFarsi(); - //var year = Convert.ToInt32(date.Substring(0, 4)); - //var month = Convert.ToInt32(date.Substring(5, 2)); - //var day = Convert.ToInt32(date.Substring(8, 2)); - //var persianDate = new PersianDateTime(year, month, day); - //string persianBeforeDate = persianDate.AddMonths(-1).ToString("yyyy/MM/dd"); - //BeforCurrentMonth_ = persianBeforeDate.Substring(5, 2); - //CurrentYear_ = persianBeforeDate.Substring(0, 4); - - #endregion - - InsurancList = _insuranceListApplication.SearchForClient(searchModel); - - YearlyList = - _yearlySalaryApplication.GetYears(); - SearchModel = new InsuranceListSearchModel - { - Year = string.IsNullOrWhiteSpace(searchModel.Year) ? " " : searchModel.Year, - Month = string.IsNullOrWhiteSpace(searchModel.Month) ? " " : searchModel.Month, - Sorting = searchModel.Sorting - }; - return Page(); - } - - return Redirect("error/404"); - } - - return Redirect("error/404"); - } - - #region PrintOne - - public IActionResult OnGetPrintOne(long id) - { - var insurance = _insuranceListApplication.GetDetails(id); - return Partial("PrintOne", insurance); - } - - #endregion - - #region PrintOneMobile - - public IActionResult OnGetPrintOneMobile(long id) - { - var insurance = _insuranceListApplication.GetDetails(id); - return Partial("PrintOneMobile", insurance); - } - - #endregion - - #region OldClientByHeydari - - //public IActionResult OnGetSearch(InsuranceListSearchModel searchModel) - //{ - - // workshop = _workshopApplication.GetDetails(workshopId_); - // searchModel.FixedSalary = workshop.FixedSalary; - // searchModel.WorkShopName = workshop.WorkshopName; - // searchModel.TypeOfInsuranceSend = workshop.TypeOfInsuranceSend; - // searchModel.WorkShopCode = workshop.InsuranceCode; - // searchModel.WorkshopId = workshopId_; - - - // var searchResult = _insuranceListApplication.SearchForClient(searchModel); - - // foreach (var item in searchResult) - // { - // item.Month = item.Month.GetMonthByNumber(); - // } - - // var result = new CompanyManagment.App.Contracts.InsuranceList.MainViewModel(); - // result.MainList = searchResult; - - - // return Partial("./MainSearch", result); - //} - //public IActionResult OnGetCreate() - //{ - // string date = DateTime.Now.ToFarsi(); - // var year = Convert.ToInt32(date.Substring(0, 4)); - // var month = Convert.ToInt32(date.Substring(5, 2)); - // var day = Convert.ToInt32(date.Substring(8, 2)); - // var persianDate = new PersianDateTime(year, month, day); - // string persianBeforeDate = persianDate.AddMonths(-1).ToString("yyyy/MM/dd"); - // //var workshopList = _workshopApplication.GetWorkshopAccount().Where(x => !string.IsNullOrWhiteSpace(x.TypeOfInsuranceSend) && x.TypeOfInsuranceSend != "false").ToList(); - // workshop = _workshopApplication.GetDetails(workshopId_); - // var command = new CreateInsuranceList() - // { - // //WorkShopSelectList = new SelectList(workshopList, "Id", "WorkshopFullName"), - // YearList = _yearlySalaryApplication.GetYears(), - // BeforCurrentMonth = persianBeforeDate.Substring(5, 2), - // CurrentYear = persianBeforeDate.Substring(0, 4), - // WorkshopId = workshopId_, - // WorkshopName = workshop.WorkshopFullName - // }; - // return Partial("./Create", command); - //} - - //public IActionResult OnPostCreate(CreateInsuranceList command) - //{ - // //var result =new OperationResult(); - // //result.IsSuccedded = true; - // var result = _insuranceListApplication.Create(command); - // if (result.IsSuccedded) - // { - // var saveFileResult = SaveFile(command); - // if (saveFileResult) - // { - // result.IsSuccedded = true; - // result.Message = "ثبت اطلاعات با موفقیت انجام شد"; - // } - // else - // { - // result.Failed("ایجاد فایل بیمه با خطا مواجه شد"); - // } - // } - // //else - // //{ - // // result.Failed("ثبت اطلاعات با خطا مواجه شد"); - // //} - // return new JsonResult(result); - //} - - //public IActionResult OnPostGetEmployerName(long workshopId) - //{ - // string names = ""; - // var employerList = _employerApplication.GetEmployerByWorkshopId(workshopId); - // var workshopInfo = _insuranceWorkshopInfoApplication.GetDetails(workshopId); - // // var personelInfo = _employeeApplication.(workshopId); - - // string isLegal = employerList.FirstOrDefault()?.IsLegal; - // bool boolIsLegal = (isLegal == "حقوقی" ? true : false); - - // foreach (var item in employerList) - // { - // if (boolIsLegal) - // { - // names = (item.EmployerLName != "#" ? (item.FName + " " + item.EmployerLName) : item.LName); - // } - // else - // { - - // names = names + item.EmployerFullName + ","; - // } - // } - - // if (!boolIsLegal) - // names = names.Substring(0, names.Length - 1); - - // return new JsonResult(new - // { - // EmployerNames = names, - // WorkshopInfo = workshopInfo, - // IsLegal = boolIsLegal - // }); - //} - - - //public IActionResult OnGetEmployeeSearch(EmployeeForCreateInsuranceListSearchModel searchModel) - //{ - - // var result = _insuranceListApplication.SearchEmployeeForCreateInsuranceList(searchModel); - // return Partial("./EmployeeDatatable", result); - //} - - //public IActionResult OnPostCreateEmployeeDetailsInfo(EmployeeDetailsForInsuranceListViewModel command) - //{ - - // TempData["EmployeeDetails"] = command; - // var result = new OperationResult(); - // if (command.InsuranceEmployeeInformationId == 0) - // result = _insuranceListApplication.CreateEmployeeDetailsInfo(command); - // else - // result = _insuranceListApplication.EditEmployeeDetailsInfo(command); - - // return new JsonResult(result); - //} - - //public IActionResult OnPostJobList() - //{ - // var jobs = _jobApplication.GetJob(); - // return new JsonResult(new - // { - // IsSuccedded = true, - // jobList = jobs, - // }); - //} - - //public IActionResult OnPostRemoveInsuranceList(long id, string pathDSKKAR00, string pathDSKWOR00) - //{ - // var result = _insuranceListApplication.Remove(id); - // if (result.IsSuccedded) - // { - // pathDSKKAR00 = pathDSKKAR00.Replace("-", "\\"); - // var filePathDSKKAR00 = $"{_webHostEnvironment.ContentRootPath}\\InsuranceList\\{pathDSKKAR00}"; - // if (System.IO.File.Exists(filePathDSKKAR00)) - // System.IO.File.Delete(filePathDSKKAR00); - - // pathDSKWOR00 = pathDSKWOR00.Replace("-", "\\"); - // var filePathDSKWOR00 = $"{_webHostEnvironment.ContentRootPath}\\InsuranceList\\{pathDSKWOR00}"; - // if (System.IO.File.Exists(filePathDSKWOR00)) - // System.IO.File.Delete(filePathDSKWOR00); - // } - // return new JsonResult(result); - //} - - //public IActionResult OnPostConfirmInsuranceList(long id) - //{ - // var result = _insuranceListApplication.ConfirmInsuranceList(id); - // return new JsonResult(result); - //} - - //public IActionResult OnGetDownloadFile(string path, string fileName) - //{ - // //var path= "11\\1402_03\\DSKWOR00.dbf"; - // // Replace "file.dbf" with the name of your .dbf file - // var filePath = $"{_webHostEnvironment.ContentRootPath}\\InsuranceList\\{path}"; ; - - // // Read the file content into a byte array - // byte[] fileContent = System.IO.File.ReadAllBytes(filePath); - - // // Return the file content as a FileResult with the appropriate MIME type and file name - // return File(fileContent, "application/dbase", fileName); - //} - //private string GetSpecifiedCharactes(string str, int MaxLength) - //{ - // return str.Length <= MaxLength ? str : str.Substring(0, MaxLength); - //} - //private bool SaveFile(CreateInsuranceList createInsuranceList) - //{ - // try - // { - // //var path = $"profilePhotos"; - // var path = createInsuranceList.InsuranceWorkshopInfo.WorkshopId; - // var directoryPath = $"{_webHostEnvironment.ContentRootPath}\\InsuranceList\\{path}"; - // if (!Directory.Exists(directoryPath)) - // Directory.CreateDirectory(directoryPath); - - // //ایجاد پوشه با توجه به هر ماه و سال - // var monthPath = directoryPath + "\\" + createInsuranceList.Year + "_" + createInsuranceList.Month; - // if (!Directory.Exists(monthPath)) - // Directory.CreateDirectory(monthPath); - - // var currentdate = DateTime.Now; - // var currentDay = Convert.ToInt32(currentdate.ToFarsi().Substring(8, 2)); - // ////ایجاد پوشه با توجه به هر روز و ساعت و دقیقه و ثانیه - // //var dayPath = monthPath +"\\"+ currentDay+"_"+ currentdate.Hour + "_" + currentdate.Month + "_" + currentdate.Second; - // //if (!Directory.Exists(dayPath)) - // // Directory.CreateDirectory(dayPath); - // //فعلا قرار شد روی فایل قبلی ریپلیس بشه - // // string fileName = currentDay + "_" + currentdate.Hour + "_" + currentdate.Month + "_" + currentdate.Second +"_"; - // if (createInsuranceList.InsuranceWorkshopInfo != null) - // { - // var odbf = new DbfFile(Encoding.GetEncoding(1256)); - // odbf.Open(Path.Combine(monthPath, "DSKKAR00.dbf"), FileMode.Create); - // //کد کارگاه - // odbf.Header.AddColumn(new DbfColumn("DSK_ID", DbfColumn.DbfColumnType.Character, 10, 0)); - // //نام کارگاه - // odbf.Header.AddColumn(new DbfColumn("DSK_NAME", DbfColumn.DbfColumnType.Character, 100, 0)); - // //نام کارفرما - // odbf.Header.AddColumn(new DbfColumn("DSK_FARM", DbfColumn.DbfColumnType.Character, 100, 0)); - // //نام آدرس - // odbf.Header.AddColumn(new DbfColumn("DSK_ADRS", DbfColumn.DbfColumnType.Character, 100, 0)); - // //نوع لیست - // odbf.Header.AddColumn(new DbfColumn("DSK_KIND", DbfColumn.DbfColumnType.Number, 1, 0)); - // //سال عملکرد - // odbf.Header.AddColumn(new DbfColumn("DSK_YY", DbfColumn.DbfColumnType.Number, 2, 0)); - // //ماه عملکرد - // odbf.Header.AddColumn(new DbfColumn("DSK_MM", DbfColumn.DbfColumnType.Number, 2, 0)); - // //شماره لیست - // odbf.Header.AddColumn(new DbfColumn("DSK_LISTNO", DbfColumn.DbfColumnType.Character, 12, 0)); - // //شرح لیست - // odbf.Header.AddColumn(new DbfColumn("DSK_DISC", DbfColumn.DbfColumnType.Character, 100, 0)); - // //تعداد کارکنان - // odbf.Header.AddColumn(new DbfColumn("DSK_NUM", DbfColumn.DbfColumnType.Number, 5, 0)); - // //تعداد کارکنان - // odbf.Header.AddColumn(new DbfColumn("DSK_TDD", DbfColumn.DbfColumnType.Number, 6, 0)); - // //مجموع دستمزد روزانه - // odbf.Header.AddColumn(new DbfColumn("DSK_TROOZ", DbfColumn.DbfColumnType.Number, 12, 0)); - // //مجموع دستمزد ماهانه - // odbf.Header.AddColumn(new DbfColumn("DSK_TMAH", DbfColumn.DbfColumnType.Number, 12, 0)); - // //مجموع مزایای ماهانه - // odbf.Header.AddColumn(new DbfColumn("DSK_TMAZ", DbfColumn.DbfColumnType.Number, 12, 0)); - // //مجموع دستمزد و مزایای ماهانه مشمول - // odbf.Header.AddColumn(new DbfColumn("DSK_TMASH", DbfColumn.DbfColumnType.Number, 12, 0)); - // // مجموع کل دستمزد و مزایای ماهانه مشمول و غیر مشمول - // odbf.Header.AddColumn(new DbfColumn("DSK_TTOTL", DbfColumn.DbfColumnType.Number, 12, 0)); - // //مجموع حق بیمه سهم بیمه شده - // odbf.Header.AddColumn(new DbfColumn("DSK_TBIME", DbfColumn.DbfColumnType.Number, 12, 0)); - // //مجموع حق بیمه سهم کارفرما - // odbf.Header.AddColumn(new DbfColumn("DSK_TKOSO", DbfColumn.DbfColumnType.Number, 12, 0)); - // //مجموع حق بیمه بیکاری - // odbf.Header.AddColumn(new DbfColumn("DSK_BIC", DbfColumn.DbfColumnType.Number, 12, 0)); - // //نرخ حق بیمه - // odbf.Header.AddColumn(new DbfColumn("DSK_RATE", DbfColumn.DbfColumnType.Number, 5, 0)); - // //نرخ پورسانتاژ - // odbf.Header.AddColumn(new DbfColumn("DSK_PRATE", DbfColumn.DbfColumnType.Number, 2, 0)); - // //نرخ مشاغل سخت زیان آور - // odbf.Header.AddColumn(new DbfColumn("DSK_BIMH", DbfColumn.DbfColumnType.Number, 12, 0)); - // //ردیف پیمان - // odbf.Header.AddColumn(new DbfColumn("MON_PYM", DbfColumn.DbfColumnType.Character, 3, 0)); - // var orec = new DbfRecord(odbf.Header); - - // //کد کارگاه - // orec[0] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.InsuranceCode, 10); - // orec[1] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.WorkshopName, 100), IranSystemNumbers.DontConvert); - // orec[2] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.EmployerName, 100), IranSystemNumbers.DontConvert); - // orec[3] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.Address, 100), IranSystemNumbers.DontConvert); - // //orec[3] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("رشت - بلوار شهدای گمنام - کوچه شهید علی قربانی - ساختمان پیام نور - طبقه اول واحد 2", 100), IranSystemNumbers.DontConvert); - // // نوع لیست - // orec[4] = "0"; - // //سال - // orec[5] = Convert.ToInt32(createInsuranceList.Year.Substring(2, 2)).ToString(); - // //ماه - // orec[6] = Convert.ToInt32(createInsuranceList.Month).ToString(); - // //شماره لیست - // orec[7] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.ListNumber, 12); - // //شرح لیست - // orec[8] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("", 100), IranSystemNumbers.DontConvert); - // //تعداد کرکنان - // orec[9] = createInsuranceList.SumOfEmployees.ToString(); - // //مجموع روزهای کارکرد - // orec[10] = createInsuranceList.SumOfWorkingDays.ToString(); - // //مجموع دستمزد روزانه - // orec[11] = createInsuranceList.SumOfDailyWage.ToString(); - // //مجموع دستمزد ماهانه - // orec[12] = createInsuranceList.SumOfSalaries.ToString(); - // //مجموع مزایای ماهانه مشمول - // orec[13] = createInsuranceList.SumOfBenefitsIncluded.ToString(); - // //مجموع دستمزد و مزایای ماهانه مشمول - // orec[14] = createInsuranceList.Included.ToString(); - // //مجموع کل دستمزد و مزایای ماهانه مشمول و غیر مشمول - // orec[15] = createInsuranceList.IncludedAndNotIncluded.ToString(); - // // مجموع حق بیمه سهم بیمه شده - // orec[16] = createInsuranceList.InsuredShare.ToString(); - // //مجموع حق بیمه سهم کارفرما - // orec[17] = createInsuranceList.EmployerShare.ToString(); //"44911361"; - // //مجموع حق بیمه بیکاری - // orec[18] = createInsuranceList.UnEmploymentInsurance.ToString(); - // //نرخ حق بیمه - // orec[19] = "23"; - // //نرخ پورسانتاژ - // orec[20] = "0"; - // //نرخ مشاغل سخت زیان آور - // orec[21] = createInsuranceList.DifficultJobsInsuranc.ToString(); - // //ردیف پیمان - // orec[22] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.AgreementNumber, 12); - // odbf.Write(orec); - // //odbf.Header.RecordCount = 50; - // odbf.WriteHeader(); - // odbf.Close(); - // } - - - // if (createInsuranceList.EmployeeInsurancListDataList != null) - // { - // //لیست پرسنل - // var dsw = new DbfFile(Encoding.GetEncoding(1256)); - // dsw.Open(Path.Combine(monthPath, "DSKWOR00.dbf"), FileMode.Create); - // //کد کارگاه - // dsw.Header.AddColumn(new DbfColumn("DSW_ID", DbfColumn.DbfColumnType.Character, 10, 0)); - // //سال عملکرد - // dsw.Header.AddColumn(new DbfColumn("DSW_YY", DbfColumn.DbfColumnType.Number, 2, 0)); - // //ماه عملکرد - // dsw.Header.AddColumn(new DbfColumn("DSW_MM", DbfColumn.DbfColumnType.Number, 2, 0)); - // //شماره لیست - // dsw.Header.AddColumn(new DbfColumn("DSW_LISTNO", DbfColumn.DbfColumnType.Character, 12, 0)); - // //شماره بیمه - // dsw.Header.AddColumn(new DbfColumn("DSW_ID1", DbfColumn.DbfColumnType.Character, 10, 0)); - // // نام - // dsw.Header.AddColumn(new DbfColumn("DSW_FNAME", DbfColumn.DbfColumnType.Character, 100, 0)); - // // نام خانوادگی - // dsw.Header.AddColumn(new DbfColumn("DSW_LNAME", DbfColumn.DbfColumnType.Character, 100, 0)); - // //نام پدر - // dsw.Header.AddColumn(new DbfColumn("DSW_DNAME", DbfColumn.DbfColumnType.Character, 100, 0)); - // // شماره شناسنامه - // dsw.Header.AddColumn(new DbfColumn("DSW_IDNO", DbfColumn.DbfColumnType.Character, 15, 0)); - // // محل صدور - // dsw.Header.AddColumn(new DbfColumn("DSW_IDPLC", DbfColumn.DbfColumnType.Character, 100, 0)); - // // تاریخ صدور - // dsw.Header.AddColumn(new DbfColumn("DSW_IDATE", DbfColumn.DbfColumnType.Character, 8, 0)); - // // تاریخ تولد - // dsw.Header.AddColumn(new DbfColumn("DSW_BDATE", DbfColumn.DbfColumnType.Character, 8, 0)); - // // جنسیت - // dsw.Header.AddColumn(new DbfColumn("DSW_SEX", DbfColumn.DbfColumnType.Character, 3, 0)); - // // ملیت - // dsw.Header.AddColumn(new DbfColumn("DSW_NAT", DbfColumn.DbfColumnType.Character, 10, 0)); - // // شرح شغل - // dsw.Header.AddColumn(new DbfColumn("DSW_OCP", DbfColumn.DbfColumnType.Character, 100, 0)); - // // تاریخ شروع بکار - // dsw.Header.AddColumn(new DbfColumn("DSW_SDATE", DbfColumn.DbfColumnType.Character, 8, 0)); - // // تاریخ ترک کار - // dsw.Header.AddColumn(new DbfColumn("DSW_EDATE", DbfColumn.DbfColumnType.Character, 8, 0)); - // // تعداد روزهای کارکرد - // dsw.Header.AddColumn(new DbfColumn("DSW_DD", DbfColumn.DbfColumnType.Number, 2, 0)); - // // دستمزد روزانه - // dsw.Header.AddColumn(new DbfColumn("DSW_ROOZ", DbfColumn.DbfColumnType.Number, 12, 0)); - // // دستمزد ماهانه - // dsw.Header.AddColumn(new DbfColumn("DSW_MAH", DbfColumn.DbfColumnType.Number, 12, 0)); - // // مزایای ماهانه - // dsw.Header.AddColumn(new DbfColumn("DSW_MAZ", DbfColumn.DbfColumnType.Number, 12, 0)); - // // جمع دستمزد و مزایای ماهانه مشمول - // dsw.Header.AddColumn(new DbfColumn("DSW_MASH", DbfColumn.DbfColumnType.Number, 12, 0)); - // // جمع کل دستمزد و مزایای ماهانه - // dsw.Header.AddColumn(new DbfColumn("DSW_TOTL", DbfColumn.DbfColumnType.Number, 12, 0)); - // //حق بیمه سهم بیمه شده - // dsw.Header.AddColumn(new DbfColumn("DSW_BIME", DbfColumn.DbfColumnType.Number, 12, 0)); - // //نرخ پورسانتاژ - // dsw.Header.AddColumn(new DbfColumn("DSW_PRATE", DbfColumn.DbfColumnType.Number, 2, 0)); - // // کد شغل - // dsw.Header.AddColumn(new DbfColumn("DSW_JOB", DbfColumn.DbfColumnType.Character, 6, 0)); - // // کد ملی - // dsw.Header.AddColumn(new DbfColumn("PER_NATCOD", DbfColumn.DbfColumnType.Character, 10, 0)); - - // foreach (var item in createInsuranceList.EmployeeInsurancListDataList) - // { - // var employee = createInsuranceList.EmployeeDetailsForInsuranceList.Where(p => p.EmployeeId == item.EmployeeId).FirstOrDefault(); - - // //var employeeObj = _employeeApplication.GetDetails(item.EmployeeId); - - // var dswrec = new DbfRecord(dsw.Header); - // //کد کارگاه - // dswrec[0] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.InsuranceCode, 10); - // //سال - // dswrec[1] = Convert.ToInt32(createInsuranceList.Year.Substring(2, 2)).ToString(); - // //ماه - // dswrec[2] = Convert.ToInt32(createInsuranceList.Month).ToString(); - // //شماره لیست - // dswrec[3] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.ListNumber, 12); - // //شماره بیمه - // dswrec[4] = GetSpecifiedCharactes(employee.InsuranceCode, 8); - // // نام - // dswrec[5] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.FName, 100), - // IranSystemNumbers.DontConvert); - // //خانوادگی نام - // dswrec[6] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.LName, 100), - // IranSystemNumbers.DontConvert); - // //پدر نام - // dswrec[7] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.FatherName, 100), - // IranSystemNumbers.DontConvert); - // //شماره شناسنامه - // dswrec[8] = employee.IdNumber; - // //محل صدور - // dswrec[9] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.PlaceOfIssue, 100), IranSystemNumbers.DontConvert); - // //تاریخ صدور - // dswrec[10] = (employee.DateOfIssue == "1300/10/11" || string.IsNullOrEmpty(employee.DateOfIssue)) ? "" : employee.DateOfIssue.Replace("/", ""); - // //تاریخ تولد - // dswrec[11] = (employee.DateOfBirth == "1300/10/11" || string.IsNullOrEmpty(employee.DateOfIssue)) ? "" : employee.DateOfBirth.Replace("/", ""); ; - // //جنسیت - // dswrec[12] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.Gender, 3), IranSystemNumbers.DontConvert); - // //ملیت - // //dswrec[13] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("ایرانی", 10), - // dswrec[13] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.Nationality, 10), - // IranSystemNumbers.DontConvert); - // //شرح شغل - // dswrec[14] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(item.JobName, 100), - // IranSystemNumbers.DontConvert); - // //تاریخ شروع بکار - // dswrec[15] = item.StartWorkDate.ToFarsi().Replace("/", ""); - - // //تاریخ ترک کار - // if (item.LeftWorkDate != null) - // dswrec[16] = item.LeftWorkDate.ToFarsi().Replace("/", ""); - // else - // dswrec[16] = ""; - - // //تعداد روزهای کارکرد - // dswrec[17] = item.WorkingDays.ToString(); - // //دستمزد روزانه - // dswrec[18] = item.DailyWage.ToString(); - // //دستمزد مااهانه - // dswrec[19] = item.MonthlySalary.ToString(); - // //مزایای ماهانه - // dswrec[20] = item.MonthlyBenefits.ToString(); - // //دستمزد و مزایای ماهانه مشمول - // dswrec[21] = item.MonthlyBenefitsIncluded.ToString(); - // //جمع کل دستمزد و مزایای ماهانه مسمول غیرمشمول - // dswrec[22] = item.IncludedAndNotIncluded.ToString(); - // //حق بیمه سهم بیمه شده - // dswrec[23] = item.InsuranceShare.ToString(); - // //نرخ پورسانتاژ - // dswrec[24] = "0"; - // //کد شغل - // dswrec[25] = item.JobCode; - // //کد ملی - // dswrec[26] = employee.NationalCode; - - // dsw.Write(dswrec); - // } - // //var dswrec = new DbfRecord(dsw.Header); - // ////کد کارگاه - // //dswrec[0] = GetSpecifiedCharactes("9008289145", 10); - // ////سال - // //dswrec[1] = "2"; - // ////ماه - // //dswrec[2] = "2"; - // ////شماره لیست - // //dswrec[3] = GetSpecifiedCharactes("01", 12); - // ////شماره بیمه - // //dswrec[4] = GetSpecifiedCharactes("48071464", 8); - // //// نام - // //dswrec[5] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("راضیه", 100), - // // IranSystemNumbers.DontConvert); - // ////خانوادگی نام - // //dswrec[6] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("پیردهقان", 100), - // // IranSystemNumbers.DontConvert); - // ////پدر نام - // //dswrec[7] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("غلام", 100), - // // IranSystemNumbers.DontConvert); - // ////شماره شناسنامه - // //dswrec[8] = "2650230614"; - // ////محل صدور - // //dswrec[9] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("رشت", 100), - // // IranSystemNumbers.DontConvert); - // //; - // ////تاریخ صدور - // //dswrec[10] = "13770805"; - // ////تاریخ تولد - // //dswrec[11] = "13770721"; - // ////جنسیت - // //dswrec[12] = - // // ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("زن", 3), IranSystemNumbers.DontConvert); - // ////ملیت - // //dswrec[13] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("ایرانی", 10), - // // IranSystemNumbers.DontConvert); - // ////شرح شغل - // //dswrec[14] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("کارشناس نرم افزار کامپیوتر", 100), - // // IranSystemNumbers.DontConvert); - // ////تاریخ شروع بکار - // //dswrec[15] = "14000201"; - // ////تاریخ ترک کار - // //dswrec[16] = ""; - // ////تعداد روزهای کارکرد - // //dswrec[17] = "31"; - // ////دستمزد روزانه - // //dswrec[18] = "1769428"; - // ////دستمزد مااهانه - // //dswrec[19] = "54852268"; - // ////مزایای ماهانه - // //dswrec[20] = "20000000"; - // ////دستمزد و مزایای ماهانه مشمول - // //dswrec[21] = "74852268"; - // ////جمع کل دستمزد و مزایای ماهانه مسمول غیرمشمول - // //dswrec[22] = "74852268"; - // ////حق بیمه سهم بیمه شده - // //dswrec[23] = "5239659"; - // ////نرخ پورسانتاژ - // //dswrec[24] = "0"; - // ////کد شغل - // //dswrec[25] = "033022"; - // ////کد ملی - // //dswrec[26] = "2650230614"; - - // //dsw.Write(dswrec); - - - // //var dswrec2 = new DbfRecord(dsw.Header); - // ////کد کارگاه - // //dswrec2[0] = GetSpecifiedCharactes("9008289145", 10); - // ////سال - // //dswrec2[1] = "2"; - // ////ماه - // //dswrec2[2] = "2"; - // ////شماره لیست - // //dswrec2[3] = GetSpecifiedCharactes("01", 12); - // ////شماره بیمه - // //dswrec2[4] = GetSpecifiedCharactes("34157806", 8); - // //// نام - // //dswrec2[5] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("پیمان", 100), - // // IranSystemNumbers.DontConvert); - // ////خانوادگی نام - // //dswrec2[6] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("افشاری بجاربنه", 100), - // // IranSystemNumbers.DontConvert); - // ////پدر نام - // //dswrec2[7] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("علیرضا", 100), - // // IranSystemNumbers.DontConvert); - // ////شماره شناسنامه - // //dswrec2[8] = "2580900713"; - // ////محل صدور - // //dswrec2[9] = - // // ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("رشت", 100), IranSystemNumbers.DontConvert); - // //; - // ////تاریخ صدور - // //dswrec2[10] = ""; - // ////تاریخ تولد - // //dswrec2[11] = "13750229"; - // ////جنسیت - // //dswrec2[12] = - // // ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("مرد", 3), IranSystemNumbers.DontConvert); - // ////ملیت - // //dswrec2[13] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("ایرانی", 10), - // // IranSystemNumbers.DontConvert); - // ////شرح شغل - // //dswrec2[14] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("کارشناس نرم افزار کامپیوتر", 100), - // // IranSystemNumbers.DontConvert); - // ////تاریخ شروع بکار - // //dswrec2[15] = "14010701"; - // ////تاریخ ترک کار - // //dswrec2[16] = ""; - // ////تعداد روزهای کارکرد - // //dswrec2[17] = "31"; - // ////دستمزد روزانه - // //dswrec2[18] = "1769428"; - // ////دستمزد مااهانه - // //dswrec2[19] = "54852268"; - // ////مزایای ماهانه - // //dswrec2[20] = "20000000"; - // ////دستمزد و مزایای ماهانه مشمول - // //dswrec2[21] = "74852268"; - // ////جمع کل دستمزد و مزایای ماهانه مسمول غیرمشمول - // //dswrec2[22] = "74852268"; - // ////حق بیمه سهم بیمه شده - // //dswrec2[23] = "5239659"; - // ////نرخ پورسانتاژ - // //dswrec2[24] = "0"; - // ////کد شغل - // //dswrec2[25] = "033022"; - // ////کد ملی - // //dswrec2[26] = "2580900713"; - - // //dsw.Write(dswrec2); - - - // //var dswrec3 = new DbfRecord(dsw.Header); - // ////کد کارگاه - // //dswrec3[0] = GetSpecifiedCharactes("9008289145", 10); - // ////سال - // //dswrec3[1] = "2"; - // ////ماه - // //dswrec3[2] = "2"; - // ////شماره لیست - // //dswrec3[3] = GetSpecifiedCharactes("01", 12); - // ////شماره بیمه - // //dswrec3[4] = GetSpecifiedCharactes("48076618", 8); - // //// نام - // //dswrec3[5] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("فاطمه", 100), - // // IranSystemNumbers.DontConvert); - // ////خانوادگی نام - // //dswrec3[6] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("پادکان", 100), - // // IranSystemNumbers.DontConvert); - // ////پدر نام - // //dswrec3[7] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("محمدفرشاد", 100), - // // IranSystemNumbers.DontConvert); - // ////شماره شناسنامه - // //dswrec3[8] = "2581230231"; - // ////محل صدور - // //dswrec3[9] = - // // ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("رشت", 100), IranSystemNumbers.DontConvert); - // //; - // ////تاریخ صدور - // //dswrec3[10] = ""; - // ////تاریخ تولد - // //dswrec3[11] = "13780926"; - // ////جنسیت - // //dswrec3[12] = - // // ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("زن", 3), IranSystemNumbers.DontConvert); - // ////ملیت - // //dswrec3[13] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("ایرانی", 10), - // // IranSystemNumbers.DontConvert); - // ////شرح شغل - // //dswrec3[14] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("کارشناس نرم افزار کامپیوتر", 100), - // // IranSystemNumbers.DontConvert); - // ////تاریخ شروع بکار - // //dswrec3[15] = "14010701"; - // ////تاریخ ترک کار - // //dswrec3[16] = ""; - // ////تعداد روزهای کارکرد - // //dswrec3[17] = "31"; - // ////دستمزد روزانه - // //dswrec3[18] = "1769428"; - // ////دستمزد مااهانه - // //dswrec3[19] = "54852268"; - // ////مزایای ماهانه - // //dswrec3[20] = "20000000"; - // ////دستمزد و مزایای ماهانه مشمول - // //dswrec3[21] = "74852268"; - // ////جمع کل دستمزد و مزایای ماهانه مسمول غیرمشمول - // //dswrec3[22] = "74852268"; - // ////حق بیمه سهم بیمه شده - // //dswrec3[23] = "5239659"; - // ////نرخ پورسانتاژ - // //dswrec3[24] = "0"; - // ////کد شغل - // //dswrec3[25] = "001094"; - // ////کد ملی - // //dswrec3[26] = "2581230231"; - - // //dsw.Write(dswrec3); - - // dsw.WriteHeader(); - - // dsw.Close(); - // } - - // return true; - // } - // catch (Exception er) { return false; } - //} - - //public IActionResult OnGetEdit(long id) - //{ - // var insurance = _insuranceListApplication.GetDetailsForEdit(id); - // workshop = _workshopApplication.GetDetails(workshopId_); - // var workshopObj = workshop; - // insurance.WorkshopName = workshopObj == null ? string.Empty : workshopObj.WorkshopFullName; - // insurance.TypeOfInsuranceSend = workshopObj.TypeOfInsuranceSend; - // insurance.Population = workshopObj.Population; - // insurance.FixedSalary = workshopObj.FixedSalary; - // insurance.InsuranceJobId = workshopObj.InsuranceJobId; - // // workshopList = workshopList.Where(x => !string.IsNullOrWhiteSpace(x.TypeOfInsuranceSend) && x.TypeOfInsuranceSend != "false").ToList(); - // //insurance.WorkShopSelectList = new SelectList(workshopList, "Id", "WorkshopFullName"); - // //insurance.YearList = _yearlySalaryApplication.GetYears(); - - // return Partial("Edit", insurance); - //} - - //public IActionResult OnGetEmployeeListForEdit(EmployeeForEditInsuranceListSearchModel searchModel) - //{ - // var result = _insuranceListApplication.SearchEmployeeListForEditByInsuranceListId(searchModel); - // return Partial("./EmployeeListForEdit", result); - //} - - //public IActionResult OnPostEdit(EditInsuranceList command) - //{ - // //var result =new OperationResult(); - // //result.IsSuccedded = true; - // var result = _insuranceListApplication.Edit(command); - // if (result.IsSuccedded) - // { - // var path = command.InsuranceWorkshopInfo.WorkshopId; - // var directoryPath = $"{_webHostEnvironment.ContentRootPath}\\InsuranceList\\{path}"; - // var monthPath = directoryPath + "\\" + command.Year + "_" + command.Month; - // //if (Directory.Exists(monthPath)) - // // Directory.Delete(monthPath); - - // var filePathDSKKAR00 = monthPath + "\\DSKKAR00.dbf"; - // if (System.IO.File.Exists(filePathDSKKAR00)) - // System.IO.File.Delete(filePathDSKKAR00); - - - // var filePathDSKWOR00 = monthPath + "\\DSKWOR00.dbf"; - // if (System.IO.File.Exists(filePathDSKWOR00)) - // System.IO.File.Delete(filePathDSKWOR00); - // var saveFileResult = SaveFile(command); - // if (saveFileResult) - // { - // result.IsSuccedded = true; - // result.Message = "ویرایش اطلاعات با موفقیت انجام شد"; - // } - // else - // { - // result.Failed("ایجاد فایل بیمه با خطا مواجه شد"); - // } - // } - - // return new JsonResult(result); - //} - - //public IActionResult OnGetInsuranceSummary(long id) - //{ - // var insurance = _insuranceListApplication.GetDetails(id); - // return Partial("InsuranceSummary", insurance); - //} - - //public IActionResult OnGetInsuranceConfirm(long id) - //{ - // var insurance = _insuranceListApplication.GetDetails(id); - // return Partial("InsuranceConfirm", insurance); - //} - //public IActionResult OnGetInspectionReport(long id) - //{ - // var insurance = _insuranceListApplication.GetDetails(id); - // return Partial("InspectionReport", insurance); - //} - - - //public IActionResult OnPostMonthlySalary(string dailyWage, string workingDays, string insuranceShare, string benefitsIncludedContinuous, string jobId, string housingAllowance, string includeStatus, string consumableItems, string endMonthCurrentDay) - //{ - - // double benefitsIncludedContinuousL = benefitsIncludedContinuous.MoneyToDouble(); - // double sum = consumableItems.MoneyToDouble() + housingAllowance.MoneyToDouble(); - // long workingDaysL = Convert.ToInt64(workingDays); - // long endMonthCurrentDayL = Convert.ToInt64(endMonthCurrentDay); - // long jobIdL = Convert.ToInt64(jobId); - // long includeStatusL = Convert.ToInt64(includeStatus); - // double dailyWageL = dailyWage.MoneyToDouble(); - - - // if (workingDaysL == endMonthCurrentDayL) - // { - // benefitsIncludedContinuousL = sum; - // } - - // if (workingDaysL < endMonthCurrentDayL) - // { - // if (endMonthCurrentDayL == 29) - // endMonthCurrentDayL = 30; - // var a = (sum * workingDaysL) / endMonthCurrentDayL; - // benefitsIncludedContinuousL = _insuranceListApplication.GetRoundValue(a); - // } - // //if (dailyWageL == 0) - // //{ - // // benefitsIncludedContinuousL = 0; - // //} - // if ((includeStatusL == 0 && (jobIdL == 10 || jobIdL == 17 || jobIdL == 18 || jobIdL == 16)) || (includeStatusL == 1 && jobIdL == 10))// 10 --> karfarma - // { - // benefitsIncludedContinuousL = 0; - - // } - // double monthlySalaryL = workingDaysL * dailyWageL; - // double insuranceShareL = ((benefitsIncludedContinuousL + monthlySalaryL) * 7) / 100; - // insuranceShareL = _insuranceListApplication.GetRoundValue(insuranceShareL); - - - // //var persianBefore = ""; - // //var year = Convert.ToInt32(date.Substring(0, 4)); - // //var month = Convert.ToInt32(date.Substring(5, 2)); - // //var day = Convert.ToInt32(date.Substring(8, 2)); - // //var persianDate = new PersianDateTime(year, month, day); - // //var persianBeforeDate = persianDate.AddDays(-1); - // //persianBefore = persianBeforeDate.ToString("yyyy/MM/dd"); - - // if (benefitsIncludedContinuousL == 0 && monthlySalaryL == 0 && insuranceShareL == 0 && dailyWageL == 0) - // { - // workingDaysL = 0; - // } - // if (benefitsIncludedContinuousL == 0 && monthlySalaryL == 0 && insuranceShareL == 0 && workingDaysL == 0) - // { - // dailyWageL = 0; - // } - // return new JsonResult(new - // { - // monthlySalary = monthlySalaryL.ToMoney(), - // benefitsIncludedContinuous = benefitsIncludedContinuousL.ToMoney(), - // insuranceShare = insuranceShareL.ToMoney(), - // workingDay = workingDaysL, - // dailyWag = dailyWageL.ToMoney(), - // }); - //} - - //public IActionResult OnPostComputeInsuranceList(List employeeDetailsForInsuranceList, string typeOfInsuranceSendWorkshop) - //{ - // double sumOfEmployees = employeeDetailsForInsuranceList.Count(); - // double included = 0;//مشمول - // double sumOfWorkingDays = 0; - // double benefitsIncludedNonContinuous = 0;//مشمول غیر مستمر - // double sumOfSalaries = 0; - // double sumOfDailyWage = 0; - // double insuredShare = 0; - // double employerShare = 0;//سهم بیمه کارفرما - // double sumOfIncluded = 0; - // double unEmploymentInsurance = 0;//سهم بیمه بیکاری - // double monthlyBenefits = 0;//مزایای ماهیانه - // double sumForunEmploymentInsurance = 0; - // double benefitsIncludedContinuous = 0; - // double sumOfIncludedKarfarma = 0; - // bool hasKarfarma = false; - // double countWithoutLeft = 0; - - // for (int i = 0; i < employeeDetailsForInsuranceList.Count; i++) - // { - - // if (!string.IsNullOrWhiteSpace(employeeDetailsForInsuranceList[i].LeftWorkDate)) - // { - // countWithoutLeft = countWithoutLeft + 1; - // } - - - // // if (employeeDetailsForInsuranceList[i].IncludeStatus && (employeeDetailsForInsuranceList[i].JobId == 10 || employeeDetailsForInsuranceList[i].JobId == 17 || employeeDetailsForInsuranceList[i].JobId == 18 || employeeDetailsForInsuranceList[i].JobId == 16))// 10 --> karfarma - // if (!employeeDetailsForInsuranceList[i].IncludeStatus && (employeeDetailsForInsuranceList[i].JobCode == "027079" || employeeDetailsForInsuranceList[i].JobCode == "024398" || employeeDetailsForInsuranceList[i].JobCode == "011015" || employeeDetailsForInsuranceList[i].JobCode == "020010"))// 10 --> karfarma - // { - // benefitsIncludedContinuous = 0; - // sumForunEmploymentInsurance = sumForunEmploymentInsurance; - // } - // else - // { - // sumForunEmploymentInsurance = sumForunEmploymentInsurance + employeeDetailsForInsuranceList[i].BenefitsIncludedContinuous; - // } - // //if (employeeDetailsForInsuranceList[i].JobId == 10)//کارفرما - // if (employeeDetailsForInsuranceList[i].JobCode == "024398")//کارفرما - // { - // hasKarfarma = true; - // sumOfIncludedKarfarma = employeeDetailsForInsuranceList[i].BenefitsIncludedContinuous; - // } - - // sumOfWorkingDays = sumOfWorkingDays + employeeDetailsForInsuranceList[i].WorkingDays; - // sumOfDailyWage = sumOfDailyWage + employeeDetailsForInsuranceList[i].DailyWage; - // sumOfSalaries = sumOfSalaries + employeeDetailsForInsuranceList[i].MonthlySalary; - // monthlyBenefits = monthlyBenefits + +employeeDetailsForInsuranceList[i].MonthlyBenefits; - // sumOfIncluded = sumOfIncluded + employeeDetailsForInsuranceList[i].BenefitsIncludedContinuous; - // benefitsIncludedNonContinuous = benefitsIncludedNonContinuous + employeeDetailsForInsuranceList[i].BenefitsIncludedNonContinuous; - // insuredShare = insuredShare + employeeDetailsForInsuranceList[i].InsuranceShare; - - // } - - // employerShare = GetRoundValueWhitGovermentlist((sumOfIncluded * 20) / 100, typeOfInsuranceSendWorkshop); - // unEmploymentInsurance = GetRoundValueWhitGovermentlist((sumForunEmploymentInsurance * 3) / 100, typeOfInsuranceSendWorkshop); - - // if (typeOfInsuranceSendWorkshop == "Govermentlist" && (sumOfEmployees - countWithoutLeft) <= 5 && !hasKarfarma) - // { //console.log(1); - // employerShare = 0; - // } - - // if (typeOfInsuranceSendWorkshop == "Govermentlist" && (sumOfEmployees - countWithoutLeft) <= 6 && hasKarfarma) - // { //console.log(sumOfIncludedKarfarma); - // var result = (sumOfIncludedKarfarma * 20) / 100; - // employerShare = GetRoundValueWhitGovermentlist(result, typeOfInsuranceSendWorkshop); - // } - // if (typeOfInsuranceSendWorkshop == "Govermentlist" && (sumOfEmployees - countWithoutLeft) >= 6 && !hasKarfarma) - // { - // //ابتدا جمع کل مزایا به دست می آید - // //جمع کل مزایا تقسیم بر تعداد کارگران منهای کسانی که ترک کار کرده اند. - // //حاصل عبارت بالا در 5 ضرب میشو یعنی میانگینی برای محاسبه قیمت 5 نفر حساب می کنیم تا از طریق دولت پرداخت شود - // var result = (sumOfIncluded - ((sumOfIncluded / (sumOfEmployees - countWithoutLeft)) * 5)) * 20 / 100; - // employerShare = GetRoundValueWhitGovermentlist(result, typeOfInsuranceSendWorkshop); - // // employerShare =getRoundValue(((sumOfIncluded/sumOfEmployees)*(sumOfEmployees-5))*20/100); - // } - // if (typeOfInsuranceSendWorkshop == "Govermentlist" && (sumOfEmployees - countWithoutLeft) > 6 && hasKarfarma) - // { // console.log(4); - // var sum = sumOfIncluded - sumOfIncludedKarfarma;//ستون مربوط به کارفرما محاسبه نمی شود - // var result = ((sum - ((sum / ((sumOfEmployees - countWithoutLeft) - 1)) * 5)) + sumOfIncludedKarfarma) * 20 / 100; - // employerShare = GetRoundValueWhitGovermentlist(result, typeOfInsuranceSendWorkshop); - - - // } - - - // return new JsonResult(new - // { - // SumOfEmployees = sumOfEmployees, - // SumOfSalaries = sumOfSalaries.ToMoney(), - // SumOfDailyWage = sumOfDailyWage.ToMoney(), - // SumOfWorkingDays = sumOfWorkingDays, - // SumOfBenefitsIncluded = monthlyBenefits.ToMoney(), - // Included = sumOfIncluded.ToMoney(), - // IncludedAndNotIncluded = (sumOfIncluded + benefitsIncludedNonContinuous).ToMoney(), - // InsuredShare = insuredShare.ToMoney(), - // EmployerShare = employerShare.ToMoney(), - // UnEmploymentInsurance = unEmploymentInsurance.ToMoney(), - // }); - - //} - //public double GetRoundValueWhitGovermentlist(double value, string type) - //{ - // string strValue = value.ToString(); - // if (strValue.IndexOf('.') > -1) - // { - // string a = strValue.Substring(strValue.IndexOf('.') + 1, 1); - // if (type == "Govermentlist") - // { - // if (int.Parse(a) >= 4) - // { - // return (Math.Round(value, MidpointRounding.ToPositiveInfinity)); - // } - // else - // { - // return (Math.Round(value, MidpointRounding.ToNegativeInfinity)); - // } - // } - // else - // { - // if (int.Parse(a) > 5) - // { - // return (Math.Round(value, MidpointRounding.ToPositiveInfinity)); - // } - // else - // { - // return (Math.Round(value, MidpointRounding.ToNegativeInfinity)); - // } - // } - // } - - // return value; - //} - - #endregion -} \ No newline at end of file + public class IndexModel : PageModel + { + + public InsuranceListSearchModel SearchModel; + public List InsurancList; + public long WorkshopId; + public string WorkshopName; + public List YearlyList; + public string Year; + public string Month; + public string Sorting; + public int PageIndex; + public string TypeOfInsurance; + private readonly IJobApplication _jobApplication; + private readonly IInsuranceListApplication _insuranceListApplication; + private readonly IWorkshopApplication _workshopApplication; + private readonly IYearlySalaryApplication _yearlySalaryApplication; + private readonly IEmployerApplication _employerApplication; + private readonly IInsuranceWorkshopInfoApplication _insuranceWorkshopInfoApplication; + private readonly IEmployeeApplication _employeeApplication; + //private readonly IInsuranceEmployeeInfoApplication _insuranceEmployeeInfoApplication; + private readonly IWebHostEnvironment _webHostEnvironment; + private readonly IPasswordHasher _passwordHasher; + + + + public string CurrentYear_; + public string BeforCurrentMonth_; + + public static long workshopId_ { get; set; } + //public static string workshopName { get; set; } + //public static string typeOfInsuranceSend { get; set; } + //public static bool fixedSalary { get; set; } + //public static string workshopCode { get; set; } + //public static string WorkshopFullName { get; set; } + + public EditWorkshop workshop; + + public IndexModel(IInsuranceListApplication insuranceListApplication, IWorkshopApplication workshopApplication, IYearlySalaryApplication yearlySalaryApplication, IEmployerApplication employerApplication, IInsuranceWorkshopInfoApplication insuranceWorkshopInfoApplication, IEmployeeApplication employeeApplication, IJobApplication jobApplication, IWebHostEnvironment webHostEnvironment, IPasswordHasher passwordHasher)// , IInsuranceEmployeeInfoApplication insuranceEmployeeInfoApplication ) + { + _jobApplication = jobApplication; + _insuranceListApplication = insuranceListApplication; + _workshopApplication = workshopApplication; + _yearlySalaryApplication = yearlySalaryApplication; + _employerApplication = employerApplication; + _insuranceWorkshopInfoApplication = insuranceWorkshopInfoApplication; + _employeeApplication = employeeApplication; + //_insuranceEmployeeInfoApplication = insuranceEmployeeInfoApplication; + _webHostEnvironment = webHostEnvironment; + _passwordHasher = passwordHasher; + } + + public IActionResult OnGet( InsuranceListSearchModel searchModel) + { + if (User.Identity.IsAuthenticated) + { + var workshopSlugCliam = User.FindFirstValue("WorkshopSlug"); + var workshopId = _passwordHasher.SlugDecrypt(workshopSlugCliam); + if (workshopId > 0) + { + searchModel.Sorting = string.IsNullOrWhiteSpace(searchModel.Sorting) + ? "CreationDate-Max" + : searchModel.Sorting; + searchModel.PageIndex = 0; + Year = searchModel.Year; + Month = searchModel.Month; + WorkshopId = workshopId == 0 ? searchModel.WorkshopId : workshopId; + searchModel.WorkshopId = WorkshopId; + Sorting = string.IsNullOrWhiteSpace(searchModel.Sorting) ? "CreationDate-Max" : searchModel.Sorting; + var workshopInfo = _workshopApplication.GetWorkshopInfo(WorkshopId); + //workshop = _workshopApplication.GetDetails(workshopId_); + WorkshopName = workshopInfo.WorkshopFullName; + searchModel.FixedSalary = workshopInfo.FixedSalary; + searchModel.TypeOfInsuranceSend = workshopInfo.TypeOfInsuranceSend; + searchModel.WorkShopCode = workshopInfo.InsuranceCode; + TypeOfInsurance = workshopInfo.InsuranceCode; + + #region OldConvertYearAndMonth + + //string date = DateTime.Now.ToFarsi(); + //var year = Convert.ToInt32(date.Substring(0, 4)); + //var month = Convert.ToInt32(date.Substring(5, 2)); + //var day = Convert.ToInt32(date.Substring(8, 2)); + //var persianDate = new PersianDateTime(year, month, day); + //string persianBeforeDate = persianDate.AddMonths(-1).ToString("yyyy/MM/dd"); + //BeforCurrentMonth_ = persianBeforeDate.Substring(5, 2); + //CurrentYear_ = persianBeforeDate.Substring(0, 4); + + #endregion + + InsurancList = _insuranceListApplication.SearchForClient(searchModel); + + YearlyList = + _yearlySalaryApplication.GetYears(); + SearchModel = new InsuranceListSearchModel() + { + Year = string.IsNullOrWhiteSpace(searchModel.Year) ? " " : searchModel.Year, + Month = string.IsNullOrWhiteSpace(searchModel.Month) ? " " : searchModel.Month, + Sorting = searchModel.Sorting, + + }; + return Page(); + } + else + { + return Redirect("error/404"); + } + } + else + { + return Redirect("error/404"); + } + } + + #region PrintOne + + public IActionResult OnGetPrintOne(long id) + { + var insurance = _insuranceListApplication.GetDetails(id); + return Partial("PrintOne", insurance); + } + + #endregion + + #region PrintOneMobile + + public IActionResult OnGetPrintOneMobile(long id) + { + var insurance = _insuranceListApplication.GetDetails(id); + return Partial("PrintOneMobile", insurance); + } + + #endregion + #region OldClientByHeydari + + //public IActionResult OnGetSearch(InsuranceListSearchModel searchModel) + //{ + + // workshop = _workshopApplication.GetDetails(workshopId_); + // searchModel.FixedSalary = workshop.FixedSalary; + // searchModel.WorkShopName = workshop.WorkshopName; + // searchModel.TypeOfInsuranceSend = workshop.TypeOfInsuranceSend; + // searchModel.WorkShopCode = workshop.InsuranceCode; + // searchModel.WorkshopId = workshopId_; + + + + // var searchResult = _insuranceListApplication.SearchForClient(searchModel); + + // foreach (var item in searchResult) + // { + // item.Month = item.Month.GetMonthByNumber(); + // } + + // var result = new CompanyManagment.App.Contracts.InsuranceList.MainViewModel(); + // result.MainList = searchResult; + + + // return Partial("./MainSearch", result); + //} + //public IActionResult OnGetCreate() + //{ + // string date = DateTime.Now.ToFarsi(); + // var year = Convert.ToInt32(date.Substring(0, 4)); + // var month = Convert.ToInt32(date.Substring(5, 2)); + // var day = Convert.ToInt32(date.Substring(8, 2)); + // var persianDate = new PersianDateTime(year, month, day); + // string persianBeforeDate = persianDate.AddMonths(-1).ToString("yyyy/MM/dd"); + // //var workshopList = _workshopApplication.GetWorkshopAccount().Where(x => !string.IsNullOrWhiteSpace(x.TypeOfInsuranceSend) && x.TypeOfInsuranceSend != "false").ToList(); + // workshop = _workshopApplication.GetDetails(workshopId_); + // var command = new CreateInsuranceList() + // { + // //WorkShopSelectList = new SelectList(workshopList, "Id", "WorkshopFullName"), + // YearList = _yearlySalaryApplication.GetYears(), + // BeforCurrentMonth = persianBeforeDate.Substring(5, 2), + // CurrentYear = persianBeforeDate.Substring(0, 4), + // WorkshopId = workshopId_, + // WorkshopName = workshop.WorkshopFullName + // }; + // return Partial("./Create", command); + //} + + //public IActionResult OnPostCreate(CreateInsuranceList command) + //{ + // //var result =new OperationResult(); + // //result.IsSuccedded = true; + // var result = _insuranceListApplication.Create(command); + // if (result.IsSuccedded) + // { + // var saveFileResult = SaveFile(command); + // if (saveFileResult) + // { + // result.IsSuccedded = true; + // result.Message = "ثبت اطلاعات با موفقیت انجام شد"; + // } + // else + // { + // result.Failed("ایجاد فایل بیمه با خطا مواجه شد"); + // } + // } + // //else + // //{ + // // result.Failed("ثبت اطلاعات با خطا مواجه شد"); + // //} + // return new JsonResult(result); + //} + + //public IActionResult OnPostGetEmployerName(long workshopId) + //{ + // string names = ""; + // var employerList = _employerApplication.GetEmployerByWorkshopId(workshopId); + // var workshopInfo = _insuranceWorkshopInfoApplication.GetDetails(workshopId); + // // var personelInfo = _employeeApplication.(workshopId); + + // string isLegal = employerList.FirstOrDefault()?.IsLegal; + // bool boolIsLegal = (isLegal == "حقوقی" ? true : false); + + // foreach (var item in employerList) + // { + // if (boolIsLegal) + // { + // names = (item.EmployerLName != "#" ? (item.FName + " " + item.EmployerLName) : item.LName); + // } + // else + // { + + // names = names + item.EmployerFullName + ","; + // } + // } + + // if (!boolIsLegal) + // names = names.Substring(0, names.Length - 1); + + // return new JsonResult(new + // { + // EmployerNames = names, + // WorkshopInfo = workshopInfo, + // IsLegal = boolIsLegal + // }); + //} + + + //public IActionResult OnGetEmployeeSearch(EmployeeForCreateInsuranceListSearchModel searchModel) + //{ + + // var result = _insuranceListApplication.SearchEmployeeForCreateInsuranceList(searchModel); + // return Partial("./EmployeeDatatable", result); + //} + + //public IActionResult OnPostCreateEmployeeDetailsInfo(EmployeeDetailsForInsuranceListViewModel command) + //{ + + // TempData["EmployeeDetails"] = command; + // var result = new OperationResult(); + // if (command.InsuranceEmployeeInformationId == 0) + // result = _insuranceListApplication.CreateEmployeeDetailsInfo(command); + // else + // result = _insuranceListApplication.EditEmployeeDetailsInfo(command); + + // return new JsonResult(result); + //} + + //public IActionResult OnPostJobList() + //{ + // var jobs = _jobApplication.GetJob(); + // return new JsonResult(new + // { + // IsSuccedded = true, + // jobList = jobs, + // }); + //} + + //public IActionResult OnPostRemoveInsuranceList(long id, string pathDSKKAR00, string pathDSKWOR00) + //{ + // var result = _insuranceListApplication.Remove(id); + // if (result.IsSuccedded) + // { + // pathDSKKAR00 = pathDSKKAR00.Replace("-", "\\"); + // var filePathDSKKAR00 = $"{_webHostEnvironment.ContentRootPath}\\InsuranceList\\{pathDSKKAR00}"; + // if (System.IO.File.Exists(filePathDSKKAR00)) + // System.IO.File.Delete(filePathDSKKAR00); + + // pathDSKWOR00 = pathDSKWOR00.Replace("-", "\\"); + // var filePathDSKWOR00 = $"{_webHostEnvironment.ContentRootPath}\\InsuranceList\\{pathDSKWOR00}"; + // if (System.IO.File.Exists(filePathDSKWOR00)) + // System.IO.File.Delete(filePathDSKWOR00); + // } + // return new JsonResult(result); + //} + + //public IActionResult OnPostConfirmInsuranceList(long id) + //{ + // var result = _insuranceListApplication.ConfirmInsuranceList(id); + // return new JsonResult(result); + //} + + //public IActionResult OnGetDownloadFile(string path, string fileName) + //{ + // //var path= "11\\1402_03\\DSKWOR00.dbf"; + // // Replace "file.dbf" with the name of your .dbf file + // var filePath = $"{_webHostEnvironment.ContentRootPath}\\InsuranceList\\{path}"; ; + + // // Read the file content into a byte array + // byte[] fileContent = System.IO.File.ReadAllBytes(filePath); + + // // Return the file content as a FileResult with the appropriate MIME type and file name + // return File(fileContent, "application/dbase", fileName); + //} + //private string GetSpecifiedCharactes(string str, int MaxLength) + //{ + // return str.Length <= MaxLength ? str : str.Substring(0, MaxLength); + //} + //private bool SaveFile(CreateInsuranceList createInsuranceList) + //{ + // try + // { + // //var path = $"profilePhotos"; + // var path = createInsuranceList.InsuranceWorkshopInfo.WorkshopId; + // var directoryPath = $"{_webHostEnvironment.ContentRootPath}\\InsuranceList\\{path}"; + // if (!Directory.Exists(directoryPath)) + // Directory.CreateDirectory(directoryPath); + + // //ایجاد پوشه با توجه به هر ماه و سال + // var monthPath = directoryPath + "\\" + createInsuranceList.Year + "_" + createInsuranceList.Month; + // if (!Directory.Exists(monthPath)) + // Directory.CreateDirectory(monthPath); + + // var currentdate = DateTime.Now; + // var currentDay = Convert.ToInt32(currentdate.ToFarsi().Substring(8, 2)); + // ////ایجاد پوشه با توجه به هر روز و ساعت و دقیقه و ثانیه + // //var dayPath = monthPath +"\\"+ currentDay+"_"+ currentdate.Hour + "_" + currentdate.Month + "_" + currentdate.Second; + // //if (!Directory.Exists(dayPath)) + // // Directory.CreateDirectory(dayPath); + // //فعلا قرار شد روی فایل قبلی ریپلیس بشه + // // string fileName = currentDay + "_" + currentdate.Hour + "_" + currentdate.Month + "_" + currentdate.Second +"_"; + // if (createInsuranceList.InsuranceWorkshopInfo != null) + // { + // var odbf = new DbfFile(Encoding.GetEncoding(1256)); + // odbf.Open(Path.Combine(monthPath, "DSKKAR00.dbf"), FileMode.Create); + // //کد کارگاه + // odbf.Header.AddColumn(new DbfColumn("DSK_ID", DbfColumn.DbfColumnType.Character, 10, 0)); + // //نام کارگاه + // odbf.Header.AddColumn(new DbfColumn("DSK_NAME", DbfColumn.DbfColumnType.Character, 100, 0)); + // //نام کارفرما + // odbf.Header.AddColumn(new DbfColumn("DSK_FARM", DbfColumn.DbfColumnType.Character, 100, 0)); + // //نام آدرس + // odbf.Header.AddColumn(new DbfColumn("DSK_ADRS", DbfColumn.DbfColumnType.Character, 100, 0)); + // //نوع لیست + // odbf.Header.AddColumn(new DbfColumn("DSK_KIND", DbfColumn.DbfColumnType.Number, 1, 0)); + // //سال عملکرد + // odbf.Header.AddColumn(new DbfColumn("DSK_YY", DbfColumn.DbfColumnType.Number, 2, 0)); + // //ماه عملکرد + // odbf.Header.AddColumn(new DbfColumn("DSK_MM", DbfColumn.DbfColumnType.Number, 2, 0)); + // //شماره لیست + // odbf.Header.AddColumn(new DbfColumn("DSK_LISTNO", DbfColumn.DbfColumnType.Character, 12, 0)); + // //شرح لیست + // odbf.Header.AddColumn(new DbfColumn("DSK_DISC", DbfColumn.DbfColumnType.Character, 100, 0)); + // //تعداد کارکنان + // odbf.Header.AddColumn(new DbfColumn("DSK_NUM", DbfColumn.DbfColumnType.Number, 5, 0)); + // //تعداد کارکنان + // odbf.Header.AddColumn(new DbfColumn("DSK_TDD", DbfColumn.DbfColumnType.Number, 6, 0)); + // //مجموع دستمزد روزانه + // odbf.Header.AddColumn(new DbfColumn("DSK_TROOZ", DbfColumn.DbfColumnType.Number, 12, 0)); + // //مجموع دستمزد ماهانه + // odbf.Header.AddColumn(new DbfColumn("DSK_TMAH", DbfColumn.DbfColumnType.Number, 12, 0)); + // //مجموع مزایای ماهانه + // odbf.Header.AddColumn(new DbfColumn("DSK_TMAZ", DbfColumn.DbfColumnType.Number, 12, 0)); + // //مجموع دستمزد و مزایای ماهانه مشمول + // odbf.Header.AddColumn(new DbfColumn("DSK_TMASH", DbfColumn.DbfColumnType.Number, 12, 0)); + // // مجموع کل دستمزد و مزایای ماهانه مشمول و غیر مشمول + // odbf.Header.AddColumn(new DbfColumn("DSK_TTOTL", DbfColumn.DbfColumnType.Number, 12, 0)); + // //مجموع حق بیمه سهم بیمه شده + // odbf.Header.AddColumn(new DbfColumn("DSK_TBIME", DbfColumn.DbfColumnType.Number, 12, 0)); + // //مجموع حق بیمه سهم کارفرما + // odbf.Header.AddColumn(new DbfColumn("DSK_TKOSO", DbfColumn.DbfColumnType.Number, 12, 0)); + // //مجموع حق بیمه بیکاری + // odbf.Header.AddColumn(new DbfColumn("DSK_BIC", DbfColumn.DbfColumnType.Number, 12, 0)); + // //نرخ حق بیمه + // odbf.Header.AddColumn(new DbfColumn("DSK_RATE", DbfColumn.DbfColumnType.Number, 5, 0)); + // //نرخ پورسانتاژ + // odbf.Header.AddColumn(new DbfColumn("DSK_PRATE", DbfColumn.DbfColumnType.Number, 2, 0)); + // //نرخ مشاغل سخت زیان آور + // odbf.Header.AddColumn(new DbfColumn("DSK_BIMH", DbfColumn.DbfColumnType.Number, 12, 0)); + // //ردیف پیمان + // odbf.Header.AddColumn(new DbfColumn("MON_PYM", DbfColumn.DbfColumnType.Character, 3, 0)); + // var orec = new DbfRecord(odbf.Header); + + // //کد کارگاه + // orec[0] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.InsuranceCode, 10); + // orec[1] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.WorkshopName, 100), IranSystemNumbers.DontConvert); + // orec[2] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.EmployerName, 100), IranSystemNumbers.DontConvert); + // orec[3] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.Address, 100), IranSystemNumbers.DontConvert); + // //orec[3] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("رشت - بلوار شهدای گمنام - کوچه شهید علی قربانی - ساختمان پیام نور - طبقه اول واحد 2", 100), IranSystemNumbers.DontConvert); + // // نوع لیست + // orec[4] = "0"; + // //سال + // orec[5] = Convert.ToInt32(createInsuranceList.Year.Substring(2, 2)).ToString(); + // //ماه + // orec[6] = Convert.ToInt32(createInsuranceList.Month).ToString(); + // //شماره لیست + // orec[7] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.ListNumber, 12); + // //شرح لیست + // orec[8] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("", 100), IranSystemNumbers.DontConvert); + // //تعداد کرکنان + // orec[9] = createInsuranceList.SumOfEmployees.ToString(); + // //مجموع روزهای کارکرد + // orec[10] = createInsuranceList.SumOfWorkingDays.ToString(); + // //مجموع دستمزد روزانه + // orec[11] = createInsuranceList.SumOfDailyWage.ToString(); + // //مجموع دستمزد ماهانه + // orec[12] = createInsuranceList.SumOfSalaries.ToString(); + // //مجموع مزایای ماهانه مشمول + // orec[13] = createInsuranceList.SumOfBenefitsIncluded.ToString(); + // //مجموع دستمزد و مزایای ماهانه مشمول + // orec[14] = createInsuranceList.Included.ToString(); + // //مجموع کل دستمزد و مزایای ماهانه مشمول و غیر مشمول + // orec[15] = createInsuranceList.IncludedAndNotIncluded.ToString(); + // // مجموع حق بیمه سهم بیمه شده + // orec[16] = createInsuranceList.InsuredShare.ToString(); + // //مجموع حق بیمه سهم کارفرما + // orec[17] = createInsuranceList.EmployerShare.ToString(); //"44911361"; + // //مجموع حق بیمه بیکاری + // orec[18] = createInsuranceList.UnEmploymentInsurance.ToString(); + // //نرخ حق بیمه + // orec[19] = "23"; + // //نرخ پورسانتاژ + // orec[20] = "0"; + // //نرخ مشاغل سخت زیان آور + // orec[21] = createInsuranceList.DifficultJobsInsuranc.ToString(); + // //ردیف پیمان + // orec[22] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.AgreementNumber, 12); + // odbf.Write(orec); + // //odbf.Header.RecordCount = 50; + // odbf.WriteHeader(); + // odbf.Close(); + // } + + + // if (createInsuranceList.EmployeeInsurancListDataList != null) + // { + // //لیست پرسنل + // var dsw = new DbfFile(Encoding.GetEncoding(1256)); + // dsw.Open(Path.Combine(monthPath, "DSKWOR00.dbf"), FileMode.Create); + // //کد کارگاه + // dsw.Header.AddColumn(new DbfColumn("DSW_ID", DbfColumn.DbfColumnType.Character, 10, 0)); + // //سال عملکرد + // dsw.Header.AddColumn(new DbfColumn("DSW_YY", DbfColumn.DbfColumnType.Number, 2, 0)); + // //ماه عملکرد + // dsw.Header.AddColumn(new DbfColumn("DSW_MM", DbfColumn.DbfColumnType.Number, 2, 0)); + // //شماره لیست + // dsw.Header.AddColumn(new DbfColumn("DSW_LISTNO", DbfColumn.DbfColumnType.Character, 12, 0)); + // //شماره بیمه + // dsw.Header.AddColumn(new DbfColumn("DSW_ID1", DbfColumn.DbfColumnType.Character, 10, 0)); + // // نام + // dsw.Header.AddColumn(new DbfColumn("DSW_FNAME", DbfColumn.DbfColumnType.Character, 100, 0)); + // // نام خانوادگی + // dsw.Header.AddColumn(new DbfColumn("DSW_LNAME", DbfColumn.DbfColumnType.Character, 100, 0)); + // //نام پدر + // dsw.Header.AddColumn(new DbfColumn("DSW_DNAME", DbfColumn.DbfColumnType.Character, 100, 0)); + // // شماره شناسنامه + // dsw.Header.AddColumn(new DbfColumn("DSW_IDNO", DbfColumn.DbfColumnType.Character, 15, 0)); + // // محل صدور + // dsw.Header.AddColumn(new DbfColumn("DSW_IDPLC", DbfColumn.DbfColumnType.Character, 100, 0)); + // // تاریخ صدور + // dsw.Header.AddColumn(new DbfColumn("DSW_IDATE", DbfColumn.DbfColumnType.Character, 8, 0)); + // // تاریخ تولد + // dsw.Header.AddColumn(new DbfColumn("DSW_BDATE", DbfColumn.DbfColumnType.Character, 8, 0)); + // // جنسیت + // dsw.Header.AddColumn(new DbfColumn("DSW_SEX", DbfColumn.DbfColumnType.Character, 3, 0)); + // // ملیت + // dsw.Header.AddColumn(new DbfColumn("DSW_NAT", DbfColumn.DbfColumnType.Character, 10, 0)); + // // شرح شغل + // dsw.Header.AddColumn(new DbfColumn("DSW_OCP", DbfColumn.DbfColumnType.Character, 100, 0)); + // // تاریخ شروع بکار + // dsw.Header.AddColumn(new DbfColumn("DSW_SDATE", DbfColumn.DbfColumnType.Character, 8, 0)); + // // تاریخ ترک کار + // dsw.Header.AddColumn(new DbfColumn("DSW_EDATE", DbfColumn.DbfColumnType.Character, 8, 0)); + // // تعداد روزهای کارکرد + // dsw.Header.AddColumn(new DbfColumn("DSW_DD", DbfColumn.DbfColumnType.Number, 2, 0)); + // // دستمزد روزانه + // dsw.Header.AddColumn(new DbfColumn("DSW_ROOZ", DbfColumn.DbfColumnType.Number, 12, 0)); + // // دستمزد ماهانه + // dsw.Header.AddColumn(new DbfColumn("DSW_MAH", DbfColumn.DbfColumnType.Number, 12, 0)); + // // مزایای ماهانه + // dsw.Header.AddColumn(new DbfColumn("DSW_MAZ", DbfColumn.DbfColumnType.Number, 12, 0)); + // // جمع دستمزد و مزایای ماهانه مشمول + // dsw.Header.AddColumn(new DbfColumn("DSW_MASH", DbfColumn.DbfColumnType.Number, 12, 0)); + // // جمع کل دستمزد و مزایای ماهانه + // dsw.Header.AddColumn(new DbfColumn("DSW_TOTL", DbfColumn.DbfColumnType.Number, 12, 0)); + // //حق بیمه سهم بیمه شده + // dsw.Header.AddColumn(new DbfColumn("DSW_BIME", DbfColumn.DbfColumnType.Number, 12, 0)); + // //نرخ پورسانتاژ + // dsw.Header.AddColumn(new DbfColumn("DSW_PRATE", DbfColumn.DbfColumnType.Number, 2, 0)); + // // کد شغل + // dsw.Header.AddColumn(new DbfColumn("DSW_JOB", DbfColumn.DbfColumnType.Character, 6, 0)); + // // کد ملی + // dsw.Header.AddColumn(new DbfColumn("PER_NATCOD", DbfColumn.DbfColumnType.Character, 10, 0)); + + // foreach (var item in createInsuranceList.EmployeeInsurancListDataList) + // { + // var employee = createInsuranceList.EmployeeDetailsForInsuranceList.Where(p => p.EmployeeId == item.EmployeeId).FirstOrDefault(); + + // //var employeeObj = _employeeApplication.GetDetails(item.EmployeeId); + + // var dswrec = new DbfRecord(dsw.Header); + // //کد کارگاه + // dswrec[0] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.InsuranceCode, 10); + // //سال + // dswrec[1] = Convert.ToInt32(createInsuranceList.Year.Substring(2, 2)).ToString(); + // //ماه + // dswrec[2] = Convert.ToInt32(createInsuranceList.Month).ToString(); + // //شماره لیست + // dswrec[3] = GetSpecifiedCharactes(createInsuranceList.InsuranceWorkshopInfo.ListNumber, 12); + // //شماره بیمه + // dswrec[4] = GetSpecifiedCharactes(employee.InsuranceCode, 8); + // // نام + // dswrec[5] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.FName, 100), + // IranSystemNumbers.DontConvert); + // //خانوادگی نام + // dswrec[6] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.LName, 100), + // IranSystemNumbers.DontConvert); + // //پدر نام + // dswrec[7] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.FatherName, 100), + // IranSystemNumbers.DontConvert); + // //شماره شناسنامه + // dswrec[8] = employee.IdNumber; + // //محل صدور + // dswrec[9] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.PlaceOfIssue, 100), IranSystemNumbers.DontConvert); + // //تاریخ صدور + // dswrec[10] = (employee.DateOfIssue == "1300/10/11" || string.IsNullOrEmpty(employee.DateOfIssue)) ? "" : employee.DateOfIssue.Replace("/", ""); + // //تاریخ تولد + // dswrec[11] = (employee.DateOfBirth == "1300/10/11" || string.IsNullOrEmpty(employee.DateOfIssue)) ? "" : employee.DateOfBirth.Replace("/", ""); ; + // //جنسیت + // dswrec[12] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.Gender, 3), IranSystemNumbers.DontConvert); + // //ملیت + // //dswrec[13] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("ایرانی", 10), + // dswrec[13] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(employee.Nationality, 10), + // IranSystemNumbers.DontConvert); + // //شرح شغل + // dswrec[14] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes(item.JobName, 100), + // IranSystemNumbers.DontConvert); + // //تاریخ شروع بکار + // dswrec[15] = item.StartWorkDate.ToFarsi().Replace("/", ""); + + // //تاریخ ترک کار + // if (item.LeftWorkDate != null) + // dswrec[16] = item.LeftWorkDate.ToFarsi().Replace("/", ""); + // else + // dswrec[16] = ""; + + // //تعداد روزهای کارکرد + // dswrec[17] = item.WorkingDays.ToString(); + // //دستمزد روزانه + // dswrec[18] = item.DailyWage.ToString(); + // //دستمزد مااهانه + // dswrec[19] = item.MonthlySalary.ToString(); + // //مزایای ماهانه + // dswrec[20] = item.MonthlyBenefits.ToString(); + // //دستمزد و مزایای ماهانه مشمول + // dswrec[21] = item.MonthlyBenefitsIncluded.ToString(); + // //جمع کل دستمزد و مزایای ماهانه مسمول غیرمشمول + // dswrec[22] = item.IncludedAndNotIncluded.ToString(); + // //حق بیمه سهم بیمه شده + // dswrec[23] = item.InsuranceShare.ToString(); + // //نرخ پورسانتاژ + // dswrec[24] = "0"; + // //کد شغل + // dswrec[25] = item.JobCode; + // //کد ملی + // dswrec[26] = employee.NationalCode; + + // dsw.Write(dswrec); + // } + // //var dswrec = new DbfRecord(dsw.Header); + // ////کد کارگاه + // //dswrec[0] = GetSpecifiedCharactes("9008289145", 10); + // ////سال + // //dswrec[1] = "2"; + // ////ماه + // //dswrec[2] = "2"; + // ////شماره لیست + // //dswrec[3] = GetSpecifiedCharactes("01", 12); + // ////شماره بیمه + // //dswrec[4] = GetSpecifiedCharactes("48071464", 8); + // //// نام + // //dswrec[5] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("راضیه", 100), + // // IranSystemNumbers.DontConvert); + // ////خانوادگی نام + // //dswrec[6] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("پیردهقان", 100), + // // IranSystemNumbers.DontConvert); + // ////پدر نام + // //dswrec[7] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("غلام", 100), + // // IranSystemNumbers.DontConvert); + // ////شماره شناسنامه + // //dswrec[8] = "2650230614"; + // ////محل صدور + // //dswrec[9] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("رشت", 100), + // // IranSystemNumbers.DontConvert); + // //; + // ////تاریخ صدور + // //dswrec[10] = "13770805"; + // ////تاریخ تولد + // //dswrec[11] = "13770721"; + // ////جنسیت + // //dswrec[12] = + // // ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("زن", 3), IranSystemNumbers.DontConvert); + // ////ملیت + // //dswrec[13] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("ایرانی", 10), + // // IranSystemNumbers.DontConvert); + // ////شرح شغل + // //dswrec[14] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("کارشناس نرم افزار کامپیوتر", 100), + // // IranSystemNumbers.DontConvert); + // ////تاریخ شروع بکار + // //dswrec[15] = "14000201"; + // ////تاریخ ترک کار + // //dswrec[16] = ""; + // ////تعداد روزهای کارکرد + // //dswrec[17] = "31"; + // ////دستمزد روزانه + // //dswrec[18] = "1769428"; + // ////دستمزد مااهانه + // //dswrec[19] = "54852268"; + // ////مزایای ماهانه + // //dswrec[20] = "20000000"; + // ////دستمزد و مزایای ماهانه مشمول + // //dswrec[21] = "74852268"; + // ////جمع کل دستمزد و مزایای ماهانه مسمول غیرمشمول + // //dswrec[22] = "74852268"; + // ////حق بیمه سهم بیمه شده + // //dswrec[23] = "5239659"; + // ////نرخ پورسانتاژ + // //dswrec[24] = "0"; + // ////کد شغل + // //dswrec[25] = "033022"; + // ////کد ملی + // //dswrec[26] = "2650230614"; + + // //dsw.Write(dswrec); + + + // //var dswrec2 = new DbfRecord(dsw.Header); + // ////کد کارگاه + // //dswrec2[0] = GetSpecifiedCharactes("9008289145", 10); + // ////سال + // //dswrec2[1] = "2"; + // ////ماه + // //dswrec2[2] = "2"; + // ////شماره لیست + // //dswrec2[3] = GetSpecifiedCharactes("01", 12); + // ////شماره بیمه + // //dswrec2[4] = GetSpecifiedCharactes("34157806", 8); + // //// نام + // //dswrec2[5] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("پیمان", 100), + // // IranSystemNumbers.DontConvert); + // ////خانوادگی نام + // //dswrec2[6] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("افشاری بجاربنه", 100), + // // IranSystemNumbers.DontConvert); + // ////پدر نام + // //dswrec2[7] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("علیرضا", 100), + // // IranSystemNumbers.DontConvert); + // ////شماره شناسنامه + // //dswrec2[8] = "2580900713"; + // ////محل صدور + // //dswrec2[9] = + // // ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("رشت", 100), IranSystemNumbers.DontConvert); + // //; + // ////تاریخ صدور + // //dswrec2[10] = ""; + // ////تاریخ تولد + // //dswrec2[11] = "13750229"; + // ////جنسیت + // //dswrec2[12] = + // // ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("مرد", 3), IranSystemNumbers.DontConvert); + // ////ملیت + // //dswrec2[13] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("ایرانی", 10), + // // IranSystemNumbers.DontConvert); + // ////شرح شغل + // //dswrec2[14] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("کارشناس نرم افزار کامپیوتر", 100), + // // IranSystemNumbers.DontConvert); + // ////تاریخ شروع بکار + // //dswrec2[15] = "14010701"; + // ////تاریخ ترک کار + // //dswrec2[16] = ""; + // ////تعداد روزهای کارکرد + // //dswrec2[17] = "31"; + // ////دستمزد روزانه + // //dswrec2[18] = "1769428"; + // ////دستمزد مااهانه + // //dswrec2[19] = "54852268"; + // ////مزایای ماهانه + // //dswrec2[20] = "20000000"; + // ////دستمزد و مزایای ماهانه مشمول + // //dswrec2[21] = "74852268"; + // ////جمع کل دستمزد و مزایای ماهانه مسمول غیرمشمول + // //dswrec2[22] = "74852268"; + // ////حق بیمه سهم بیمه شده + // //dswrec2[23] = "5239659"; + // ////نرخ پورسانتاژ + // //dswrec2[24] = "0"; + // ////کد شغل + // //dswrec2[25] = "033022"; + // ////کد ملی + // //dswrec2[26] = "2580900713"; + + // //dsw.Write(dswrec2); + + + // //var dswrec3 = new DbfRecord(dsw.Header); + // ////کد کارگاه + // //dswrec3[0] = GetSpecifiedCharactes("9008289145", 10); + // ////سال + // //dswrec3[1] = "2"; + // ////ماه + // //dswrec3[2] = "2"; + // ////شماره لیست + // //dswrec3[3] = GetSpecifiedCharactes("01", 12); + // ////شماره بیمه + // //dswrec3[4] = GetSpecifiedCharactes("48076618", 8); + // //// نام + // //dswrec3[5] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("فاطمه", 100), + // // IranSystemNumbers.DontConvert); + // ////خانوادگی نام + // //dswrec3[6] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("پادکان", 100), + // // IranSystemNumbers.DontConvert); + // ////پدر نام + // //dswrec3[7] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("محمدفرشاد", 100), + // // IranSystemNumbers.DontConvert); + // ////شماره شناسنامه + // //dswrec3[8] = "2581230231"; + // ////محل صدور + // //dswrec3[9] = + // // ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("رشت", 100), IranSystemNumbers.DontConvert); + // //; + // ////تاریخ صدور + // //dswrec3[10] = ""; + // ////تاریخ تولد + // //dswrec3[11] = "13780926"; + // ////جنسیت + // //dswrec3[12] = + // // ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("زن", 3), IranSystemNumbers.DontConvert); + // ////ملیت + // //dswrec3[13] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("ایرانی", 10), + // // IranSystemNumbers.DontConvert); + // ////شرح شغل + // //dswrec3[14] = ConvertToIranSystem.ToIranSystem(GetSpecifiedCharactes("کارشناس نرم افزار کامپیوتر", 100), + // // IranSystemNumbers.DontConvert); + // ////تاریخ شروع بکار + // //dswrec3[15] = "14010701"; + // ////تاریخ ترک کار + // //dswrec3[16] = ""; + // ////تعداد روزهای کارکرد + // //dswrec3[17] = "31"; + // ////دستمزد روزانه + // //dswrec3[18] = "1769428"; + // ////دستمزد مااهانه + // //dswrec3[19] = "54852268"; + // ////مزایای ماهانه + // //dswrec3[20] = "20000000"; + // ////دستمزد و مزایای ماهانه مشمول + // //dswrec3[21] = "74852268"; + // ////جمع کل دستمزد و مزایای ماهانه مسمول غیرمشمول + // //dswrec3[22] = "74852268"; + // ////حق بیمه سهم بیمه شده + // //dswrec3[23] = "5239659"; + // ////نرخ پورسانتاژ + // //dswrec3[24] = "0"; + // ////کد شغل + // //dswrec3[25] = "001094"; + // ////کد ملی + // //dswrec3[26] = "2581230231"; + + // //dsw.Write(dswrec3); + + // dsw.WriteHeader(); + + // dsw.Close(); + // } + + // return true; + // } + // catch (Exception er) { return false; } + //} + + //public IActionResult OnGetEdit(long id) + //{ + // var insurance = _insuranceListApplication.GetDetailsForEdit(id); + // workshop = _workshopApplication.GetDetails(workshopId_); + // var workshopObj = workshop; + // insurance.WorkshopName = workshopObj == null ? string.Empty : workshopObj.WorkshopFullName; + // insurance.TypeOfInsuranceSend = workshopObj.TypeOfInsuranceSend; + // insurance.Population = workshopObj.Population; + // insurance.FixedSalary = workshopObj.FixedSalary; + // insurance.InsuranceJobId = workshopObj.InsuranceJobId; + // // workshopList = workshopList.Where(x => !string.IsNullOrWhiteSpace(x.TypeOfInsuranceSend) && x.TypeOfInsuranceSend != "false").ToList(); + // //insurance.WorkShopSelectList = new SelectList(workshopList, "Id", "WorkshopFullName"); + // //insurance.YearList = _yearlySalaryApplication.GetYears(); + + // return Partial("Edit", insurance); + //} + + //public IActionResult OnGetEmployeeListForEdit(EmployeeForEditInsuranceListSearchModel searchModel) + //{ + // var result = _insuranceListApplication.SearchEmployeeListForEditByInsuranceListId(searchModel); + // return Partial("./EmployeeListForEdit", result); + //} + + //public IActionResult OnPostEdit(EditInsuranceList command) + //{ + // //var result =new OperationResult(); + // //result.IsSuccedded = true; + // var result = _insuranceListApplication.Edit(command); + // if (result.IsSuccedded) + // { + // var path = command.InsuranceWorkshopInfo.WorkshopId; + // var directoryPath = $"{_webHostEnvironment.ContentRootPath}\\InsuranceList\\{path}"; + // var monthPath = directoryPath + "\\" + command.Year + "_" + command.Month; + // //if (Directory.Exists(monthPath)) + // // Directory.Delete(monthPath); + + // var filePathDSKKAR00 = monthPath + "\\DSKKAR00.dbf"; + // if (System.IO.File.Exists(filePathDSKKAR00)) + // System.IO.File.Delete(filePathDSKKAR00); + + + // var filePathDSKWOR00 = monthPath + "\\DSKWOR00.dbf"; + // if (System.IO.File.Exists(filePathDSKWOR00)) + // System.IO.File.Delete(filePathDSKWOR00); + // var saveFileResult = SaveFile(command); + // if (saveFileResult) + // { + // result.IsSuccedded = true; + // result.Message = "ویرایش اطلاعات با موفقیت انجام شد"; + // } + // else + // { + // result.Failed("ایجاد فایل بیمه با خطا مواجه شد"); + // } + // } + + // return new JsonResult(result); + //} + + //public IActionResult OnGetInsuranceSummary(long id) + //{ + // var insurance = _insuranceListApplication.GetDetails(id); + // return Partial("InsuranceSummary", insurance); + //} + + //public IActionResult OnGetInsuranceConfirm(long id) + //{ + // var insurance = _insuranceListApplication.GetDetails(id); + // return Partial("InsuranceConfirm", insurance); + //} + //public IActionResult OnGetInspectionReport(long id) + //{ + // var insurance = _insuranceListApplication.GetDetails(id); + // return Partial("InspectionReport", insurance); + //} + + + //public IActionResult OnPostMonthlySalary(string dailyWage, string workingDays, string insuranceShare, string benefitsIncludedContinuous, string jobId, string housingAllowance, string includeStatus, string consumableItems, string endMonthCurrentDay) + //{ + + // double benefitsIncludedContinuousL = benefitsIncludedContinuous.MoneyToDouble(); + // double sum = consumableItems.MoneyToDouble() + housingAllowance.MoneyToDouble(); + // long workingDaysL = Convert.ToInt64(workingDays); + // long endMonthCurrentDayL = Convert.ToInt64(endMonthCurrentDay); + // long jobIdL = Convert.ToInt64(jobId); + // long includeStatusL = Convert.ToInt64(includeStatus); + // double dailyWageL = dailyWage.MoneyToDouble(); + + + + // if (workingDaysL == endMonthCurrentDayL) + // { + // benefitsIncludedContinuousL = sum; + // } + + // if (workingDaysL < endMonthCurrentDayL) + // { + // if (endMonthCurrentDayL == 29) + // endMonthCurrentDayL = 30; + // var a = (sum * workingDaysL) / endMonthCurrentDayL; + // benefitsIncludedContinuousL = _insuranceListApplication.GetRoundValue(a); + // } + // //if (dailyWageL == 0) + // //{ + // // benefitsIncludedContinuousL = 0; + // //} + // if ((includeStatusL == 0 && (jobIdL == 10 || jobIdL == 17 || jobIdL == 18 || jobIdL == 16)) || (includeStatusL == 1 && jobIdL == 10))// 10 --> karfarma + // { + // benefitsIncludedContinuousL = 0; + + // } + // double monthlySalaryL = workingDaysL * dailyWageL; + // double insuranceShareL = ((benefitsIncludedContinuousL + monthlySalaryL) * 7) / 100; + // insuranceShareL = _insuranceListApplication.GetRoundValue(insuranceShareL); + + + // //var persianBefore = ""; + // //var year = Convert.ToInt32(date.Substring(0, 4)); + // //var month = Convert.ToInt32(date.Substring(5, 2)); + // //var day = Convert.ToInt32(date.Substring(8, 2)); + // //var persianDate = new PersianDateTime(year, month, day); + // //var persianBeforeDate = persianDate.AddDays(-1); + // //persianBefore = persianBeforeDate.ToString("yyyy/MM/dd"); + + // if (benefitsIncludedContinuousL == 0 && monthlySalaryL == 0 && insuranceShareL == 0 && dailyWageL == 0) + // { + // workingDaysL = 0; + // } + // if (benefitsIncludedContinuousL == 0 && monthlySalaryL == 0 && insuranceShareL == 0 && workingDaysL == 0) + // { + // dailyWageL = 0; + // } + // return new JsonResult(new + // { + // monthlySalary = monthlySalaryL.ToMoney(), + // benefitsIncludedContinuous = benefitsIncludedContinuousL.ToMoney(), + // insuranceShare = insuranceShareL.ToMoney(), + // workingDay = workingDaysL, + // dailyWag = dailyWageL.ToMoney(), + // }); + //} + + //public IActionResult OnPostComputeInsuranceList(List employeeDetailsForInsuranceList, string typeOfInsuranceSendWorkshop) + //{ + // double sumOfEmployees = employeeDetailsForInsuranceList.Count(); + // double included = 0;//مشمول + // double sumOfWorkingDays = 0; + // double benefitsIncludedNonContinuous = 0;//مشمول غیر مستمر + // double sumOfSalaries = 0; + // double sumOfDailyWage = 0; + // double insuredShare = 0; + // double employerShare = 0;//سهم بیمه کارفرما + // double sumOfIncluded = 0; + // double unEmploymentInsurance = 0;//سهم بیمه بیکاری + // double monthlyBenefits = 0;//مزایای ماهیانه + // double sumForunEmploymentInsurance = 0; + // double benefitsIncludedContinuous = 0; + // double sumOfIncludedKarfarma = 0; + // bool hasKarfarma = false; + // double countWithoutLeft = 0; + + // for (int i = 0; i < employeeDetailsForInsuranceList.Count; i++) + // { + + // if (!string.IsNullOrWhiteSpace(employeeDetailsForInsuranceList[i].LeftWorkDate)) + // { + // countWithoutLeft = countWithoutLeft + 1; + // } + + + // // if (employeeDetailsForInsuranceList[i].IncludeStatus && (employeeDetailsForInsuranceList[i].JobId == 10 || employeeDetailsForInsuranceList[i].JobId == 17 || employeeDetailsForInsuranceList[i].JobId == 18 || employeeDetailsForInsuranceList[i].JobId == 16))// 10 --> karfarma + // if (!employeeDetailsForInsuranceList[i].IncludeStatus && (employeeDetailsForInsuranceList[i].JobCode == "027079" || employeeDetailsForInsuranceList[i].JobCode == "024398" || employeeDetailsForInsuranceList[i].JobCode == "011015" || employeeDetailsForInsuranceList[i].JobCode == "020010"))// 10 --> karfarma + // { + // benefitsIncludedContinuous = 0; + // sumForunEmploymentInsurance = sumForunEmploymentInsurance; + // } + // else + // { + // sumForunEmploymentInsurance = sumForunEmploymentInsurance + employeeDetailsForInsuranceList[i].BenefitsIncludedContinuous; + // } + // //if (employeeDetailsForInsuranceList[i].JobId == 10)//کارفرما + // if (employeeDetailsForInsuranceList[i].JobCode == "024398")//کارفرما + // { + // hasKarfarma = true; + // sumOfIncludedKarfarma = employeeDetailsForInsuranceList[i].BenefitsIncludedContinuous; + // } + + // sumOfWorkingDays = sumOfWorkingDays + employeeDetailsForInsuranceList[i].WorkingDays; + // sumOfDailyWage = sumOfDailyWage + employeeDetailsForInsuranceList[i].DailyWage; + // sumOfSalaries = sumOfSalaries + employeeDetailsForInsuranceList[i].MonthlySalary; + // monthlyBenefits = monthlyBenefits + +employeeDetailsForInsuranceList[i].MonthlyBenefits; + // sumOfIncluded = sumOfIncluded + employeeDetailsForInsuranceList[i].BenefitsIncludedContinuous; + // benefitsIncludedNonContinuous = benefitsIncludedNonContinuous + employeeDetailsForInsuranceList[i].BenefitsIncludedNonContinuous; + // insuredShare = insuredShare + employeeDetailsForInsuranceList[i].InsuranceShare; + + // } + + // employerShare = GetRoundValueWhitGovermentlist((sumOfIncluded * 20) / 100, typeOfInsuranceSendWorkshop); + // unEmploymentInsurance = GetRoundValueWhitGovermentlist((sumForunEmploymentInsurance * 3) / 100, typeOfInsuranceSendWorkshop); + + // if (typeOfInsuranceSendWorkshop == "Govermentlist" && (sumOfEmployees - countWithoutLeft) <= 5 && !hasKarfarma) + // { //console.log(1); + // employerShare = 0; + // } + + // if (typeOfInsuranceSendWorkshop == "Govermentlist" && (sumOfEmployees - countWithoutLeft) <= 6 && hasKarfarma) + // { //console.log(sumOfIncludedKarfarma); + // var result = (sumOfIncludedKarfarma * 20) / 100; + // employerShare = GetRoundValueWhitGovermentlist(result, typeOfInsuranceSendWorkshop); + // } + // if (typeOfInsuranceSendWorkshop == "Govermentlist" && (sumOfEmployees - countWithoutLeft) >= 6 && !hasKarfarma) + // { + // //ابتدا جمع کل مزایا به دست می آید + // //جمع کل مزایا تقسیم بر تعداد کارگران منهای کسانی که ترک کار کرده اند. + // //حاصل عبارت بالا در 5 ضرب میشو یعنی میانگینی برای محاسبه قیمت 5 نفر حساب می کنیم تا از طریق دولت پرداخت شود + // var result = (sumOfIncluded - ((sumOfIncluded / (sumOfEmployees - countWithoutLeft)) * 5)) * 20 / 100; + // employerShare = GetRoundValueWhitGovermentlist(result, typeOfInsuranceSendWorkshop); + // // employerShare =getRoundValue(((sumOfIncluded/sumOfEmployees)*(sumOfEmployees-5))*20/100); + // } + // if (typeOfInsuranceSendWorkshop == "Govermentlist" && (sumOfEmployees - countWithoutLeft) > 6 && hasKarfarma) + // { // console.log(4); + // var sum = sumOfIncluded - sumOfIncludedKarfarma;//ستون مربوط به کارفرما محاسبه نمی شود + // var result = ((sum - ((sum / ((sumOfEmployees - countWithoutLeft) - 1)) * 5)) + sumOfIncludedKarfarma) * 20 / 100; + // employerShare = GetRoundValueWhitGovermentlist(result, typeOfInsuranceSendWorkshop); + + + // } + + + + + // return new JsonResult(new + // { + // SumOfEmployees = sumOfEmployees, + // SumOfSalaries = sumOfSalaries.ToMoney(), + // SumOfDailyWage = sumOfDailyWage.ToMoney(), + // SumOfWorkingDays = sumOfWorkingDays, + // SumOfBenefitsIncluded = monthlyBenefits.ToMoney(), + // Included = sumOfIncluded.ToMoney(), + // IncludedAndNotIncluded = (sumOfIncluded + benefitsIncludedNonContinuous).ToMoney(), + // InsuredShare = insuredShare.ToMoney(), + // EmployerShare = employerShare.ToMoney(), + // UnEmploymentInsurance = unEmploymentInsurance.ToMoney(), + // }); + + //} + //public double GetRoundValueWhitGovermentlist(double value, string type) + //{ + // string strValue = value.ToString(); + // if (strValue.IndexOf('.') > -1) + // { + // string a = strValue.Substring(strValue.IndexOf('.') + 1, 1); + // if (type == "Govermentlist") + // { + // if (int.Parse(a) >= 4) + // { + // return (Math.Round(value, MidpointRounding.ToPositiveInfinity)); + // } + // else + // { + // return (Math.Round(value, MidpointRounding.ToNegativeInfinity)); + // } + // } + // else + // { + // if (int.Parse(a) > 5) + // { + // return (Math.Round(value, MidpointRounding.ToPositiveInfinity)); + // } + // else + // { + // return (Math.Round(value, MidpointRounding.ToNegativeInfinity)); + // } + // } + // } + + // return value; + //} + + #endregion + } +} diff --git a/ServiceHost/Areas/Client/Pages/Company/InsuranceList/InsuranceConfirm.cshtml b/ServiceHost/Areas/Client/Pages/Company/InsuranceList/InsuranceConfirm.cshtml index a1ef4675..b2b6d444 100644 --- a/ServiceHost/Areas/Client/Pages/Company/InsuranceList/InsuranceConfirm.cshtml +++ b/ServiceHost/Areas/Client/Pages/Company/InsuranceList/InsuranceConfirm.cshtml @@ -467,539 +467,535 @@