2026-03-02 11:19:28 +01:00
using BeWoPlanerMobil.Models ;
2021-08-19 17:22:04 +02:00
using BeWoPlanerMobil.Service ;
2026-03-04 12:21:19 +01:00
using BeWoPlanerMobil.Util ;
using BeWoPlanerMobil.Util.Constants ;
using BeWoPlanerMobil.Util.SchedulerUtils ;
2021-08-19 17:22:04 +02:00
using BeWoPlanerMobil.Views.DevExpressScheduler ;
2026-03-02 11:19:28 +01:00
using BS.Shared ;
using BS.Shared.Core ;
2021-08-19 17:22:04 +02:00
using BS.Shared.DataContracts ;
2026-03-02 11:19:28 +01:00
using BS.Shared.DataContracts.Compact ;
using BS.Shared.Extensions ;
2021-08-19 17:22:04 +02:00
using DevExpress.Web.Mvc ;
2026-03-02 11:19:28 +01:00
using DevExpress.XtraScheduler ;
using Newtonsoft.Json ;
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Web.Mvc ;
2026-06-29 13:45:15 +02:00
using CompactCustomerDC = BS . Shared . DataContracts . Compact . CompactCustomerDC ;
2021-08-19 17:22:04 +02:00
namespace BeWoPlanerMobil.Controllers
{
2026-03-02 11:19:28 +01:00
/ *
* ToDo :
2026-06-29 13:45:15 +02:00
* Ü bersetzungen
2026-03-02 11:19:28 +01:00
* /
2021-08-19 17:22:04 +02:00
public class DevExpressSchedulerController : AbstractBaseController
{
2026-03-02 11:19:28 +01:00
[Authorize]
public override string SaveCollapsibleStatus ( bool isOpen , string identifier )
{
return SaveCollapsibleStatusToModel ( Model , isOpen , identifier ) ;
}
2021-08-19 17:22:04 +02:00
private DevExpressSchedulerModel _Model ;
public DevExpressSchedulerModel Model
{
get
{
2025-07-18 19:37:01 +02:00
if ( false = = MobileSessionFacade . IsUserLoggedIn ( ) )
2021-08-19 17:22:04 +02:00
{
Logout ( ) ;
return null ;
}
2025-07-18 19:37:01 +02:00
if ( _Model ! = null )
2021-08-19 17:22:04 +02:00
{
2025-07-18 19:37:01 +02:00
return _Model ;
2021-08-19 17:22:04 +02:00
}
2025-07-18 19:37:01 +02:00
_Model = new DevExpressSchedulerModel ( ) ;
InitModel ( _Model ) ;
2026-03-02 11:19:28 +01:00
InitViewModel ( ) ;
2021-08-19 17:22:04 +02:00
return _Model ;
}
}
2026-03-02 11:19:28 +01:00
private AppointmentModel _AppointmentModel ;
public AppointmentModel AppointmentModel
{
get
{
if ( false = = MobileSessionFacade . IsUserLoggedIn ( ) )
{
Logout ( ) ;
return null ;
}
if ( _AppointmentModel ! = null )
{
return _AppointmentModel ;
}
_AppointmentModel = new AppointmentModel ( ) ;
InitModel ( _AppointmentModel ) ;
InitAppointmentModel ( ) ;
return _AppointmentModel ;
}
}
private void InitAppointmentModel ( )
{
AppointmentModel . PossibleEmployees = EmployeeService . GetAllAuthorizedCompactEmployees ( ) ;
AppointmentModel . PossibleCustomers = CustomerService . GetAllAuthorizedCompactCustomers ( ) ;
AppointmentModel . PossibleResources = KalenderService . GetAllResources ( ) ;
2026-05-08 11:05:48 +02:00
AppointmentModel . ResourceCategories2Resources = new Dictionary < ValueListEntryDC , List < ResourceDC > > ( ) ;
foreach ( var resource in AppointmentModel . PossibleResources )
{
AppointmentModel . ResourceCategories2Resources . AddOrUpdateValueInDictionary ( resource . ResourceCategory , resource ) ;
}
2026-03-02 11:19:28 +01:00
}
private void InitViewModel ( )
{
2026-04-28 12:01:37 +02:00
if ( false = = MobileSessionFacade . IsUserLoggedIn ( ) | | Request . Browser . Browser . Equals ( "InternetExplorer" ) | | Model ? . LoggedInUser ? . Employee is null )
2026-03-02 11:19:28 +01:00
{
Logout ( ) ;
return ;
}
2026-04-28 12:01:37 +02:00
var user = Model . LoggedInUser ;
var compactEmployee = user . Employee ;
var employeeOid = compactEmployee . EmployeeOid ;
var userSettings = user . Settings . FirstOrDefault ( f = > f . Type . Equals ( SettingsType . ApplicationSettings ) ) ? . Value ;
2026-04-15 11:29:51 +02:00
Model . ShowOnlyMyOwnAppointments = UserSettingsUtils . GetSettingValueAsBool ( userSettings , SettingsKeys . ZeigeNurMeineTermine ) ;
2026-04-28 12:01:37 +02:00
if ( Model . ShowOnlyMyOwnAppointments )
2026-04-15 11:29:51 +02:00
{
2026-04-28 12:01:37 +02:00
Model . SelectedEmployeeOidsForFiltering = new List < long > { employeeOid } ;
2026-04-15 11:29:51 +02:00
}
2026-06-29 13:45:15 +02:00
// Nach den Kalenderrechten filtern!
2026-03-02 11:19:28 +01:00
Model . PossibleEmployees = EmployeeService . GetAllAuthorizedCompactEmployees ( ) ;
Model . PossibleCustomers = CustomerService . GetAllAuthorizedCompactCustomers ( ) ;
Model . PossibleResources = KalenderService . GetAllResources ( ) ;
2026-07-09 11:39:24 +02:00
// Ressourcen
2026-03-23 15:23:00 +01:00
if ( Model . HasRightToInsertRessourceAppointments | | Model . HasRightToViewAllResourceAppointments )
{
var allResources = KalenderService . GetAllResources ( ) . OrderBy ( r = > r . Name ) . ToList ( ) ;
var categories2Resources = new Dictionary < ValueListEntryDC , List < ResourceDC > > ( ) ;
foreach ( var category in allResources . Select ( resource = > resource . ResourceCategory ) )
{
categories2Resources . AddOrUpdateValueInDictionary ( category , allResources . Where ( resource = > resource . ResourceCategory . Equals ( category ) ) . OrderBy ( r = > r . Name ) . ToList ( ) ) ;
}
2026-04-28 12:01:37 +02:00
Model . ResourceCategories2Resources = categories2Resources . OrderBy ( category2Resources = > category2Resources . Key . DisplayName ) . ToDictionary ( kvp = > kvp . Key , kvp = > kvp . Value ) ;
2026-03-23 15:23:00 +01:00
}
2026-07-09 11:39:24 +02:00
// Teams
2026-04-28 12:01:37 +02:00
Model . MyTeamEmployees = EmployeeService . GetAllTeamMember ( compactEmployee ) . OrderBy ( employee = > employee . LastName ) . ToList ( ) ;
2026-03-23 15:23:00 +01:00
2026-04-28 12:01:37 +02:00
if ( Model . HasRightToViewTeams )
2026-03-23 15:23:00 +01:00
{
2026-04-28 12:01:37 +02:00
Model . MyTeams = EmployeeService . GetAllActiveCompactTeamsForEmployee ( employeeOid ) . OrderBy ( team = > team . Name ) . ToList ( ) ;
2026-03-23 15:23:00 +01:00
}
2026-04-28 12:01:37 +02:00
Model . TeamMemberCustomerOids = EmployeeService . LoadTeamsRelatedCustomerOids ( employeeOid ) ;
2026-07-09 11:39:24 +02:00
// /Teams
2026-03-23 15:23:00 +01:00
Model . SelectedEmployeesForFiltering = Model . PossibleEmployees . Where ( possibleEmployee = > Model . SelectedEmployeeOidsForFiltering ? . Contains ( possibleEmployee . EmployeeOid ) ? ? false ) . ToList ( ) ;
Model . SelectedCustomersForFiltering = Model . PossibleCustomers . Where ( possibleCustomer = > Model . SelectedCustomerOidsForFiltering ? . Contains ( possibleCustomer . CustomerOid ) ? ? false ) . ToList ( ) ;
Model . SelectedResourcesForFiltering = Model . PossibleResources . Where ( possibleResource = > possibleResource . ResourceOid . HasValue & & ( Model . SelectedResourceOidsForFiltering ? . Contains ( possibleResource . ResourceOid . Value ) ? ? false ) ) . ToList ( ) ;
2026-03-02 11:19:28 +01:00
ReloadAppointments ( ) ;
}
private void ReloadAppointments ( )
{
if ( Model . LoggedInEmployee . EmployeeOid is null )
{
2026-03-18 18:05:58 +01:00
throw new Exception ( "Bei DevExpressSchedulerController.ReloadAppointments() ist die Oid des angemeldeten Benutzers wider Erwarten NULL!" ) ;
2026-03-02 11:19:28 +01:00
}
2026-03-23 15:23:00 +01:00
UpdateSelectedObjects ( ) ;
2026-03-02 11:19:28 +01:00
var user = LoggedInUser ;
2026-04-28 12:01:37 +02:00
var employeeOid = user . Employee . EmployeeOid ;
var userSettings = user . Settings . FirstOrDefault ( f = > f . Type . Equals ( SettingsType . ApplicationSettings ) ) ? . Value ;
2026-03-02 11:19:28 +01:00
2026-06-29 13:45:15 +02:00
var relatedCustomerOids = user . Employee . RelatedCustomerOIDList ;
2026-03-02 11:19:28 +01:00
Model . CurrentViewType = ( SchedulerViewType ) UserSettingsUtils . GetSettingValueAsInteger ( userSettings , SettingsKeys . SchedulerViewType ) ;
var intervalStart = DateTimeExtensions . GetDayOfWeek ( DayOfWeek . Monday ) ;
var intervalEnd = intervalStart . AddDays ( 7 ) ;
2026-07-09 11:39:24 +02:00
var allAppointments = KalenderService . LoadFilteredAppointmentsMitAufgabenForMoK
2026-03-02 11:19:28 +01:00
(
Model . HasRightKalenderMitarbeitertermineAnsehen ,
2026-03-18 18:05:58 +01:00
employeeOid ,
2026-03-02 11:19:28 +01:00
intervalStart ,
intervalEnd ,
2026-03-23 15:23:00 +01:00
Model . SelectedEmployeeOidsForFiltering ,
Model . SelectedCustomerOidsForFiltering ,
Model . SelectedResourceOidsForFiltering ,
Model . ShowOnlyEmployees ,
Model . ShowOnlyCustomers ,
Model . ShowOnlyResources ,
2026-04-15 11:29:51 +02:00
Model . ShowOnlyPrivateAppointments ,
2026-03-23 15:23:00 +01:00
Model . ShowOnlyMyOwnAppointments ,
Model . ShowTasks
2026-03-02 11:19:28 +01:00
) ;
2026-06-29 13:45:15 +02:00
var appointments = allAppointments ;
2026-07-16 16:01:13 +02:00
var changedOrDeletedOccurrences = KalenderService . FindAppointmentsByRecurrenceId ( appointments . Select ( apt = > apt . RecurrenceId ) . ToList ( ) , true ) ;
Model . RecurrenceIdsWithOccurrences = new List < string > ( ) ;
foreach ( var occ in changedOrDeletedOccurrences )
{
Model . RecurrenceIdsWithOccurrences . AddIfNotIn ( occ . RecurrenceIdReference ) ;
}
2026-06-29 13:45:15 +02:00
foreach ( var appointment in appointments )
{
if ( false = = appointment . IsPrivate | | appointment . Originator . EmployeeOid . Equals ( employeeOid ) | | appointment . EmployeeList . Any ( e = > e . Employee . EmployeeOid . Equals ( employeeOid ) ) )
{
continue ;
}
appointment . Description = "Privater Termin" ;
appointment . Subject = $"Privat ({appointment.Originator})" ;
appointment . CanBeDeleted = false ;
appointment . CanBeEdited = false ;
appointment . CanBeViewed = false ;
}
// Den Rechten entsprechend filtern
if ( Model . HasRightKalenderKliententermineAnsehen is false )
{
var relatedCustomers = Model . LoggedInEmployee . RelatedCustomers . Select ( s = > s . Customer ) ;
var filteredAppointments = new List < SchedulerAppointmentDC > ( ) ;
// Nur die der eigenen Klienten nicht filtern?
appointments = appointments . Where ( appointment = >
appointment . IsTask is false & &
appointment . IsAbsenceTime is false & &
appointment . CustomerList . Any ( customer = > relatedCustomers . Contains ( customer ) ) | |
appointment . CustomerList . Count = = 0
) . ToList ( ) ;
foreach ( var appointment in appointments )
{
if ( appointment . CustomerList . Any ( ) & & false = = appointment . CustomerList . Any ( customer = > relatedCustomers . Contains ( customer ) ) )
{
continue ;
}
filteredAppointments . Add ( appointment ) ;
}
2026-03-18 18:05:58 +01:00
2026-06-29 13:45:15 +02:00
appointments = filteredAppointments ;
}
if ( Model . HasRightKalenderMitarbeitertermineAnsehen is false )
{
appointments = appointments . Where ( appointment = >
appointment . IsTask is false & &
appointment . IsAbsenceTime is false & &
( appointment . Originator . Equals ( Model . LoggedInCompactEmployee ) | | appointment . EmployeeList . Any ( employee2Appointment = > employee2Appointment . Employee . Equals ( Model . LoggedInCompactEmployee ) ) )
) . ToList ( ) ;
}
if ( Model . HasRightKalenderRessourcentermineAnsehen is false )
{
appointments = appointments . Where ( appointment = >
appointment . IsTask is false & &
appointment . IsAbsenceTime is false & &
appointment . ResourceList . Count = = 0
) . ToList ( ) ;
}
if ( Model . ShowTasks is false )
{
appointments = appointments . Where ( appointment = > appointment . IsTask is false ) . ToList ( ) ;
}
else
{
appointments . AddRangeIfElementsNotIn ( allAppointments . Where ( appointment = > appointment . IsTask ) ) ;
}
if ( Model . ShowEmployeeColors )
{
appointments . DoForEach ( appointment = > appointment . ShowEmployeeColors = true ) ;
}
var customerAbsenceTimes = KalenderService . GetAllActiveCustomersAbsenceTimesInInterval ( intervalStart , intervalEnd , employeeOid , Model . SelectedCustomerOidsForFiltering ) ;
var employeeAbsenceTimes = KalenderService . GetAllActiveEmployeeAbsenceTimesInInterval ( intervalStart , intervalEnd , employeeOid , Model . SelectedEmployeeOidsForFiltering ) ;
2026-03-18 18:05:58 +01:00
2026-04-15 11:29:51 +02:00
if ( Model . ShowAbsenceTimes )
{
var allAbsenceTimes = new List < AbsenceTimeDC > ( ) ;
allAbsenceTimes . AddRange ( customerAbsenceTimes ) ;
allAbsenceTimes . AddRange ( employeeAbsenceTimes ) ;
2026-03-18 18:05:58 +01:00
2026-04-15 11:29:51 +02:00
appointments . AddRange ( ConvertAbsenceTimesToAppointments ( allAbsenceTimes , Model . PossibleCustomers , Model . PossibleEmployees ) ) ;
}
2026-03-18 18:05:58 +01:00
2026-06-29 13:45:15 +02:00
if ( Model . HasRightKalenderRessourcenTermineAndererAendern is false )
{
appointments
2026-07-09 11:39:24 +02:00
. Where ( appointment = >
appointment . IsTask is false & &
appointment . IsAbsenceTime is false & &
appointment . Originator . Equals ( Model . LoggedInCompactEmployee ) is false & & appointment . ResourceList . Any ( ) )
2026-06-29 13:45:15 +02:00
. DoForEach ( appointment = > appointment . CanBeEdited = false ) ;
}
if ( Model . HasRightKalenderKlientenTermineAendern is false )
{
appointments
2026-07-09 11:39:24 +02:00
. Where ( appointment = >
appointment . IsTask is false & &
appointment . IsAbsenceTime is false & &
appointment . Originator . Equals ( Model . LoggedInCompactEmployee ) is false & & appointment . CustomerList . Any ( ) )
2026-06-29 13:45:15 +02:00
. DoForEach ( appointment = > appointment . CanBeEdited = false ) ;
}
if ( Model . HasRightKalenderMitarbeiterTermineAendern is false )
{
appointments
2026-07-09 11:39:24 +02:00
. Where ( appointment = >
appointment . IsTask is false & &
appointment . IsAbsenceTime is false & &
appointment . Originator . Equals ( Model . LoggedInCompactEmployee ) is false )
2026-06-29 13:45:15 +02:00
. DoForEach ( appointment = > appointment . CanBeEdited = false ) ;
}
2026-07-09 11:39:24 +02:00
foreach ( var appointment in appointments . Where ( apt = > apt . IsTask is false & & apt . IsAbsenceTime is false & & apt . Originator . Equals ( Model . LoggedInCompactEmployee ) is false & & apt . CustomerList . Any ( ) ) )
{
var canEdit = appointment . CanBeEdited ;
var canView = appointment . CanBeViewed ;
var canDelete = appointment . CanBeDeleted ;
var subject = appointment . Subject ;
}
var x = appointments . Where ( w = > w . SchedulerAppointmentOid is null ) . ToList ( ) ;
2026-03-02 11:19:28 +01:00
Model . Appointments = appointments ;
2026-04-15 11:29:51 +02:00
LoadNotificationCount ( ) ;
}
[Authorize]
public ActionResult GetNotifications ( )
{
LoadNotificationCount ( ) ;
return PartialView ( "SchedulerNotificationPartial" , Model ) ;
}
2026-04-28 12:01:37 +02:00
private void LoadNotificationCount ( )
2026-04-15 11:29:51 +02:00
{
2026-06-29 13:45:15 +02:00
var openAppointments = KalenderService . GetAllOpenAppointmentsForEmployee ( LoggedInUser . Employee . EmployeeOid ) . OrderBy ( openAppointment = > openAppointment . StartDate ) . ToList ( ) ;
var employee2Appointments = new List < Employee2SchedulerAppointmentDC > ( ) ;
foreach ( var appointment in openAppointments )
2026-04-28 12:01:37 +02:00
{
2026-06-29 13:45:15 +02:00
// Termine, die von anderen Beantwortet wurden:
employee2Appointments . AddRangeIfElementsNotIn ( appointment . EmployeeList . Where ( e2a = >
appointment . Originator . Equals ( Model . LoggedInCompactEmployee ) & &
false = = e2a . Employee . Equals ( Model . LoggedInCompactEmployee ) & &
e2a . IsPChanged & &
e2a . IsPC_CheckedTs is null & &
e2a . ParticipationAnswer ! = ParticipationAnswer . Offen & &
e2a . ParticipationAnswer ! = ParticipationAnswer . Verstrichen
) ) ;
// Termine zum Beantworten:
employee2Appointments . AddRangeIfElementsNotIn ( appointment . EmployeeList . Where ( e2A = >
false = = appointment . Originator . Equals ( Model . LoggedInCompactEmployee ) & &
false = = e2A . IsPChanged & &
e2A . Employee . Equals ( Model . LoggedInCompactEmployee )
) ) ;
2026-04-28 12:01:37 +02:00
}
2026-04-15 11:29:51 +02:00
2026-06-29 13:45:15 +02:00
Model . OpenEmployee2AppointmentRels = new List < Employee2SchedulerAppointmentDC > ( ) ;
Model . OpenEmployee2AppointmentRelOids = new List < long > ( ) ;
Model . OpenAppointments = openAppointments ;
Model . OpenAppointmentOids = openAppointments
. Where ( schedulerAppointment = > schedulerAppointment . SchedulerAppointmentOid . HasValue )
. Select ( schedulerAppointment = > schedulerAppointment . SchedulerAppointmentOid . Value )
. ToList ( ) ;
Model . OpenEmployee2AppointmentRels . AddRange ( employee2Appointments ) ;
Model . OpenEmployee2AppointmentRelOids = employee2Appointments . Where ( w = > w . Employee2SchedulerAppointmentOid . HasValue ) . Select ( s = > s . Employee2SchedulerAppointmentOid . Value ) . ToList ( ) ;
2026-03-02 11:19:28 +01:00
}
2026-03-18 18:05:58 +01:00
private List < SchedulerAppointmentDC > ConvertAbsenceTimesToAppointments ( List < AbsenceTimeDC > absenceTimes , List < CompactCustomerDC > allCustomers , List < CompactEmployeeDC > allEmployees )
{
var appointments = new List < SchedulerAppointmentDC > ( ) ;
foreach ( var absenceTime in absenceTimes )
{
var subject = $"{absenceTime.Reason.Description}" ;
var employee = absenceTime . EmployeeOid . HasValue ? allEmployees . FirstOrDefault ( f = > f . EmployeeOid = = absenceTime . EmployeeOid . Value ) : null ;
var customer = absenceTime . CustomerOid . HasValue ? allCustomers . FirstOrDefault ( f = > f . CustomerOid = = absenceTime . CustomerOid . Value ) : null ;
var allDay = absenceTime . IsAllDay ;
var isEmployeeAbsenceTime = absenceTime . EmployeeOid . HasValue ;
IFilterableDC dc = employee ;
var originator = employee ;
if ( false = = isEmployeeAbsenceTime )
{
dc = customer ;
originator = EmployeeService . FindCompactEmployeeByFullname ( absenceTime . InsUser ) ;
}
if ( false = = dc is null )
{
subject + = $" ({dc.SimpleDescription})" ;
}
var absenceTimeEnd = absenceTime . End ;
var end = absenceTime . End ? ? DateTime . MaxValue ;
var isMultipleDayAbsenceTime = absenceTime . End is null | | absenceTime . Start . Value . Date ! = absenceTime . End . Value . Date ;
if ( isMultipleDayAbsenceTime & & allDay & & end ! = DateTime . MaxValue )
{
absenceTimeEnd = end . AddDays ( 1 ) ;
}
if ( originator is null )
{
originator = LoggedInUser . Employee ;
}
var appointment = new SchedulerAppointmentDC
{
AbsenceReason = absenceTime . Reason ,
AllDay = true ,
Description = absenceTime . Notice ,
StartDate = absenceTime . Start ,
EndDate = absenceTimeEnd ,
ActivationType = ActivationTypeId . Active ,
FormerAbsenceTimeOid = absenceTime . AbsenceTimeOid ,
Originator = originator ,
Subject = subject ,
2026-04-15 11:29:51 +02:00
Krankheitsmeldung = absenceTime . KrankheitsMeldung ,
IsAbsenceTime = true
2026-03-18 18:05:58 +01:00
} ;
if ( false = = customer is null & & employee is null )
{
appointment . CustomerList = new List < CompactCustomerDC > { customer } ;
}
appointments . Add ( appointment ) ;
}
return appointments ;
}
2021-08-19 17:22:04 +02:00
[Authorize]
public ActionResult DevExpressScheduler ( )
{
2026-03-27 15:14:20 +01:00
if ( false = = MobileSessionFacade . IsUserLoggedIn ( ) | | Model is null )
2021-08-19 17:22:04 +02:00
{
return RedirectToActionPermanent ( "Index" , "Login" ) ;
}
2025-07-18 19:37:01 +02:00
Model . Resources = new List < object > ( ) ;
2021-08-19 17:22:04 +02:00
return View ( Model ) ;
}
[Authorize]
public ActionResult SchedulerPagePartial ( )
{
return PartialView ( "SchedulerPagePartial" , Model ) ;
}
[Authorize]
public ActionResult EditAppointment ( )
{
UpdateAppointment ( ) ;
return PartialView ( "SchedulerPagePartial" , Model ) ;
}
[Authorize]
private void UpdateAppointment ( )
{
2026-03-02 11:19:28 +01:00
var appointmentsToInsert = SchedulerExtension . GetAppointmentsToInsert < SchedulerAppointmentDC > (
"scheduler" ,
Model . Appointments ,
SchedulerHelper . DefaultAppointmentStorage ,
SchedulerHelper . DefaultResourceStorage ) ;
var appointmentsToUpdate = SchedulerExtension . GetAppointmentsToUpdate < SchedulerAppointmentDC > (
"scheduler" ,
Model . Appointments ,
SchedulerHelper . DefaultAppointmentStorage ,
SchedulerHelper . DefaultResourceStorage
) ;
var appointmentsToRemove = SchedulerExtension . GetAppointmentsToRemove < SchedulerAppointmentDC > (
"scheduler" ,
Model . Appointments ,
SchedulerHelper . DefaultAppointmentStorage ,
SchedulerHelper . DefaultResourceStorage
) ;
foreach ( var appointment in appointmentsToInsert )
{
2026-07-16 16:01:13 +02:00
if ( appointment . Type ! = ( int ) AppointmentType . DeletedOccurrence & & appointment . Type ! = ( int ) AppointmentType . ChangedOccurrence )
2026-07-13 20:32:28 +02:00
{
appointment . CustomerList = AppointmentModel . SelectedCustomers ;
appointment . ResourceList = AppointmentModel . SelectedResources ;
appointment . EmployeeList = new List < Employee2SchedulerAppointmentDC > ( ) ;
2026-06-29 13:45:15 +02:00
2026-07-13 20:32:28 +02:00
foreach ( var selectedEmployee in AppointmentModel . SelectedEmployees ? ? new List < CompactEmployeeDC > ( ) )
{
appointment . EmployeeList . Add ( new Employee2SchedulerAppointmentDC { Employee = selectedEmployee } ) ;
}
2026-06-29 13:45:15 +02:00
2026-07-13 20:32:28 +02:00
appointment . Originator = Model . LoggedInUser . Employee ;
}
else
2026-06-29 13:45:15 +02:00
{
2026-07-13 20:32:28 +02:00
appointment . NewSchedulerAppointmentVersion = null ;
2026-06-29 13:45:15 +02:00
}
2026-03-02 11:19:28 +01:00
KalenderService . InsertSchedulerAppointment ( appointment ) ;
ViewData [ "EditableAppointmentModel" ] = appointment ;
}
foreach ( var appointment in appointmentsToUpdate )
{
if ( AppointmentModel . SelectedCustomers ! = null )
{
appointment . CustomerList = AppointmentModel . SelectedCustomers ;
}
if ( AppointmentModel . SelectedResources ! = null )
{
appointment . ResourceList = AppointmentModel . SelectedResources ;
}
if ( AppointmentModel . SelectedEmployees ! = null )
{
appointment . EmployeeList = new List < Employee2SchedulerAppointmentDC > ( ) ;
foreach ( var selectedEmployee in AppointmentModel . SelectedEmployees )
{
appointment . EmployeeList . Add ( new Employee2SchedulerAppointmentDC { Employee = selectedEmployee } ) ;
}
}
appointment . ActivationType = ActivationTypeId . Active ;
KalenderService . UpdateSchedulerAppointments ( new List < SchedulerAppointmentDC > { appointment } ) ;
}
2026-07-13 20:32:28 +02:00
var oid2Version = appointmentsToRemove
. Where ( appointment = > appointment . SchedulerAppointmentOid . HasValue & & appointment . NewSchedulerAppointmentVersion . HasValue )
. ToDictionary ( k = > k . SchedulerAppointmentOid . Value , v = > v . NewSchedulerAppointmentVersion . Value ) ;
KalenderService . DeleteSchedulerAppointments ( oid2Version ) ;
2026-03-02 11:19:28 +01:00
ReloadAppointments ( ) ;
}
2025-03-25 17:36:15 +01:00
[Authorize]
2026-03-02 11:19:28 +01:00
public string SelectActiveViewType ( string viewTypeName )
2025-03-25 17:36:15 +01:00
{
2026-03-02 11:19:28 +01:00
if ( Enum . TryParse < SchedulerViewType > ( viewTypeName , out var viewType ) )
{
Model . CurrentViewType = viewType ;
UpdateUserSettingsWithoutReload ( SettingsKeys . SchedulerViewType , ( ( int ) viewType ) . ToString ( ) ) ;
}
return LeerzeichenFuerGetMethoden ;
}
2026-04-15 11:29:51 +02:00
/// <summary>
2026-04-28 12:01:37 +02:00
/// Hierüber laufen Custom-Aufrufe des DevExpress-Schedulers ab. Im JavaScript mit scheduler.PerformCallback(...) aufrufen.
2026-04-15 11:29:51 +02:00
/// </summary>
/// <param name="apptID">Etwaige Id des Termin-Objekts</param>
/// <param name="actionId">Die Id der auszuführenden Methode</param>
/// <param name="args">Etwaige Parameter für die auszuführende Methode</param>
2026-04-28 12:01:37 +02:00
/// <returns>Entweder das Scheduler-Partial oder einen anderen Seitenaufruf.</returns>
2026-03-02 11:19:28 +01:00
[Authorize]
public ActionResult CustomCallbackAction ( string apptID , string actionId , string [ ] args )
{
2026-04-15 11:29:51 +02:00
switch ( actionId )
2026-03-02 11:19:28 +01:00
{
2026-04-15 11:29:51 +02:00
case "ToServiceRecord" :
return ToServiceRecord ( apptID , actionId , args ) ;
case "FilterAppointments" :
2026-04-28 12:01:37 +02:00
return FilterAppointments ( args ? . Length > = 1 ? args [ 0 ] : null ) ;
2026-04-15 11:29:51 +02:00
case "Reload" :
ReloadAppointments ( ) ;
break ;
2026-07-16 16:01:13 +02:00
case "DeleteSeries" :
DeleteAppointment ( ( ( List < SchedulerAppointmentDC > ) Model . Appointments ) . FirstOrDefault ( appointment = > appointment . SchedulerAppointmentOid = = long . Parse ( apptID ) ) ) ;
break ;
case "DeleteApt" :
DeleteAppointment ( ( ( List < SchedulerAppointmentDC > ) Model . Appointments ) . FirstOrDefault ( appointment = > appointment . SchedulerAppointmentOid = = long . Parse ( apptID ) ) ) ;
2026-06-29 13:45:15 +02:00
break ;
2026-07-16 16:01:13 +02:00
case "ResetSeries" :
var oid2Versions = KalenderService . LoadOccurrencesByRecurrenceId ( apptID ) . Where ( appointment = > appointment . RecurrenceIndexReference ! = null ) . ToDictionary ( x = > x . SchedulerAppointmentOid . Value , y = > y . NewSchedulerAppointmentVersion . Value ) ;
KalenderService . DeleteSchedulerAppointments ( oid2Versions ) ;
ReloadAppointments ( ) ;
break ;
2026-04-15 11:29:51 +02:00
}
2026-03-04 12:21:19 +01:00
2026-04-15 11:29:51 +02:00
return PartialView ( "SchedulerPagePartial" , Model ) ;
}
2026-03-02 11:19:28 +01:00
2026-07-16 16:01:13 +02:00
private void DeleteAppointment ( SchedulerAppointmentDC appointment2Delete )
{
if ( appointment2Delete is null | | appointment2Delete . SchedulerAppointmentOid is null | | appointment2Delete . NewSchedulerAppointmentVersion is null )
{
return ;
}
var oid2Version = new Dictionary < long , long > { { appointment2Delete . SchedulerAppointmentOid . Value , appointment2Delete . NewSchedulerAppointmentVersion . Value } } ;
KalenderService . DeleteSchedulerAppointments ( oid2Version ) ;
ReloadAppointments ( ) ;
}
2026-06-29 13:45:15 +02:00
private void CreateDummyAppointments ( )
{
var today = DateTime . Today ;
var day1 = today ;
var day2 = day1 . AddDays ( 1 ) ;
switch ( day2 . DayOfWeek )
{
case DayOfWeek . Saturday :
day2 = day1 . AddDays ( - 2 ) ; // Samstag -> Donnerstag
break ;
case DayOfWeek . Sunday :
day2 = day1 . AddDays ( - 3 ) ; // Sonntag -> Donnerstag
break ;
}
var day3 = day2 . AddDays ( 1 ) ;
switch ( day3 . DayOfWeek )
{
case DayOfWeek . Saturday :
day3 = day2 . AddDays ( - 2 ) ; // Samstag -> Donnerstag
break ;
case DayOfWeek . Sunday :
day3 = day2 . AddDays ( - 3 ) ; // Sonntag -> Donnerstag
break ;
}
var employees = EmployeeService . GetAllCompactEmployees ( ) ;
var customers = CustomerService . GetAllCompactCustomers ( ) ;
var resources = KalenderService . GetAllResources ( ) ;
var ich = Model . LoggedInCompactEmployee ;
var nichtIch = employees . First ( employee = > employee . EmployeeOid ! = ich . EmployeeOid ) ;
var weiterer = employees . First ( employee = > employee . EmployeeOid ! = ich . EmployeeOid & & employee . EmployeeOid ! = nichtIch . EmployeeOid ) ;
var eigenerKlient = customers . FirstOrDefault ( customer = > ich . RelatedCustomerOIDList . Contains ( customer . CustomerOid ) ) ;
var fremderKlient = customers . FirstOrDefault ( customer = > ich . RelatedCustomerOIDList . Contains ( customer . CustomerOid ) is false ) ;
var ressource = resources . FirstOrDefault ( ) ;
var ressource2 = resources . Count > 1 ? resources [ 1 ] : ressource ;
var nichtIchsKlient = customers . FirstOrDefault ( customer = > nichtIch . RelatedCustomerOIDList . Contains ( customer . CustomerOid ) ) ;
var nichtIchsFremderKlient = customers . FirstOrDefault ( customer = > nichtIch . RelatedCustomerOIDList . Contains ( customer . CustomerOid ) is false ) ;
// 1a) Einfacher eigener Termin
var apt_1a = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 8 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 9 , 0 , 0 ) ,
Subject = "Einfacher eigener Termin" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "Einfacher eigener Termin"
} ;
// 1b) mit Mitarbeiter
var apt_1b = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 9 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 10 , 0 , 0 ) ,
Subject = "mit Mitarbeiter" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "mit Mitarbeiter" ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = ich }
}
} ;
// 1c) mit eigenem Klient
var apt_1c = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 10 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 11 , 0 , 0 ) ,
Subject = "mit eigenem Klient" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "mit eigenem Klient" ,
CustomerList = new List < CompactCustomerDC > { eigenerKlient }
} ;
// 1d) mit fremdem Klient
var apt_1d = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 11 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 12 , 0 , 0 ) ,
Subject = "mit fremdem Klient" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "mit fremdem Klient" ,
CustomerList = new List < CompactCustomerDC > { fremderKlient }
} ;
// 1e) mit Ressource
var apt_1e = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 12 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 13 , 0 , 0 ) ,
Subject = "mit Ressource" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "mit Ressource" ,
ResourceList = new List < ResourceDC > { ressource }
} ;
// 1f) mit Mitarbeiter, eigenem Klient
var apt_1f = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 13 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 14 , 0 , 0 ) ,
Subject = "mit Mitarbeiter, eigenem Klient" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "mit Mitarbeiter, eigenem Klient" ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = ich }
} ,
CustomerList = new List < CompactCustomerDC > { eigenerKlient }
} ;
// 1g) mit Mitarbeiter, fremdem Klient
var apt_1g = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 14 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 15 , 0 , 0 ) ,
Subject = "mit Mitarbeiter, fremdem Klient" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "mit Mitarbeiter, fremdem Klient" ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = ich }
} ,
CustomerList = new List < CompactCustomerDC > { fremderKlient }
} ;
// 1h) mit eigenem Klient, Ressource
var apt_1h = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 15 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 16 , 0 , 0 ) ,
Subject = "mit eigenem Klient, Ressource" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "mit eigenem Klient, Ressource" ,
CustomerList = new List < CompactCustomerDC > { eigenerKlient } ,
ResourceList = new List < ResourceDC > { ressource }
} ;
// 1i) mit fremdem Klient, Ressource
var apt_1i = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 16 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 17 , 0 , 0 ) ,
Subject = "mit fremdem Klient, Ressource" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "mit fremdem Klient, Ressource" ,
CustomerList = new List < CompactCustomerDC > { fremderKlient } ,
ResourceList = new List < ResourceDC > { ressource }
} ;
// 1j) mit Mitarbeiter, eigenem Klient, Ressource
var apt_1j = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 17 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 18 , 0 , 0 ) ,
Subject = "mit Mitarbeiter, eigenem Klient, Ressource" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "mit Mitarbeiter, eigenem Klient, Ressource" ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = ich }
} ,
CustomerList = new List < CompactCustomerDC > { eigenerKlient } ,
ResourceList = new List < ResourceDC > { ressource }
} ;
// 1k) mit Mitarbeiter, fremdem Klient, Ressource
var apt_1k = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 18 , 0 , 0 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 19 , 0 , 0 ) ,
Subject = "mit Mitarbeiter, fremdem Klient, Ressource" ,
Location = "Datenbank" ,
Originator = ich ,
Description = "mit Mitarbeiter, fremdem Klient, Ressource" ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = ich }
} ,
CustomerList = new List < CompactCustomerDC > { fremderKlient } ,
ResourceList = new List < ResourceDC > { ressource }
} ;
// -----------------------------------------------------------------------------
// 2a) einfach
var apt_2a = new SchedulerAppointmentDC
{
StartDate = day1 . MergeDateWithHoursMinutesSeconds ( 19 ) ,
EndDate = day1 . MergeDateWithHoursMinutesSeconds ( 20 ) ,
Subject = "einfach" ,
Location = "Datenbank" ,
Originator = nichtIch ,
Description = "einfach"
} ;
// 2b) mit Mitarbeiter
var apt_2b = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 8 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 9 ) ,
Subject = "mit Mitarbeiter" ,
Location = "Datenbank" ,
Description = "mit Mitarbeiter" ,
Originator = nichtIch ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = weiterer }
}
} ;
// 2c) mit angemeldetem Mitarbeiter
var apt_2c = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 9 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 10 ) ,
Subject = "mit angemeldetem Mitarbeiter" ,
Location = "Datenbank" ,
Description = "mit angemeldetem Mitarbeiter" ,
Originator = nichtIch ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = ich }
}
} ;
// 2d) mit eigenem Klient
var apt_2d = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 10 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 11 ) ,
Subject = "mit eigenem Klient" ,
Location = "Datenbank" ,
Description = "mit eigenem Klient" ,
Originator = nichtIch ,
CustomerList = new List < CompactCustomerDC > { nichtIchsKlient }
} ;
// 2e) mit fremdem Klient
var apt_2e = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 11 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 12 ) ,
Subject = "mit fremdem Klient" ,
Location = "Datenbank" ,
Description = "mit fremdem Klient" ,
Originator = nichtIch ,
CustomerList = new List < CompactCustomerDC > { nichtIchsFremderKlient }
} ;
// 2f) mit Ressource
var apt_2f = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 12 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 13 ) ,
Subject = "mit Ressource" ,
Location = "Datenbank" ,
Description = "mit Ressource" ,
Originator = nichtIch ,
ResourceList = new List < ResourceDC > { ressource2 }
} ;
// 2g) mit Mitarbeiter, eigenem Klient
var apt_2g = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 13 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 14 ) ,
Subject = "mit Mitarbeiter, eigenem Klient" ,
Location = "Datenbank" ,
Description = "mit Mitarbeiter, eigenem Klient" ,
Originator = nichtIch ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = weiterer }
} ,
CustomerList = new List < CompactCustomerDC > { nichtIchsKlient }
} ;
// 2h) mit Mitarbeiter, fremdem Klient
var apt_2h = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 14 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 15 ) ,
Subject = "mit Mitarbeiter, fremdem Klient" ,
Location = "Datenbank" ,
Description = "mit Mitarbeiter, fremdem Klient" ,
Originator = nichtIch ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = weiterer }
} ,
CustomerList = new List < CompactCustomerDC > { nichtIchsFremderKlient }
} ;
// 2i) mit eigenem Klient, Ressource
var apt_2i = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 15 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 16 ) ,
Subject = "mit eigenem Klient, Ressource" ,
Location = "Datenbank" ,
Description = "mit eigenem Klient, Ressource" ,
Originator = nichtIch ,
CustomerList = new List < CompactCustomerDC > { nichtIchsKlient } ,
ResourceList = new List < ResourceDC > { ressource2 }
} ;
// 2j) mit fremdem Klient, Ressource
var apt_2j = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 16 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 17 ) ,
Subject = "mit fremdem Klient, Ressource" ,
Location = "Datenbank" ,
Description = "mit fremdem Klient, Ressource" ,
Originator = nichtIch ,
CustomerList = new List < CompactCustomerDC > { nichtIchsFremderKlient } ,
ResourceList = new List < ResourceDC > { ressource2 }
} ;
// 2k) mit Mitarbeiter, eigenem Klient, Ressource
var apt_2k = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 17 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 18 ) ,
Subject = "mit Mitarbeiter, eigenem Klient, Ressource" ,
Location = "Datenbank" ,
Description = "mit Mitarbeiter, eigenem Klient, Ressource" ,
Originator = nichtIch
} ;
// 2l) mit Mitarbeiter, fremdem Klient, Ressource
var apt_2l = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 18 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 19 ) ,
Subject = "mit Mitarbeiter, fremdem Klient, Ressource" ,
Location = "Datenbank" ,
Description = "mit Mitarbeiter, fremdem Klient, Ressource" ,
Originator = nichtIch ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = weiterer }
} ,
CustomerList = new List < CompactCustomerDC > { nichtIchsFremderKlient } ,
ResourceList = new List < ResourceDC > { ressource2 }
} ;
// 2m) mit angemeldetem Mitarbeiter, dessen Klient
var apt_2m = new SchedulerAppointmentDC
{
StartDate = day2 . MergeDateWithHoursMinutesSeconds ( 19 ) ,
EndDate = day2 . MergeDateWithHoursMinutesSeconds ( 20 ) ,
Subject = "mit angemeldetem Mitarbeiter, dessen Klient" ,
Location = "Datenbank" ,
Description = "mit angemeldetem Mitarbeiter, dessen Klient" ,
Originator = nichtIch ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = ich }
} ,
CustomerList = new List < CompactCustomerDC > { eigenerKlient }
} ;
// 2n) mit angemeldetem Mitarbeiter, diesem fremdem Klient
var apt_2n = new SchedulerAppointmentDC
{
StartDate = day3 . MergeDateWithHoursMinutesSeconds ( 8 ) ,
EndDate = day3 . MergeDateWithHoursMinutesSeconds ( 9 ) ,
Subject = "mit angemeldetem Mitarbeiter, diesem fremdem Klient" ,
Location = "Datenbank" ,
Description = "mit angemeldetem Mitarbeiter, diesem fremdem Klient" ,
Originator = nichtIch ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = ich }
} ,
CustomerList = new List < CompactCustomerDC > { fremderKlient }
} ;
// 2o) mit angemeldetem Mitarbeiter, dessen Klient, Ressource
var apt_2o = new SchedulerAppointmentDC
{
StartDate = day3 . MergeDateWithHoursMinutesSeconds ( 9 ) ,
EndDate = day3 . MergeDateWithHoursMinutesSeconds ( 10 ) ,
Subject = "mit angemeldetem Mitarbeiter, dessen Klient, Ressource" ,
Location = "Datenbank" ,
Description = "mit angemeldetem Mitarbeiter, dessen Klient, Ressource" ,
Originator = nichtIch ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = ich }
} ,
CustomerList = new List < CompactCustomerDC > { eigenerKlient } ,
ResourceList = new List < ResourceDC > { ressource }
} ;
// 2p) mit angemeldetem Mitarbeiter, diesem fremdem Klient, Ressource
var apt_2p = new SchedulerAppointmentDC
{
StartDate = day3 . MergeDateWithHoursMinutesSeconds ( 10 ) ,
EndDate = day3 . MergeDateWithHoursMinutesSeconds ( 11 ) ,
Subject = "mit angemeldetem Mitarbeiter, diesem fremdem Klient, Ressource" ,
Location = "Datenbank" ,
Description = "mit angemeldetem Mitarbeiter, diesem fremdem Klient, Ressource" ,
Originator = nichtIch ,
EmployeeList = new List < Employee2SchedulerAppointmentDC >
{
new Employee2SchedulerAppointmentDC { Employee = nichtIch } ,
new Employee2SchedulerAppointmentDC { Employee = ich }
} ,
CustomerList = new List < CompactCustomerDC > { fremderKlient } ,
ResourceList = new List < ResourceDC > { ressource }
} ;
var appointmentsToInsert = new List < SchedulerAppointmentDC >
{
apt_1a ,
apt_1b ,
apt_1c ,
apt_1d ,
apt_1e ,
apt_1f ,
apt_1g ,
apt_1h ,
apt_1i ,
apt_1j ,
apt_1k ,
apt_2a ,
apt_2b ,
apt_2c ,
apt_2d ,
apt_2e ,
apt_2f ,
apt_2g ,
apt_2h ,
apt_2i ,
apt_2j ,
apt_2k ,
apt_2l ,
apt_2m ,
apt_2n ,
apt_2o ,
apt_2p
} ;
foreach ( var appointment in appointmentsToInsert )
{
appointment . ActivationType = ActivationTypeId . Active ;
}
KalenderService . InsertSchedulerAppointments ( appointmentsToInsert ) ;
ReloadAppointments ( ) ;
}
2026-04-15 11:29:51 +02:00
[Authorize]
private ActionResult ToServiceRecord ( string apptID , string actionId , string [ ] args )
{
long? selectedAppointmentOid ;
var isRecurring = false ;
2026-03-02 11:19:28 +01:00
2026-04-15 11:29:51 +02:00
// Serientermin
if ( apptID . Contains ( "_" ) )
{
var splitApptId = apptID . Split ( '_' ) ;
selectedAppointmentOid = long . Parse ( splitApptId [ 0 ] ) ;
var recurrenceIndex = int . Parse ( splitApptId [ 1 ] ) ;
2026-03-02 11:19:28 +01:00
2026-04-15 11:29:51 +02:00
TempData [ TempDataConstants . AppointmentRecurrenceIndexKey ] = recurrenceIndex ;
}
else
{
selectedAppointmentOid = long . Parse ( apptID ) ;
}
2026-03-02 11:19:28 +01:00
2026-04-15 11:29:51 +02:00
var appointment = selectedAppointmentOid . HasValue ? Model . GetAppointmentByOid ( selectedAppointmentOid . Value ) : null ;
2026-03-02 11:19:28 +01:00
2026-04-15 11:29:51 +02:00
TempData [ TempDataConstants . AppointmentOidKey ] = appointment ? . SchedulerAppointmentOid ;
2026-03-02 11:19:28 +01:00
2026-04-15 11:29:51 +02:00
TempData [ TempDataConstants . AppointmentStartKey ] = appointment ? . StartDate ;
TempData [ TempDataConstants . AppointmentEndKey ] = appointment ? . EndDate ;
TempData [ TempDataConstants . AppointmentSubjectKey ] = appointment ? . Subject ;
TempData [ TempDataConstants . AppointmentIsAllDayKey ] = appointment ? . AllDay ? ? false ;
2026-03-02 11:19:28 +01:00
2026-04-15 11:29:51 +02:00
TempData [ TempDataConstants . AppointmentCustomerOidsKey ] = string . Join ( "," , appointment ? . CustomerList . Select ( s = > s . CustomerOid ) ? ? new List < long > ( ) ) ;
2026-03-02 11:19:28 +01:00
2026-04-15 11:29:51 +02:00
TempData [ TempDataConstants . AppointmentEmployeeOidsKey ] = string . Join ( "," , appointment ? . EmployeeList . Select ( s = > s . Employee . EmployeeOid ) ? ? new List < long > ( ) ) ;
2026-03-02 11:19:28 +01:00
2026-04-15 11:29:51 +02:00
TempData [ TempDataConstants . AppointmentIsSerienterminKey ] = appointment ! = null & & selectedAppointmentOid is null & & appointment . RecurrenceInfo is string ;
2026-03-02 11:19:28 +01:00
2026-04-15 11:29:51 +02:00
return RedirectToActionPermanent ( "PrepareServiceRecordInsert" , "Main" ) ;
2026-03-02 11:19:28 +01:00
}
2026-03-06 18:17:57 +01:00
[Authorize]
public string GetAppointmentType ( long oid )
{
var appointment = Model . GetAppointmentByOid ( oid ) ;
var showMenuItem = false ;
2026-03-23 15:23:00 +01:00
var isTask = appointment . IsTask ;
var isAbsenceTime = appointment . AbsenceReason ! = null ;
if ( isTask )
{
//showMenuItem =
}
2026-03-06 18:17:57 +01:00
return JsonConvert . SerializeObject ( showMenuItem ) ;
}
2026-03-23 15:23:00 +01:00
private void UpdateSelectedObjects ( )
{
var list = new List < ResourceDC > ( ) ;
2026-04-28 12:01:37 +02:00
2026-03-23 15:23:00 +01:00
Model . ResourceCategories2Resources . Values . DoForEach ( l = > l . DoForEach ( s = > list . AddIfNotIn ( s ) ) ) ;
2026-07-13 20:32:28 +02:00
//Model.SelectedEmployees = Model.PossibleEmployees.Where(employee => Model.SelectedEmployeeOids.Contains(employee.EmployeeOid)).ToList();
//Model.SelectedCustomers = Model.PossibleCustomers.Where(customer => Model.SelectedCustomerOids.Contains(customer.CustomerOid)).ToList();
//Model.SelectedResources = list.Where(resource => resource.ResourceOid.HasValue && Model.SelectedResourceOids.Contains(resource.ResourceOid.Value)).ToList();
AppointmentModel . SelectedEmployees = Model . PossibleEmployees . Where ( employee = > Model . SelectedEmployeeOids . Contains ( employee . EmployeeOid ) ) . ToList ( ) ;
AppointmentModel . SelectedCustomers = Model . PossibleCustomers . Where ( customer = > Model . SelectedCustomerOids . Contains ( customer . CustomerOid ) ) . ToList ( ) ;
AppointmentModel . SelectedResources = list . Where ( resource = > resource . ResourceOid . HasValue & & Model . SelectedResourceOids . Contains ( resource . ResourceOid . Value ) ) . ToList ( ) ;
2026-03-23 15:23:00 +01:00
Model . SelectedEmployeesForFiltering = Model . PossibleEmployees . Where ( employee = > Model . SelectedEmployeeOidsForFiltering . Contains ( employee . EmployeeOid ) ) . ToList ( ) ;
Model . SelectedCustomersForFiltering = Model . PossibleCustomers . Where ( customer = > Model . SelectedCustomerOidsForFiltering . Contains ( customer . CustomerOid ) ) . ToList ( ) ;
Model . SelectedResourcesForFiltering = list . Where ( resource = > resource . ResourceOid . HasValue & & Model . SelectedResourceOidsForFiltering . Contains ( resource . ResourceOid . Value ) ) . ToList ( ) ;
}
2026-03-04 12:21:19 +01:00
[Authorize]
public ActionResult CheckEmployeeAvailability ( string startString , string endString )
2026-03-02 11:19:28 +01:00
{
2026-03-04 12:21:19 +01:00
var start = DateTime . Parse ( startString ) ;
var end = DateTime . Parse ( endString ) ;
var availabilities = ReportService . GetMitarbeiterverfuegbarkeiten ( AppointmentModel . PossibleEmployees , start , end ) ;
var employee2Overtime = new EmployeeAvailabilityObject ( start , end , availabilities ) ;
2026-03-02 11:19:28 +01:00
2026-03-04 12:21:19 +01:00
Model . EmployeeAvailabilityObject = employee2Overtime ;
ViewData [ ViewDataConstants . SchedulerEmployeeAvailabilityConstant ] = employee2Overtime ;
return PartialView ( "SchedulerPagePartial" , Model ) ;
2025-03-25 17:36:15 +01:00
}
2026-03-18 18:05:58 +01:00
[Authorize]
2026-03-23 15:23:00 +01:00
public ActionResult SelectAllEmployeesForFiltering ( bool isChecked )
2026-03-18 18:05:58 +01:00
{
2026-03-23 15:23:00 +01:00
if ( Model is null )
{
TempData [ TempDataConstants . DoLogoutKey ] = true ;
return PartialView ( "AptFltEmployeePopupListPartial" ) ;
}
2026-03-18 18:05:58 +01:00
2026-03-27 15:14:20 +01:00
if ( isChecked )
{
Model . SelectedEmployeesForFiltering = Model . PossibleEmployees ;
Model . SelectedEmployeeOidsForFiltering = Model . PossibleEmployees . Select ( employee = > employee . EmployeeOid ) . ToList ( ) ;
}
else
{
Model . SelectedEmployeesForFiltering ? . Clear ( ) ;
Model . SelectedEmployeeOidsForFiltering ? . Clear ( ) ;
}
2026-03-23 15:23:00 +01:00
return PartialView ( "AptFltEmployeePopupListPartial" , Model ) ;
2026-03-18 18:05:58 +01:00
}
[Authorize]
2026-03-23 15:23:00 +01:00
public ActionResult SelectAllCustomersForFiltering ( bool isChecked )
2026-03-18 18:05:58 +01:00
{
2026-03-23 15:23:00 +01:00
if ( Model is null )
{
TempData [ TempDataConstants . DoLogoutKey ] = true ;
return PartialView ( "AptFltCustomerPopupListPartial" ) ;
}
2026-03-27 15:14:20 +01:00
if ( isChecked )
{
Model . SelectedCustomerOidsForFiltering = Model . PossibleCustomers . Select ( customer = > customer . CustomerOid ) . ToList ( ) ;
Model . SelectedCustomersForFiltering = Model . PossibleCustomers ;
}
else
{
Model . SelectedCustomerOidsForFiltering ? . Clear ( ) ;
Model . SelectedCustomersForFiltering ? . Clear ( ) ;
}
2026-03-18 18:05:58 +01:00
2026-03-23 15:23:00 +01:00
return PartialView ( "AptFltCustomerPopupListPartial" , Model ) ;
2026-03-18 18:05:58 +01:00
}
[Authorize]
2026-03-23 15:23:00 +01:00
public ActionResult SelectAllResourcesForFiltering ( bool isChecked )
2026-03-18 18:05:58 +01:00
{
2026-03-23 15:23:00 +01:00
if ( Model is null )
{
TempData [ TempDataConstants . DoLogoutKey ] = true ;
return PartialView ( "AptFltResourcePopupListPartial" ) ;
}
2026-03-27 15:14:20 +01:00
if ( isChecked )
{
Model . SelectedResourceOidsForFiltering = Model . PossibleResources . Where ( resource = > resource . ResourceOid . HasValue ) . Select ( resource = > resource . ResourceOid . Value ) . ToList ( ) ;
Model . SelectedResourcesForFiltering = Model . PossibleResources ;
}
else
{
Model . SelectedResourceOidsForFiltering ? . Clear ( ) ;
Model . SelectedResourcesForFiltering ? . Clear ( ) ;
}
2026-03-18 18:05:58 +01:00
2026-03-27 15:14:20 +01:00
return PartialView ( "AptFltResourcePopupListPartial" , Model ) ;
2026-03-18 18:05:58 +01:00
}
2026-03-23 15:23:00 +01:00
[Authorize]
public ActionResult SelectTeamForAppointment ( long teamOid )
{
if ( Model is null )
{
TempData [ TempDataConstants . DoLogoutKey ] = true ;
return PartialView ( "AptFltEmployeePopupListPartial" ) ;
}
var selectedTeam = Model . MyTeams . FirstOrDefault ( team = > team . TeamOid . Equals ( teamOid ) ) ;
if ( selectedTeam is null )
{
2026-03-27 15:14:20 +01:00
return PartialView ( "AptFltEmployeePopupListPartial" , Model ) ;
2026-03-23 15:23:00 +01:00
}
var fullTeamObj = EmployeeService . LoadTeam ( teamOid ) ;
2026-03-27 15:14:20 +01:00
var teamMembers = fullTeamObj ? . Member ? ? new List < CompactEmployeeDC > ( ) ;
2026-03-23 15:23:00 +01:00
2026-03-27 15:14:20 +01:00
Model . SelectedEmployeesForFiltering . AddRangeIfElementsNotIn ( teamMembers ) ;
Model . SelectedEmployeeOids . AddRangeIfElementsNotIn ( teamMembers . Select ( member = > member . EmployeeOid ) ) ;
return PartialView ( "AptFltEmployeePopupListPartial" , Model ) ;
2026-03-23 15:23:00 +01:00
}
[Authorize]
2026-05-08 11:05:48 +02:00
public ActionResult UpdateEmployeeFilterSelection ( long [ ] selectedOids )
2026-03-23 15:23:00 +01:00
{
if ( Model is null )
{
TempData [ TempDataConstants . DoLogoutKey ] = true ;
return PartialView ( "AptFltEmployeePopupListPartial" ) ;
}
2026-04-28 12:01:37 +02:00
if ( selectedOids is null )
{
selectedOids = Array . Empty < long > ( ) ;
}
var selectedEmployees = Model . PossibleEmployees . Where ( possibleEmployee = > selectedOids . Contains ( possibleEmployee . EmployeeOid ) ) . ToList ( ) ;
2026-03-23 15:23:00 +01:00
2026-03-27 15:14:20 +01:00
Model . SelectedEmployeesForFiltering = selectedEmployees ;
2026-03-23 15:23:00 +01:00
Model . SelectedEmployeeOidsForFiltering = selectedEmployees . Select ( employee = > employee . EmployeeOid ) . ToList ( ) ;
return PartialView ( "AptFltEmployeePopupListPartial" , Model ) ;
}
[Authorize]
2026-05-08 11:05:48 +02:00
public ActionResult UpdateCustomerFilterSelection ( long [ ] selectedOids )
2026-03-23 15:23:00 +01:00
{
if ( Model is null )
{
TempData [ TempDataConstants . DoLogoutKey ] = true ;
return PartialView ( "AptFltCustomerPopupListPartial" ) ;
}
2026-04-28 12:01:37 +02:00
if ( selectedOids is null )
{
selectedOids = Array . Empty < long > ( ) ;
}
var selectedCustomers = Model . PossibleCustomers . Where ( possibleCustomer = > selectedOids . Contains ( possibleCustomer . CustomerOid ) ) . ToList ( ) ;
2026-03-23 15:23:00 +01:00
2026-03-27 15:14:20 +01:00
Model . SelectedCustomersForFiltering = selectedCustomers ;
Model . SelectedCustomerOidsForFiltering = selectedCustomers . Select ( customer = > customer . CustomerOid ) . ToList ( ) ;
2026-03-23 15:23:00 +01:00
return PartialView ( "AptFltCustomerPopupListPartial" , Model ) ;
}
[Authorize]
2026-05-08 11:05:48 +02:00
public ActionResult UpdateResourceFilterSelection ( long [ ] selectedOids )
2026-03-23 15:23:00 +01:00
{
if ( Model is null )
{
TempData [ TempDataConstants . DoLogoutKey ] = true ;
return PartialView ( "AptFltResourcePopupListPartial" ) ;
}
2026-04-28 12:01:37 +02:00
if ( selectedOids is null )
{
selectedOids = Array . Empty < long > ( ) ;
}
var selectedResources = Model . PossibleResources . Where ( possibleResource = > possibleResource . ResourceOid . HasValue & & selectedOids . Contains ( possibleResource . ResourceOid . Value ) ) . ToList ( ) ;
2026-03-27 15:14:20 +01:00
Model . SelectedResourcesForFiltering = selectedResources ;
Model . SelectedResourceOidsForFiltering = selectedResources . Where ( resource = > resource . ResourceOid . HasValue ) . Select ( resource = > resource . ResourceOid . Value ) . ToList ( ) ;
2026-03-23 15:23:00 +01:00
return PartialView ( "AptFltResourcePopupListPartial" , Model ) ;
}
2026-03-27 15:14:20 +01:00
[Authorize]
public string GetSelectedEmployeesForAptFlt ( )
{
return JsonConvert . SerializeObject ( Model . SelectedEmployeeOidsForFiltering . Count ) ;
}
[Authorize]
public string GetSelectedCustomersForAptFlt ( )
{
return JsonConvert . SerializeObject ( Model . SelectedCustomerOidsForFiltering . Count ) ;
}
[Authorize]
public string GetSelectedResourcesForAptFlt ( )
{
return JsonConvert . SerializeObject ( Model . SelectedResourceOidsForFiltering . Count ) ;
}
2026-04-15 11:29:51 +02:00
private ActionResult FilterAppointments ( string filters )
{
var filterPairs = filters ? . Split ( ';' ) ? ? Array . Empty < string > ( ) ;
foreach ( var pair in filterPairs )
{
var id2Checked = pair . Split ( "_" ) ;
var isChecked = id2Checked [ 1 ] = = "on" ;
var id = id2Checked [ 0 ] ;
switch ( id )
{
case "only-my-own-appointments-cb2" :
Model . ShowOnlyMyOwnAppointments = isChecked ;
UpdateUserSettingsWithoutReload ( SettingsKeys . ZeigeNurMeineTermine , isChecked . ToString ( ) ) ;
break ;
case "only-private-appointments-cb2" :
Model . ShowOnlyPrivateAppointments = isChecked ;
break ;
case "employee-colors-cb2" :
Model . ShowEmployeeColors = isChecked ;
break ;
case "absence-times-cb2" :
Model . ShowAbsenceTimes = isChecked ;
break ;
case "tasks-cb2" :
Model . ShowTasks = isChecked ;
break ;
case "only-employees-cb2" :
Model . ShowOnlyEmployees = isChecked ;
break ;
case "only-customers-cb2" :
Model . ShowOnlyCustomers = isChecked ;
break ;
case "only-resources-cb2" :
Model . ShowOnlyResources = isChecked ;
break ;
}
}
ReloadAppointments ( ) ;
return PartialView ( "SchedulerPagePartial" , Model ) ;
}
2026-04-28 12:01:37 +02:00
2026-06-29 13:45:15 +02:00
[Authorize]
public string UnselectAppointment2Answer ( )
{
Model . AppointmentOidToAnswerOrUpdate = null ;
Model . AppointmentToAnswerOrUpdate = null ;
return LeerzeichenFuerGetMethoden ;
}
2026-04-28 12:01:37 +02:00
[Authorize]
public ActionResult LoadAppointmentToAnswer ( long oid )
{
2026-06-29 13:45:15 +02:00
var relation = Model . OpenEmployee2AppointmentRels . FirstOrDefault ( f = > f . Employee2SchedulerAppointmentOid . HasValue & & f . Employee2SchedulerAppointmentOid . Equals ( oid ) ) ;
if ( relation ! = null )
{
Model . Employee2AppointmentToAnswerOrUpdateRel = relation ;
Model . Employee2AppointmentToAnswerOrUpdateRelOid = relation . Employee2SchedulerAppointmentOid ;
var appointment = Model . OpenAppointments . FirstOrDefault ( f = > f . EmployeeList . Any ( a = > a . Employee2SchedulerAppointmentOid . Equals ( relation . Employee2SchedulerAppointmentOid . Value ) ) ) ;
if ( appointment ! = null )
{
Model . AppointmentToAnswerOrUpdate = appointment ;
Model . AppointmentOidToAnswerOrUpdate = appointment . SchedulerAppointmentOid ;
}
}
2026-04-28 12:01:37 +02:00
2026-06-29 13:45:15 +02:00
return PartialView ( "SelectedOpenEmployee2AppointmentFormPartial" , Model ) ;
2026-04-28 12:01:37 +02:00
}
[Authorize]
public ActionResult AnswerOpenAppointment ( int answer )
{
2026-06-29 13:45:15 +02:00
var appointmentOid = Model . AppointmentOidToAnswerOrUpdate ;
var relationOid = Model . Employee2AppointmentToAnswerOrUpdateRelOid ;
2026-04-28 12:01:37 +02:00
2026-06-29 13:45:15 +02:00
var appointment = Model . OpenAppointments . FirstOrDefault ( f = > f . SchedulerAppointmentOid . Equals ( appointmentOid ) ) ;
var relation = Model . OpenEmployee2AppointmentRels . FirstOrDefault ( f = > f . Employee2SchedulerAppointmentOid . Equals ( relationOid ) ) ;
2026-04-28 12:01:37 +02:00
2026-06-29 13:45:15 +02:00
if ( relation is null )
2026-04-28 12:01:37 +02:00
{
2026-06-29 13:45:15 +02:00
throw new ArgumentNullException ( nameof ( relation ) , "Das Employee2NewSchedulerAppointmentDC-Objekt ist in der Funktion 'AnswerOpenAppointment' wider Erwarten null!" ) ;
2026-04-28 12:01:37 +02:00
}
2026-06-29 13:45:15 +02:00
if ( appointment is null )
{
throw new ArgumentNullException ( nameof ( appointment ) , "Das SchedulerAppointmentDC-Objekt ist in der Funktion 'AnswerOpenAppointment' wider Erwarten null!" ) ;
}
2026-04-28 12:01:37 +02:00
2026-06-29 13:45:15 +02:00
if ( answer = = 5 )
{
relation . IsPC_CheckedTs = DateTime . Now ;
}
else
{
var participationAnswer = ( ParticipationAnswer ) answer ;
relation . ParticipationAnswer = participationAnswer ;
relation . IsPChanged = true ;
}
KalenderService . UpdateEmployee2SchedulerAppointments ( new List < Employee2SchedulerAppointmentDC > { relation } ) ;
Model . AppointmentOidToAnswerOrUpdate = null ;
Model . Employee2AppointmentToAnswerOrUpdateRelOid = null ;
2026-04-28 12:01:37 +02:00
ReloadAppointments ( ) ;
return PartialView ( "NotificationsPopupContent" , Model ) ;
}
2026-06-29 13:45:15 +02:00
[Authorize]
public ActionResult ReloadOpenAppointments ( )
{
ReloadAppointments ( ) ;
return PartialView ( "OpenEmployee2AppointmentListPartial" , Model ) ;
}
2026-04-28 12:01:37 +02:00
[Authorize]
public ActionResult ConfirmAllOpenAppointments ( )
{
2026-06-29 13:45:15 +02:00
var rels = Model . OpenEmployee2AppointmentRels ;
2026-04-28 12:01:37 +02:00
2026-06-29 13:45:15 +02:00
var appointmentOids = rels
. Where ( employee2Appointment = > employee2Appointment . SchedulerAppointmentOid . HasValue )
. Select ( employee2Appointment = > employee2Appointment . SchedulerAppointmentOid . Value )
. ToList ( ) ;
2026-04-28 12:01:37 +02:00
2026-06-29 13:45:15 +02:00
var appointments = Model . OpenAppointments . Where ( appointment = > appointment . SchedulerAppointmentOid . HasValue & & appointmentOids . Contains ( appointment . SchedulerAppointmentOid . Value ) ) . ToList ( ) ;
2026-04-28 12:01:37 +02:00
2026-06-29 13:45:15 +02:00
foreach ( var appointment in appointments )
{
foreach ( var employee2Appointment in appointment . EmployeeList )
{
if ( employee2Appointment . Employee . Equals ( Model . LoggedInCompactEmployee ) )
{
employee2Appointment . IsPChanged = true ;
employee2Appointment . ParticipationAnswer = ParticipationAnswer . Zusage ;
}
}
}
2026-04-28 12:01:37 +02:00
2026-06-29 13:45:15 +02:00
KalenderService . UpdateSchedulerAppointments ( appointments ) ;
2026-04-28 12:01:37 +02:00
ReloadAppointments ( ) ;
return PartialView ( "NotificationsPopupContent" , Model ) ;
}
2026-06-29 13:45:15 +02:00
[Authorize]
public string GetOpenEmp2AppRelCount ( )
{
return JsonConvert . SerializeObject ( Model . OpenEmployee2AppointmentRelOids . Count ) ;
}
[Authorize]
public ActionResult UpdateOpenEmp2AppCount ( )
{
return PartialView ( "NotificationsLinkPartial" , Model ) ;
}
2026-04-28 12:01:37 +02:00
[Authorize]
public ActionResult RightClickConfirm ( int answer , long id )
{
var appointments = ( List < SchedulerAppointmentDC > ) Model . Appointments ;
var appointment2Answer = appointments . FirstOrDefault ( appointment = > appointment . SchedulerAppointmentOid ? . Equals ( id ) ? ? false ) ;
var rel = appointment2Answer ? . EmployeeList . FirstOrDefault ( employee2Appointment = > employee2Appointment . Employee . Equals ( Model . LoggedInCompactEmployee ) ) ;
if ( rel ! = null )
{
rel . ParticipationAnswer = ( ParticipationAnswer ) answer ;
rel . IsPChanged = true ;
rel . IsPC_CheckedTs = DateTime . Now ;
}
KalenderService . UpdateSchedulerAppointments ( new List < SchedulerAppointmentDC > { appointment2Answer } ) ;
ReloadAppointments ( ) ;
return PartialView ( "SchedulerPagePartial" , Model ) ;
}
2026-05-08 11:05:48 +02:00
[Authorize]
public string GetEmployeePageCount ( )
{
return JsonConvert . SerializeObject ( new EditFormInfo ( AppointmentModel . EmployeePageCount , AppointmentModel . EmployeePageLimit ) ) ;
}
[Authorize]
public string GetCustomerPageCount ( )
{
return JsonConvert . SerializeObject ( new EditFormInfo ( AppointmentModel . CustomerPageCount , AppointmentModel . CustomerPageLimit ) ) ;
}
[Authorize]
public string GetResourcePageCount ( )
{
return JsonConvert . SerializeObject ( new EditFormInfo ( AppointmentModel . ResourcePageCount , AppointmentModel . ResourcePageLimit ) ) ;
}
[Authorize]
public string UpdateAppointmentEmployeeSelection ( string selectedOids )
{
if ( selectedOids is null )
{
selectedOids = string . Empty ;
}
var selectedEmployeeOids = selectedOids . Length = = 0 ? new List < long > ( ) : selectedOids . Split ( ',' ) . Select ( long . Parse ) . ToList ( ) ;
2026-06-29 13:45:15 +02:00
var relationsToKeep = AppointmentModel . SelectedEmployee2SchedulerAppointments ? . Where ( e2A = > selectedEmployeeOids . Contains ( e2A . Employee . EmployeeOid ) ) . ToList ( ) ? ? new List < Employee2SchedulerAppointmentDC > ( ) ;
var newlySelectedEmployeeOids = selectedEmployeeOids . Except ( relationsToKeep . Select ( e2A = > e2A . Employee . EmployeeOid ) ) ;
2026-05-08 11:05:48 +02:00
2026-06-29 13:45:15 +02:00
AppointmentModel . SelectedEmployee2SchedulerAppointments = new List < Employee2SchedulerAppointmentDC > ( relationsToKeep ) ;
var oids = AppointmentModel . PossibleEmployees . Where ( e = > selectedEmployeeOids . Contains ( e . EmployeeOid ) ) . Select ( e = > e . EmployeeOid ) . ToList ( ) ;
var employees = AppointmentModel . PossibleEmployees . Where ( possibleEmployee = > newlySelectedEmployeeOids . Contains ( possibleEmployee . EmployeeOid ) ) . ToList ( ) ;
2026-05-08 11:05:48 +02:00
foreach ( var employee in employees )
{
AppointmentModel . SelectedEmployee2SchedulerAppointments . Add ( new Employee2SchedulerAppointmentDC { Employee = employee } ) ;
}
2026-06-29 13:45:15 +02:00
AppointmentModel . SelectedEmployeeOids = oids ;
return JsonConvert . SerializeObject ( AppointmentModel . SelectedEmployee2SchedulerAppointments ? . Count ? ? 0 ) ;
2026-05-08 11:05:48 +02:00
}
[Authorize]
public string UpdateAppointmentCustomerSelection ( string selectedOids )
{
if ( selectedOids is null )
{
selectedOids = string . Empty ;
}
AppointmentModel . SelectedCustomerOids = selectedOids . Length = = 0 ? new List < long > ( ) : selectedOids . Split ( ',' ) . Select ( long . Parse ) . ToList ( ) ;
2026-06-29 13:45:15 +02:00
return JsonConvert . SerializeObject ( AppointmentModel . SelectedCustomerOids ? . Count ? ? 0 ) ;
2026-05-08 11:05:48 +02:00
}
[Authorize]
public string UpdateAppointmentResourceSelection ( string selectedOids )
{
if ( selectedOids is null )
{
selectedOids = string . Empty ;
}
AppointmentModel . SelectedResourceOids = selectedOids . Length = = 0 ? new List < long > ( ) : selectedOids . Split ( ',' ) . Select ( long . Parse ) . ToList ( ) ;
2026-07-09 11:39:24 +02:00
2026-06-29 13:45:15 +02:00
return JsonConvert . SerializeObject ( AppointmentModel . SelectedResourceOids ? . Count ? ? 0 ) ;
2026-05-08 11:05:48 +02:00
}
}
public class EditFormInfo
{
public int PageCount { get ; }
public int PageLimit { get ; }
public EditFormInfo ( int pageCount , int pageLimit )
{
PageCount = pageCount ;
PageLimit = pageLimit ;
}
2021-08-19 17:22:04 +02:00
}
}