1212using Microting . TimePlanningBase . Infrastructure . Data . Entities ;
1313using Sentry ;
1414using TimePlanning . Pn . Infrastructure . Models . Planning ;
15+ using TimePlanning . Pn . Infrastructure . Models . WorkingHours . Index ;
1516using TimePlanning . Pn . Services . TimePlanningPlanningService ;
1617
1718namespace TimePlanning . Pn . Infrastructure . Helpers ;
@@ -768,4 +769,151 @@ public static async Task<TimePlanningPlanningModel> UpdatePlanRegistrationsInPer
768769
769770 return siteModel ;
770771 }
772+
773+ public static async Task < TimePlanningWorkingHoursModel > ReadBySiteAndDate (
774+ TimePlanningPnDbContext dbContext , int sdkSiteId , DateTime dateTime ,
775+ string token )
776+ {
777+ if ( token != null )
778+ {
779+ var registrationDevice = await dbContext . RegistrationDevices
780+ . Where ( x => x . Token == token ) . FirstOrDefaultAsync ( ) ;
781+ if ( registrationDevice == null )
782+ {
783+ return null ;
784+ }
785+ }
786+
787+ // var today = DateTime.UtcNow;
788+ var midnight = dateTime ;
789+
790+ var planRegistration = await dbContext . PlanRegistrations
791+ . Where ( x => x . Date == midnight )
792+ . Where ( x => x . SdkSitId == sdkSiteId )
793+ . Where ( x => x . WorkflowState != Constants . WorkflowStates . Removed )
794+ . FirstOrDefaultAsync ( ) ;
795+
796+ if ( planRegistration == null )
797+ {
798+ var newTimePlanningWorkingHoursModel = new TimePlanningWorkingHoursModel
799+ {
800+ SdkSiteId = sdkSiteId ,
801+ Date = midnight ,
802+ PlanText = "" ,
803+ PlanHours = 0 ,
804+ Shift1Start = 0 ,
805+ Shift1Stop = 0 ,
806+ Shift1Pause = 0 ,
807+ Shift2Start = 0 ,
808+ Shift2Stop = 0 ,
809+ Shift2Pause = 0 ,
810+ NettoHours = 0 ,
811+ FlexHours = 0 ,
812+ SumFlexStart = 0 ,
813+ SumFlexEnd = 0 ,
814+ PaidOutFlex = "0" ,
815+ Message = 0 ,
816+ CommentWorker = "" ,
817+ CommentOffice = "" ,
818+ CommentOfficeAll = "" ,
819+ Shift1PauseNumber = 0 ,
820+ Shift2PauseNumber = 0 ,
821+ } ;
822+
823+ return newTimePlanningWorkingHoursModel ;
824+
825+ // return new OperationDataResult<TimePlanningWorkingHoursModel>(false, "Plan registration not found",
826+ // null);
827+ }
828+
829+ var timePlanningWorkingHoursModel = new TimePlanningWorkingHoursModel
830+ {
831+ SdkSiteId = sdkSiteId ,
832+ Date = planRegistration . Date ,
833+ PlanText = planRegistration . PlanText ,
834+ PlanHours = planRegistration . PlanHours ,
835+ Shift1Start = planRegistration . Start1Id ,
836+ Shift1Stop = planRegistration . Stop1Id ,
837+ Shift1Pause = planRegistration . Pause1Id ,
838+ Shift2Start = planRegistration . Start2Id ,
839+ Shift2Stop = planRegistration . Stop2Id ,
840+ Shift2Pause = planRegistration . Pause2Id ,
841+ NettoHours = planRegistration . NettoHours ,
842+ FlexHours = planRegistration . Flex ,
843+ SumFlexStart = planRegistration . SumFlexStart ,
844+ SumFlexEnd = planRegistration . SumFlexEnd ,
845+ PaidOutFlex = planRegistration . PaiedOutFlex . ToString ( ) ,
846+ Message = planRegistration . MessageId ,
847+ CommentWorker = planRegistration . WorkerComment ,
848+ CommentOffice = planRegistration . CommentOffice ,
849+ CommentOfficeAll = planRegistration . CommentOfficeAll ,
850+ Start1StartedAt = planRegistration . Start1StartedAt ,
851+ Stop1StoppedAt = planRegistration . Stop1StoppedAt ,
852+ Pause1StartedAt = planRegistration . Pause1StartedAt ,
853+ Pause1StoppedAt = planRegistration . Pause1StoppedAt ,
854+ Start2StartedAt = planRegistration . Start2StartedAt ,
855+ Stop2StoppedAt = planRegistration . Stop2StoppedAt ,
856+ Pause2StartedAt = planRegistration . Pause2StartedAt ,
857+ Pause2StoppedAt = planRegistration . Pause2StoppedAt ,
858+ Pause10StartedAt = planRegistration . Pause10StartedAt ,
859+ Pause10StoppedAt = planRegistration . Pause10StoppedAt ,
860+ Pause11StartedAt = planRegistration . Pause11StartedAt ,
861+ Pause11StoppedAt = planRegistration . Pause11StoppedAt ,
862+ Pause12StartedAt = planRegistration . Pause12StartedAt ,
863+ Pause12StoppedAt = planRegistration . Pause12StoppedAt ,
864+ Pause13StartedAt = planRegistration . Pause13StartedAt ,
865+ Pause13StoppedAt = planRegistration . Pause13StoppedAt ,
866+ Pause14StartedAt = planRegistration . Pause14StartedAt ,
867+ Pause14StoppedAt = planRegistration . Pause14StoppedAt ,
868+ Pause15StartedAt = planRegistration . Pause15StartedAt ,
869+ Pause15StoppedAt = planRegistration . Pause15StoppedAt ,
870+ Pause16StartedAt = planRegistration . Pause16StartedAt ,
871+ Pause16StoppedAt = planRegistration . Pause16StoppedAt ,
872+ Pause17StartedAt = planRegistration . Pause17StartedAt ,
873+ Pause17StoppedAt = planRegistration . Pause17StoppedAt ,
874+ Pause18StartedAt = planRegistration . Pause18StartedAt ,
875+ Pause18StoppedAt = planRegistration . Pause18StoppedAt ,
876+ Pause19StartedAt = planRegistration . Pause19StartedAt ,
877+ Pause19StoppedAt = planRegistration . Pause19StoppedAt ,
878+ Pause100StartedAt = planRegistration . Pause100StartedAt ,
879+ Pause100StoppedAt = planRegistration . Pause100StoppedAt ,
880+ Pause101StartedAt = planRegistration . Pause101StartedAt ,
881+ Pause101StoppedAt = planRegistration . Pause101StoppedAt ,
882+ Pause102StartedAt = planRegistration . Pause102StartedAt ,
883+ Pause102StoppedAt = planRegistration . Pause102StoppedAt ,
884+ Pause20StartedAt = planRegistration . Pause20StartedAt ,
885+ Pause20StoppedAt = planRegistration . Pause20StoppedAt ,
886+ Pause21StartedAt = planRegistration . Pause21StartedAt ,
887+ Pause21StoppedAt = planRegistration . Pause21StoppedAt ,
888+ Pause22StartedAt = planRegistration . Pause22StartedAt ,
889+ Pause22StoppedAt = planRegistration . Pause22StoppedAt ,
890+ Pause23StartedAt = planRegistration . Pause23StartedAt ,
891+ Pause23StoppedAt = planRegistration . Pause23StoppedAt ,
892+ Pause24StartedAt = planRegistration . Pause24StartedAt ,
893+ Pause24StoppedAt = planRegistration . Pause24StoppedAt ,
894+ Pause25StartedAt = planRegistration . Pause25StartedAt ,
895+ Pause25StoppedAt = planRegistration . Pause25StoppedAt ,
896+ Pause26StartedAt = planRegistration . Pause26StartedAt ,
897+ Pause26StoppedAt = planRegistration . Pause26StoppedAt ,
898+ Pause27StartedAt = planRegistration . Pause27StartedAt ,
899+ Pause27StoppedAt = planRegistration . Pause27StoppedAt ,
900+ Pause28StartedAt = planRegistration . Pause28StartedAt ,
901+ Pause28StoppedAt = planRegistration . Pause28StoppedAt ,
902+ Pause29StartedAt = planRegistration . Pause29StartedAt ,
903+ Pause29StoppedAt = planRegistration . Pause29StoppedAt ,
904+ Pause200StartedAt = planRegistration . Pause200StartedAt ,
905+ Pause200StoppedAt = planRegistration . Pause200StoppedAt ,
906+ Pause201StartedAt = planRegistration . Pause201StartedAt ,
907+ Pause201StoppedAt = planRegistration . Pause201StoppedAt ,
908+ Pause202StartedAt = planRegistration . Pause202StartedAt ,
909+ Pause202StoppedAt = planRegistration . Pause202StoppedAt ,
910+ Shift1PauseNumber = planRegistration . Shift1PauseNumber ,
911+ Shift2PauseNumber = planRegistration . Shift2PauseNumber
912+ } ;
913+
914+ return timePlanningWorkingHoursModel ;
915+ // return new OperationDataResult<TimePlanningWorkingHoursModel>(true, "Plan registration found",
916+ // timePlanningWorkingHoursModel);
917+ }
918+
771919}
0 commit comments