using System; using System.Collections.Generic; using System.Linq; using System.Windows.Threading; using BeWo.Core.Service; using BeWo.SchulbegleitenderDienst.ViewModel; using BeWo.ServiceProxy; using BeWo.ViewModel.Controls.AI; using BeWo.ViewModel.ListViewModel; using BeWo.ViewModel.View.AI; using BS.Shared; using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.DataContracts.Feature.AI; using BS.Shared.Extensions; using DevExpress.XtraEditors.Filtering.Templates; namespace BeWo.ViewModel { public static class VMFactory { public static void CreateAbsenceReasonListVMAsync(Action pCallBack) { ServiceFacade.DoCustomerServiceAsync(s => s.GetAllAbsenceReasons(), r => pCallBack(new AbsenceReasonListVM(r))); } public static void CreateAbsenceTimeListVMAsync(IEnumerable pDCs, AbsenceReasonVisibilityType? type, Action pCallBack) { ServiceFacade.DoCustomerServiceAsync(s => s.GetAllAbsenceReasons(), cb => pCallBack(new AbsenceTimeListVM(pDCs, cb.Where(a => !a.Sichtbarkeit.HasValue || a.Sichtbarkeit.Value == AbsenceReasonVisibilityType.All || a.Sichtbarkeit.Value == type).ToList()))); } public static AbsenceTimeListVM CreateAbsenceTimeListVM(IEnumerable pDCs, AbsenceReasonVisibilityType? type) { var list = ServiceFacade.DoCustomerServiceSync(s => s.GetAllAbsenceReasons()); return new AbsenceTimeListVM(pDCs, list.Where(a => !a.Sichtbarkeit.HasValue || a.Sichtbarkeit.Value == AbsenceReasonVisibilityType.All || a.Sichtbarkeit.Value == type).ToList()); } public static void CreateOvertimeListVMAsync(IEnumerable pDCs, Action pCallBack) { //ServiceFacade.DoValueListServiceAsync(v => v.GetAllValueListEntrysByType(ValueListEntryType.Auszahlungsart), cb => pCallBack(new OvertimeListVM(pDCs))); ServiceFacade.DoEmployeeServiceAsync(v => v.GetAllOvertimes(), cb => pCallBack(new OvertimeListVM(pDCs))); } public static void CreateAccountingBookingVMAsnyc(Action pCallBack) { Cache.GetInstance().GetSupportConceptTree( tree => Cache.GetInstance().GetAllValueListEntrysByTypeAsync(ValueListEntryType.AccountingTransactionType, categories => pCallBack(new AccountingBookingVM(tree, categories)))); } public static void CreateAccountingTransactionListVMAsnyc(DateTimeSpan pSpan, long? pSupportConceptOid, long? pCostBearerSupportConceptRelOid, Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s => s.GetAccountingTransactions(pSpan, pSupportConceptOid, pCostBearerSupportConceptRelOid), r => pCallBack(new AccountingTransactionListVM(r))); } public static void CreateAssessmentSheetCategoryListVM(Action cb) { ServiceFacade.DoEmployeeServiceAsync( s1 => s1.GetAllAssessmentSheetValues(), v => ServiceFacade.DoEmployeeServiceAsync(s => s.GetAllAssessmentSheetCategories(), dcs => cb(new AssessmentSheetCategoryListVM(dcs, v)))); } public static void CreateAssessmentSheetValueListVM(Action cb) { ServiceFacade.DoEmployeeServiceAsync(s => s.GetAllAssessmentSheetValues(), dcs => cb(new AssessmentSheetValueListVM(dcs))); } public static void CreateBookingVMAsync(DateTimeSpan pSpan, Action pCallBack) { ServiceFacade.DoResourceServiceAsync(s => s.GetAllBookings(pSpan.StartDateTime, pSpan.EndDateTime), r => pCallBack(new BookingVM(r))); } public static CustomerEmployeeRelationListVM CreateCustomerEmployeeRelationListVM(List pList) { var valueList = Cache.GetInstance().GetAllValueListEntrysByTypeSync(ValueListEntryType.StaffRoleType); return new CustomerEmployeeRelationListVM(pList, valueList); } public static WohnheimEmployeeRelationListVM CreateWohnheimEmployeeRelationListVM(List pList) { var valueList = Cache.GetInstance().GetAllValueListEntrysByTypeSync(ValueListEntryType.StaffRoleType); return new WohnheimEmployeeRelationListVM(pList, valueList); } public static WohnheimCustomerRelationListVM CreateWohnheimCustomerRelationListVM(List pList) { var valueList = Cache.GetInstance().GetAllValueListEntrysByTypeSync(ValueListEntryType.StaffRoleType); return new WohnheimCustomerRelationListVM(pList, valueList); } public static GoalRatingListVM CreateGoalRatingListVM(List ratingList) { var typeList = Cache.GetInstance().GetAllRatingTypeList(); return new GoalRatingListVM(ratingList, typeList); } public static void CreateOrganisationPersonRelationListVMAsync(List pDCs, Action pCallBack) { pCallBack(new OrganisationPersonRelationListVM(pDCs)); } public static CustomerPersonRelationListVM CreateCustomerEnvironmentPersonRelListVM(List pList, ValueListEntryType vtype) { var valueList = Cache.GetInstance().GetAllValueListEntrysByTypeSync(vtype); return new CustomerPersonRelationListVM(pList, valueList); } public static void CreateCustomerEnvironmentOrganisationRelListVMAsync(List pList, Action pCallBack) { Cache.GetInstance().GetAllValueListEntrysByTypeAsync(ValueListEntryType.EnvironmentOrganisationType, r => pCallBack(new CustomerOrganisationRelationListVM(pList, r))); } public static CustomerOrganisationRelationListVM CreateCustomerEnvironmentOrganisationRelListVM(List pList) { var valueList = Cache.GetInstance().GetAllValueListEntrysByTypeSync(ValueListEntryType.EnvironmentOrganisationType); return new CustomerOrganisationRelationListVM(pList, valueList); } public static MedikamentenverordnungslisteListVM CreateMedikementenverordnungslisteListVM(IEnumerable pList) { var darreichungsformen = ServiceFacade.DoCustomerServiceSync(s => s.GetAllDarreichungsformen()); var depotrhythmen = ServiceFacade.DoCustomerServiceSync(s => s.GetAllDepotRhythmen()); return new MedikamentenverordnungslisteListVM(pList, darreichungsformen, depotrhythmen); } public static BargeldtransaktionsListVM CreateBargeldtransaktionsListVM(IEnumerable pList) { return new BargeldtransaktionsListVM(pList); } public static void CreateCustomerVMAsync(long pOid, Action pCallBack) { ServiceFacade.DoCustomerServiceAsync(s => s.LoadCustomer(pOid), cb => CreateCustomerVMAsync(cb, pCallBack)); } public static void CreateCustomerVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync( s => s.GetVarFieldDefs(TableID.Customer), cb => CreateCustomerVMAsync( new CustomerDC { CustomerVarFields = cb }, pCallBack)); } public static void CreateCustomerVMAsync(CustomerDC pCustomerDC, Action pCallBack) { if (BeWoApp.ICD10Diagnosis == null) { ServiceFacade.DoOperationsServiceAsync( s => s.GetCompressedICD10Diagnosis(), st => { st = Utils.Decompress(st); var ds = st.Split(Environment.NewLine).ToDictionary(line => line.Substring(0, line.IndexOf(';')), line => line.Substring(line.IndexOf(';') + 1)); BeWoApp.ICD10Diagnosis = ds; InternalCreateCustomerVM(pCustomerDC, pCallBack); }); } else { InternalCreateCustomerVM(pCustomerDC, pCallBack); } } public static void CreateEmployeeVMAsync(long pOid, Action pCallBack) { ServiceFacade.DoEmployeeServiceAsync( s => s.LoadEmployee(pOid), r => { CreateEmployeeVMAsync(r, pCallBack); }); } public static void CreateEmployeeVMAsync(EmployeeDC pEmployeeDC, Action pCallBack) { ServiceFacade.DoEmployeeServiceAsync(s => s.GetAllEmploymentTypes(), r1 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.StaffQualificationsType, r2 => Cache.GetInstance() .GetAllValueListEntrysByTypeAsync(ValueListEntryType.StaffActivityFocusType, r3 => Cache.GetInstance() .GetAllValueListEntrysByTypeAsync(ValueListEntryType.ContractType, r4 => Cache.GetInstance() .GetAllValueListEntrysByTypeAsync(ValueListEntryType.Nationality, nat => Cache.GetInstance() .GetAllValueListEntrysByTypeAsync(ValueListEntryType.NotizenKategorieEmployee, r7 => ServiceFacade.DoEmployeeServiceAsync( e => e.GetAllAuszahlungsarten(), r6 => ServiceFacade.DoOperationsServiceAsync( s => s.GetSbdConfig(), config => pCallBack(new EmployeeVM(pEmployeeDC, r1, nat, r2, r3, r6, r4, config.Stundensaetze, r7)))))))))); } public static void CreateEmployeeVMAsync(Action pCallBack) { CreateEmployeeVMAsync(new EmployeeDC(), pCallBack); } public static void CreateWohnheimVMAsync(long pOid, List customers, Action pCallBack) { ServiceFacade.DoWohnheimServiceAsync( s => s.LoadWohnheim(pOid), r => { CreateWohnheimVMAsync(r, customers, pCallBack); }); } public static void CreateWohnheimVMAsync(WohnheimDC pWohnheimDC, List customers, Action pCallBack) { pCallBack(new WohnheimVM(pWohnheimDC, customers)); } public static void CreateWohnheimVMAsync(List customers, Action pCallBack) { CreateWohnheimVMAsync(new WohnheimDC(), customers, pCallBack); } public static void CreateEquityInvoiceBaselListVMAsync(long supportconeptOid, Action callback) { ServiceFacade.DoAccountingServiceAsync( s => s.GetInvoiceBasesForSupportConcept(InvoiceType.CustomerEquity, supportconeptOid), r => { r.Sort( (dc1, dc2) => { if (dc2.InvoiceDate == null) { return -1; } if (dc1.InvoiceDate == null) { return 1; } return dc2.InvoiceDate.Value.CompareTo(dc1.InvoiceDate.Value); }); callback(new InvoiceBaseListVM(r)); }); } public static void CreateGeneralInvoiceBaselListVMAsync(CompactCustomerDC customer, CompactOrganisationDC organisation, CompactPersonDC person, Action callback) { if (organisation != null) { ServiceFacade.DoAccountingServiceAsync( s => s.GetGeneralInvoiceBasesForOrganisation(organisation.OrganisationOid), r => { r.Sort( (dc1, dc2) => { if (dc2.InvoiceDate == null) { return -1; } if (dc1.InvoiceDate == null) { return 1; } return dc2.InvoiceDate.Value.CompareTo(dc1.InvoiceDate.Value); }); callback(new InvoiceBaseListVM(r)); }); } else if (person != null) { ServiceFacade.DoAccountingServiceAsync( s => s.GetGeneralInvoiceBasesForPerson(person.PersonOid), r => { r.Sort( (dc1, dc2) => { if (dc2.InvoiceDate == null) { return -1; } if (dc1.InvoiceDate == null) { return 1; } return dc2.InvoiceDate.Value.CompareTo(dc1.InvoiceDate.Value); }); callback(new InvoiceBaseListVM(r)); }); } else if (customer != null) { ServiceFacade.DoAccountingServiceAsync( s => s.GetGeneralInvoiceBasesForCustomer(customer.CustomerOid), r => { r.Sort( (dc1, dc2) => { if (dc2.InvoiceDate == null) { return -1; } if (dc1.InvoiceDate == null) { return 1; } return dc2.InvoiceDate.Value.CompareTo(dc1.InvoiceDate.Value); }); callback(new InvoiceBaseListVM(r)); }); } } public static void CreateInvoiceListVMAsync(Action callback) { ServiceFacade.DoCustomerServiceAsync( s1 => s1.GetAllActiveSupportConceptsCompact(), r1 => ServiceFacade.DoCustomerServiceAsync( s2 => s2.GetAllActiveOrganisationsCompact(), r2 => ServiceFacade.DoOperationsServiceAsync(s3 => s3.GetAllActiveInvoices(), r3 => callback(new InvoiceListVM(r2, r1, r3))))); } public static void CreateInvoiceOverviewListVM(Action callback) { ServiceFacade.DoAccountingServiceAsync(s => s.GetAllActiveInvoiceBases(), cb => callback(new InvoiceBaseListVM(cb))); } public static void CreateOrganisationVMAsync(long pOid, Action pCallBack) { ServiceFacade.DoCustomerServiceAsync( s => s.LoadOrganisation(pOid), r1 => ServiceFacade.DoValueListServiceAsync(s1 => s1.GetAllValueListEntrysByType(ValueListEntryType.StaffQualificationsType), r2 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync(ValueListEntryType.OrganisationFunctionType, r4 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync(ValueListEntryType.RoleInOrganisationType, r3 => pCallBack(new OrganisationVM(r1, r2, r4, r3)))))); } public static void CreateOrganisationVMAsync(Action pCallBack) { ServiceFacade.DoValueListServiceAsync( s1 => s1.GetAllValueListEntrysByType(ValueListEntryType.StaffQualificationsType), r1 => ServiceFacade.DoOperationsServiceAsync( s => s.GetVarFieldDefs(TableID.Organisation), r2 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.OrganisationFunctionType, r4 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.RoleInOrganisationType, r3 => pCallBack(new OrganisationVM( new OrganisationDC { VarFields = r2 }, r1, r4, r3)))))); } //public static void CreatePersonOrganisationRelationVMAsync(CompactOrganisationDC pOrganisation, Action pCallBack) //{ // pCallBack( // new PersonOrganisationRelationVM( // new Organisation2PersonDC // { // OrganisationOid = pOrganisation.OrganisationOid, // OrganisationName = pOrganisation.Name, // OrganisationVersion = pOrganisation.OrganisationVersion // })); //} public static void CreatePersonVMAsync(Action pCallBack) { Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.TitleType, r1 => ServiceFacade.DoOperationsServiceAsync( s => s.GetVarFieldDefs(TableID.Person), r2 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.FunctionType, r4 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.RoleInOrganisationType, r5 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.Nationality, r3 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.Aufenthaltsstatus, r6 => pCallBack( new PersonVM( new PersonDC { VarFields = r2 }, r1, r4, r5, r3, r6)))))))); } public static void CreatePersonVMAsync(long pOid, Action pCallBack) { ServiceFacade.DoCustomerServiceAsync( s => s.LoadPerson(pOid), cb => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.TitleType, r1 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync(ValueListEntryType.FunctionType, r3 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync(ValueListEntryType.RoleInOrganisationType, r4 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync(ValueListEntryType.Nationality, r2 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync(ValueListEntryType.Aufenthaltsstatus, r5 => pCallBack(new PersonVM(cb, r1, r3, r4, r2, r5)))))))); } public static void CreateResourceListVMAsync(Action pCallBack) { ServiceFacade.DoResourceServiceAsync( s => s.GetAllResources(), r1 => ServiceFacade.DoValueListServiceAsync(s => s.GetAllValueListEntrysByType(ValueListEntryType.ResourceCategory), r2 => pCallBack(new ResourceListVM(r1, r2)))); } public static void CreateServiceCategoryListVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s => s.GetAllServiceCategories(), r => pCallBack(new ServiceCategoryListVM(r.Where(sc => sc.ScopeType == ScopeTypeId.Global).ToList()))); } public static void CreateAdditionalServiceListVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s => s.GetAllAdditionalService(), r => pCallBack(new AdditionalServiceListVM(r.ToList()))); } public static void CreateAuszahlungsartenListVMAsync(Action pCallBack) { ServiceFacade.DoEmployeeServiceAsync(s => s.GetAllAuszahlungsarten(), r => pCallBack(new AuszahlungsartListVM(r.ToList()))); } public static void CreateBudgetListVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s => s.GetAllBudgets(), r => pCallBack(new BudgetListVM(r.ToList()))); } public static void CreatePreisListVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s => s.GetAllPreise(), r => pCallBack(new PreisListVM(r.ToList()))); } public static void CreateDienstListVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s => s.GetAllDienste(null), r => pCallBack(new DienstInfoListVM(r.ToList()))); } public static void CreateRatingTypeListVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s => s.GetAllRatingTypes(), r => pCallBack(new RatingTypeListVM(r.ToList()))); } public static void CreateTextModuleListVMAsync(Action pCallBack, bool pIsInAdministrationView = false, bool pIsInTextModuleEditor = false) { ServiceFacade.DoOperationsServiceAsync(s1 => s1.GetTextModules(pIsInTextModuleEditor, BeWoApp.LoggedOnEmployee.EmployeeOid.Value, BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineAlleAnsehen), pIsInAdministrationView), r1 => ServiceFacade.DoOperationsServiceAsync( s2 => s2.GetAllServiceCategories(), s3 => { var x = r1.FirstOrDefault(tm => tm.TextModuleOid == 41); pCallBack(new TextModuleListVM(r1.OrderBy(o => o.Name), s3)); })); } public static void CreateMedArtListVMAsync(Action pCallBack) { ServiceFacade.DoCustomerServiceAsync(s => s.GetAllMedArten(), r => pCallBack(new MedArtListVM(r.ToList()))); } public static void CreateServiceDescriptionListVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync( s1 => s1.GetAllServiceDescriptions(), r1 => ServiceFacade.DoOperationsServiceAsync(s2 => s2.GetAllServiceCategories(), r2 => pCallBack(new ServiceDescriptionListVM(r1.Where(sr => sr.ScopeType == ScopeTypeId.Global).ToList(), r2.Where(sc => sc.ScopeType == ScopeTypeId.Global).ToList())))); } public static void CreateAdditionalServiceRegionListVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s1 => s1.GetAllAdditionalServiceRegion(), r1 => ServiceFacade.DoOperationsServiceAsync(s2 => s2.GetAllAdditionalService(), r2 => pCallBack(new AdditionalServiceRegionListVM(r1.ToList(), r2.ToList())))); } public static void CreateServiceRecordVMAsync(long pEmployeeOid, Action pCallBack) { Cache.GetInstance().GetServiceCategoryDescriptionDict( dict => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.SupportConceptGoalCategoryType, goalCats => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.SupportConceptIndividualGoalCategoryType, iGoalCats => Cache.GetInstance().GetAllValueListEntrysByTypeAsync(ValueListEntryType.SupportConceptGoalType, goals => Cache.GetInstance().GetAllValueListEntrysByTypeAsync(ValueListEntryType.DocumentType, docTypes => ServiceFacade.DoCustomerServiceAsync( s => s.GetAllActiveWohnheimeCompact(), cb => ServiceFacade.DoCustomerServiceAsync(s2 => s2.GetAllDarreichungsformen(), abc => pCallBack(new ServiceRecordListVM(dict, goalCats, iGoalCats, goals, cb, docTypes, abc))))))))); } public static void CreateMedRecordVMAsync(long pCustomerOid, Action pCallback) { ServiceFacade.DoCustomerServiceAsync(s => s.GetMedRecordsForCustomer(pCustomerOid), cb => pCallback(new MedRecordListVM(cb)), true); } public static void CreateSettlementListForCostBearerAndPeriod(long costBearerOid, DateTime periodStart, DateTime periodEnd, Action callback) { ServiceFacade.DoAccountingServiceAsync( s => s.GetSettlementInvoicesForCostBearerAndPeriod(costBearerOid, periodStart, periodEnd), r => { r.Sort( (dc1, dc2) => { if (dc2.InvoiceDate == null) { return -1; } if (dc1.InvoiceDate == null) { return 1; } return dc2.InvoiceDate.Value.CompareTo(dc1.InvoiceDate.Value); }); callback(new SettlementListVM(r)); }); } public static void CreateSettlementListForSupportConceptVMAsync(long supportconceptOid, Action callback) { ServiceFacade.DoAccountingServiceAsync( s => s.GetSettlementInvoicesForSupportConcept(supportconceptOid), r => { r.Sort( (dc1, dc2) => { if (dc2.InvoiceDate == null) { return -1; } if (dc1.InvoiceDate == null) { return 1; } return dc2.InvoiceDate.Value.CompareTo(dc1.InvoiceDate.Value); }); callback(new SettlementListVM(r)); }); } public static void CreateSettlementVMAsync(long pSupportConcept2CostBearerOid, Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s => s.GenerateInitialSettlementDC(pSupportConcept2CostBearerOid), r => pCallBack(new SettlementVM(r))); } public static void CreateSupportConceptCostBearerRelVMAsync(List pList, ObservableSortCollection budgets, Action pCallBack) { pCallBack(new SupportConceptCostBearerRelListVM(pList, budgets)); } public static void CreateSupportConceptGoalListVMAsync(ValueListEntryType pType, ValueListEntryType pParentType, Action pCallBack) { Cache.GetInstance().GetAllValueListEntrysByTypeAsync(pType, r1 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync(pParentType, r2 => pCallBack(new SupportConceptGoalListVM(r1, r2)))); } public static void CreateSupportConceptVMAsync(Action pCallback) { CreateSupportConceptVMAsync(new SupportConceptDC(), pCallback, true); } public static void CreateSupportConceptVMAsync(long pOid, Action pCallback) { ServiceFacade.DoCustomerServiceAsync(s => s.LoadSupportConcept(pOid), r => CreateSupportConceptVMAsync(r, pCallback, false)); } public static void CreateSupportConceptVMAsync(SupportConceptDC dc, Action pCallBack, bool initOriginator) { Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.SupportConceptGoalCategoryType, r1 => Cache.GetInstance().GetAllValueListEntrysByTypeAsync( ValueListEntryType.SupportConceptGoalType, r2 => Cache.GetInstance().GetServiceCategoryDescriptionDict( dict => ServiceFacade.DoOperationsServiceAsync(s => s.GetAllBudgets(), r3 => { var vm = new SupportConceptVM(dc, r1, r2, dict, r3); if (initOriginator) { vm.Originator = BeWoApp.LoggedOnUser.Employee; } pCallBack(vm); })))); } public static void CreateTeamVMAsync(Action pCallBack) { pCallBack(new TeamVM(new TeamDC())); } public static void CreateTeamVMAsync(long pTeamOid, Action pCallBack) { ServiceFacade.DoEmployeeServiceAsync(s => s.LoadTeam(pTeamOid), cb => pCallBack(new TeamVM(cb))); } public static void CreateGroupOfPeopleVMAsync(Action pCallBack) { pCallBack(new GroupOfPeopleVM(new GroupOfPeopleDC())); } public static void CreateGroupOfPeopleVMAsync(long pGroupOfPeopleOid, Action pCallBack) { ServiceFacade.DoEmployeeServiceAsync(s => s.LoadGroupOfPeople(pGroupOfPeopleOid), cb => pCallBack(new GroupOfPeopleVM(cb))); } public static void CreateGroupOfPeopleListVMAsync(Action pCallBack) { ServiceFacade.DoEmployeeServiceAsync(s => s.GetAllGroups(BeWoApp.LoggedOnEmployee.EmployeeOid), cb => pCallBack(new GroupOfPeopleListVM(cb))); } public static void CreateAdditinoalServiceGroupOfPeopleListVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s => s.GetAllAdditionalServiceGroupOfPeople(), cb => pCallBack(new AdditionalServiceGroupOfPeopleListVM(cb))); } public static void CreateUserGroupVMAsync(long pOid, Action pCallBack) { ServiceFacade.DoUserServiceAsync(s => s.LoadUserGroup(pOid), r => pCallBack(new UserGroupVM(r)), true); } public static void CreateUserGroupVMAsync(Action pCallBack) { pCallBack(new UserGroupVM(new UserGroupDC())); } public static void CreateUserVMAsync(long pUserOid, Action pCallBack) { ServiceFacade.DoUserServiceAsync(s => s.LoadUser(pUserOid), r1 => ServiceFacade.DoUserServiceAsync(s => s.GetAllUserGroups(), r2 => pCallBack(new UserVM(r1, r2)), true), true); } public static void CreateUserVMAsync(Action pCallBack) { ServiceFacade.DoUserServiceAsync(s => s.GetAllUserGroups(), cb => pCallBack(new UserVM(new UserDC(), cb)), true); } public static void CreateValueListVMAsync(ValueListEntryType pType, Action pCallBack) { ServiceFacade.DoValueListServiceAsync(s => s.GetAllValueListEntrysByType(pType), r => pCallBack(new ValueListEntryListVM(pType, r))); } public static void CreateGoalCategoryVMAsync(Action pCallBack, bool pIsIncludingIndividualGoals = false) { var typeList = new List { ValueListEntryType.SupportConceptGoalType, ValueListEntryType.SupportConceptGoalCategoryType }; if (pIsIncludingIndividualGoals) { typeList.Add(ValueListEntryType.SupportConceptIndividualGoalCategoryType); typeList.Add(ValueListEntryType.SupportConceptIndividualGoalType); } ServiceFacade.DoValueListServiceAsync( s => s.GetAllValueListEntrysByTypes(typeList), cb => pCallBack(new GenericValueListEntryListVM(cb))); } public static void CreateEmploymentTypeListVMAsync(Action pCallBack) { ServiceFacade.DoEmployeeServiceAsync(s => s.GetAllEmploymentTypes(), r => pCallBack(new EmploymentTypeListVM(r))); } private static void InternalCreateCustomerVM(CustomerDC pCustomerDC, Action pCallBack) { var list = new List { ValueListEntryType.DisabilityType, ValueListEntryType.CustomerCareType, ValueListEntryType.PlacementObjectiveType, ValueListEntryType.TerminationReasonType, ValueListEntryType.Nationality, ValueListEntryType.Aufenthaltsstatus, ValueListEntryType.RoleInFamily, ValueListEntryType.NotizenKategorieCustomer, ValueListEntryType.EinkommenBeginnType, ValueListEntryType.EinkommenEndeType, ValueListEntryType.FremdHilfeType, ValueListEntryType.SozSchwierigkeitenType, ValueListEntryType.SozBeziehungenType, ValueListEntryType.ErstaufnahmeType, ValueListEntryType.RegionType, }; ServiceFacade.DoValueListServiceAsync( s => s.GetAllValueListEntrysByTypes(list), cb => ServiceFacade.DoEmployeeServiceAsync(s2 => s2.GetAllAssessmentSheetCategories(), cb2 => ServiceFacade.DoEmployeeServiceAsync(s3 => s3.GetAllAssessmentSheetValues(), cb3 => ServiceFacade.DoCustomerServiceAsync(s4 => s4.GetAllMedArten(), cb4 => pCallBack(new CustomerVM(pCustomerDC, cb, cb2, cb3, cb4)))))); } public static void CreateAppointmentCategoryListVMAsync(Action pCallBack) { ServiceFacade.DoCustomerServiceAsync( s => s.GetAllAppointmentCategories(), cats => pCallBack(new AppointmentCategoryListVM(cats))); } public static WohnheimbuchungEmployeeRelListVM CreateEmployeeWohnheimbuchungsListVM(IEnumerable pList) { return new WohnheimbuchungEmployeeRelListVM(pList); } public static Wohnheimbuchung2Costbearer2SupportConceptRelListVM CreateSupportConceptWohnheimbuchungsListVM(IEnumerable pList) { return new Wohnheimbuchung2Costbearer2SupportConceptRelListVM(pList); } public static void CreateWohnheimbuchungsVMAsync(long? pOid, Action pCallBack) { Cache.GetInstance().GetServiceCategoryDescriptionDict( dict => { if (pOid == null) { pCallBack(new WohnheimbuchungsVM(new WohnheimbuchungDC(), dict)); } else { ServiceFacade.DoCustomerServiceAsync(s => s.GetWohnheimbuchung(pOid.Value), cb => pCallBack(new WohnheimbuchungsVM(cb, dict))); } }); } public static SupportConceptApprovalPeriodEmployeeRelListVM CreateSupportConceptApprovalPeriodEmployeeRelListVM(IEnumerable pList) { return new SupportConceptApprovalPeriodEmployeeRelListVM(pList); } public static ArbeitszeitEintragListVM CreateArbeitszeitEintragListVm(IEnumerable pList) { return new ArbeitszeitEintragListVM(pList); } public static void CreateSbdAdminVMAsync(Action pCallBack) { ServiceFacade.DoOperationsServiceAsync(s => s.GetSbdConfig(), r => { pCallBack(new SbdConfigVM(r)); }); } public static List CreateSupportConceptList() { List allSupportConcepts = new List(); List activeSupportConcepts = new List(); allSupportConcepts = ServiceFacade.DoCustomerServiceSync( s => s.GetAllSupportConceptsCompact(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); foreach (var sc in allSupportConcepts) { if (!sc.IsDeleted) activeSupportConcepts.Add(sc); } return activeSupportConcepts; } public static List CreateCustomerList() { List allCustomers = new List(); List activeCustomers = new List(); allCustomers = ServiceFacade.DoCustomerServiceSync( s => s.GetAllCustomersCompact(BeWoApp.LoggedOnUser.Employee.EmployeeOid)); foreach (var customer in allCustomers) { if (!customer.IsDeleted) activeCustomers.Add(customer); } return activeCustomers; } public static List CreateOrganisationList() { List allOrganisations = new List(); allOrganisations = ServiceFacade.DoCustomerServiceSync(s => s.GetAllActiveOrganisationsCompact()); return allOrganisations; } public static List CreatePeopleList() { List allPeople = new List(); List activePeople = new List(); allPeople = ServiceFacade.DoCustomerServiceSync(s => s.GetAllPersonsByTypeCompact(PersonType.Others)); foreach (var person in allPeople) { if (!person.IsDeleted) activePeople.Add(person); } return activePeople; } public static List CreateEmployeeList() { List allEmployee = new List(); allEmployee = ServiceFacade.DoEmployeeServiceSync(s => s.GetAllActiveEmployeesCompact()); return allEmployee; } public static List CreateTeamList() { List allTeams = new List(); allTeams = ServiceFacade.DoEmployeeServiceSync(s => s.GetAllTeamsCompact()); return allTeams; } public static List CreateUserList() { List allUsers = new List(); allUsers = ServiceFacade.DoUserServiceSync(s => s.GetAllUsersCompact()); return allUsers; } public static List CreateUserGroupList() { List allUserGroups = new List(); allUserGroups = ServiceFacade.DoUserServiceSync(s => s.GetAllUserGroups()); return allUserGroups; } public static List CreateFolderList(TableID tid, long objectOid) { List folderList = new List(); folderList = ServiceFacade.DoOperationsServiceSync(s => s.GetFolderTree(tid, objectOid)); return folderList; } public static void CreateWohneinheitListVMs(List dcs, out WohneinheitListVM einheit_vm_list, out WohneinheitBelegungListVM beleg_vm_list) { einheit_vm_list = new WohneinheitListVM(dcs); var beleg_dc_list = new List(); var beleg_dc2einheit_vm = new Dictionary(); foreach (var einheit_vm in einheit_vm_list.VMList) { var einheit_dc = einheit_vm.DataContract; if (einheit_dc.Belegungen is null) continue; foreach (var beleg_dc in einheit_dc.Belegungen) { beleg_dc_list.Add(beleg_dc); beleg_dc2einheit_vm.Add(beleg_dc, einheit_vm); } } beleg_vm_list = new WohneinheitBelegungListVM(beleg_dc_list.OrderBy(x => x.Oid).ToList()); foreach (var beleg_vm in beleg_vm_list.VMList) { var beleg_dc = beleg_vm.DataContract; beleg_vm.Wohneinheit = beleg_dc2einheit_vm[beleg_dc]; } einheit_vm_list.VMList.Sort(WohneinheitVM.Compare); } public static AiConversationChatViewModel CreateAiConversationChatViewModel(AiActionType actionType, AiViewContextDC view_context, List assistentCommands = null, bool canSendNewMessage = true) { var vm = new AiConversationChatViewModel(); vm.ActionType = actionType; vm.ViewContext = view_context; vm.CanSendNewMessage = canSendNewMessage; vm.ImportAssistentCommandCopy(); if (assistentCommands is object) { foreach (var command in assistentCommands) { vm.ImportAssistentCommand(command); } } return vm; } public static AiConversationListVM CreateAiConversationListVM(AiActionType actionType, long? reference_oid) { var list = ServiceFacade.DoAiEnhancedServiceSnyc(s => s.GetAiConversations(actionType, reference_oid)); return new AiConversationListVM(list); } public static void CreateAiConversationListVMAsync(AiActionType actionType, long? reference_oid, Action callback) { ServiceFacade.DoAiEnhancedServiceAsnyc( s => s.GetAiConversations(actionType, reference_oid), cb => { cb.Reverse(); callback(new AiConversationListVM(cb)); }); } internal static void CreateAiPromptbausteinFolderListVMAsync(AiActionType aiActionType, Action get_viewmodel) { ServiceFacade.DoAiEnhancedServiceAsnyc( req => req.GetAiPromptbausteinFolder(aiActionType), res => CreateAiPromptbausteinFolderListVM(res, get_viewmodel)); } internal static void CreateAiPromptbausteinFolderListVM(List res, Action get_viewmodel) { var listvm = new AiPromptbausteinFolderListVM(res); reloadFavoriten(listvm); get_viewmodel(listvm); } static void reloadFavoriten(AiPromptbausteinFolderListVM folders) { var favoriten = new AiPromptbausteinFolderDC() { Oid = -5, Title = "Favoriten", Description = "Eigene Favoriten", SubPrompts = new List(), SubRoutines = new List() }; var fav_vm = new AiPromptbausteinFolderVM(favoriten); fav_vm.SubPrompts.VMList.Clear(); fav_vm.SubRoutines.VMList.Clear(); folders.VMList.Insert(0, fav_vm); findFavoriten(folders, fav_vm); } static void findFavoriten(AiPromptbausteinFolderListVM folders, AiPromptbausteinFolderVM favoriten) { foreach (var folder in folders.VMList) { if (folder == favoriten) continue; if (folder.SubFolders?.VMList.Any() ?? false) findFavoriten(folder.SubFolders, favoriten); foreach (var prompt in folder.SubPrompts.VMList) { if (prompt.IsFavorite) favoriten.SubPrompts.VMList.Add(prompt); } foreach (var routine in folder.SubRoutines.VMList) { if (routine.IsFavorite) favoriten.SubRoutines.VMList.Add(routine); } } } } }