using BeWoPlanerMobil.Models; using BeWoPlanerMobil.Service; using BeWoPlanerMobil.Util; using BeWoPlanerMobil.Util.Constants; using BeWoPlanerMobil.Util.SchedulerUtils; using BeWoPlanerMobil.Views.DevExpressScheduler; using BS.Shared; using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; using DevExpress.Web.Mvc; using DevExpress.XtraScheduler; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; namespace BeWoPlanerMobil.Controllers { /* * ToDo: * 1. Filterung einbauen (Mitarbeiter, Klienten, Ressourcen, Privat, Aufgaben, Abwesenheiten) * 2. "In die Zeiterfassung übertragen" und "Verfügbare Mitarbeiter prüfen" einbauen * 3. Rechte implementieren! * 4. Übersetzungen */ public class DevExpressSchedulerController : AbstractBaseController { [Authorize] public override string SaveCollapsibleStatus(bool isOpen, string identifier) { return SaveCollapsibleStatusToModel(Model, isOpen, identifier); } private DevExpressSchedulerModel _Model; public DevExpressSchedulerModel Model { get { if(false == MobileSessionFacade.IsUserLoggedIn()) { Logout(); return null; } if(_Model != null) { return _Model; } _Model = new DevExpressSchedulerModel(); InitModel(_Model); InitViewModel(); return _Model; } } 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(); } private void InitViewModel() { if(false == MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || Model?.LoggedInEmployee?.EmployeeOid is null) { Logout(); return; } var userSettings = LoggedInUser?.Settings.FirstOrDefault(f => f.Type.Equals(SettingsType.ApplicationSettings))?.Value; Model.ShowOnlyMyOwnAppointments = UserSettingsUtils.GetSettingValueAsBool(userSettings, SettingsKeys.ZeigeNurMeineTermine); if(Model.ShowOnlyMyOwnAppointments && LoggedInUser != null) { Model.SelectedEmployeeOidsForFiltering = new List { LoggedInUser.Employee.EmployeeOid }; } Model.PossibleEmployees = EmployeeService.GetAllAuthorizedCompactEmployees(); Model.PossibleCustomers = CustomerService.GetAllAuthorizedCompactCustomers(); Model.PossibleResources = KalenderService.GetAllResources(); if(Model.HasRightToInsertRessourceAppointments || Model.HasRightToViewAllResourceAppointments) { var allResources = KalenderService.GetAllResources().OrderBy(r => r.Name).ToList(); var categories2Resources = new Dictionary>(); foreach(var category in allResources.Select(resource => resource.ResourceCategory)) { categories2Resources.AddOrUpdateValueInDictionary(category, allResources.Where(resource => resource.ResourceCategory.Equals(category)).OrderBy(r => r.Name).ToList()); } Model.ResourceCategories2Resources = categories2Resources.OrderBy(kvp => kvp.Key.DisplayName).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); } if(Model.LoggedInEmployee?.EmployeeOid.HasValue ?? false) { var compactEmployee = EmployeeService.GetActiveCompactEmployeeWithOid(Model.LoggedInEmployee.EmployeeOid.Value); Model.MyTeamEmployees = EmployeeService.GetAllTeamMember(compactEmployee).OrderBy(employee => employee.LastName).ToList(); } else { Model.MyTeamEmployees = new List(); } if(Model.HasRightToViewTeams && (Model?.LoggedInEmployee?.EmployeeOid.HasValue ?? false)) { Model.MyTeams = EmployeeService.GetAllActiveCompactTeamsForEmployee(Model.LoggedInEmployee.EmployeeOid.Value).OrderBy(team => team.Name).ToList(); } Model.TeamMemberCustomerOids = EmployeeService.LoadTeamsRelatedCustomerOids(LoggedInUser.Employee.EmployeeOid); 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(); ReloadAppointments(); } private void ReloadAppointments() { if(Model.LoggedInEmployee.EmployeeOid is null) { throw new Exception("Bei DevExpressSchedulerController.ReloadAppointments() ist die Oid des angemeldeten Benutzers wider Erwarten NULL!"); } UpdateSelectedObjects(); var employeeOid = Model.LoggedInEmployee.EmployeeOid.Value; var user = LoggedInUser; var userSettings = user?.Settings.FirstOrDefault(f => f.Type.Equals(SettingsType.ApplicationSettings))?.Value; Model.CurrentViewType = (SchedulerViewType) UserSettingsUtils.GetSettingValueAsInteger(userSettings, SettingsKeys.SchedulerViewType); var intervalStart = DateTimeExtensions.GetDayOfWeek(DayOfWeek.Monday); var intervalEnd = intervalStart.AddDays(7); var appointments = KalenderService.LoadFilteredAppointmentsMitAufgaben ( Model.HasRightKalenderMitarbeitertermineAnsehen, employeeOid, intervalStart, intervalEnd, Model.SelectedEmployeeOidsForFiltering, Model.SelectedCustomerOidsForFiltering, Model.SelectedResourceOidsForFiltering, Model.ShowOnlyEmployees, Model.ShowOnlyCustomers, Model.ShowOnlyResources, Model.ShowOnlyPrivateAppointments, Model.ShowOnlyMyOwnAppointments, Model.ShowTasks ); var selectedCustomerOids = Model.PossibleCustomers.Select(s => s.CustomerOid).ToList(); var selectedEmployeeOids = Model.PossibleEmployees.Select(s => s.EmployeeOid).ToList(); var customerAbsenceTimes = KalenderService.GetAllActiveCustomersAbsenceTimesInInterval(intervalStart, intervalEnd, employeeOid, selectedCustomerOids); var employeeAbsenceTimes = KalenderService.GetAllActiveEmployeeAbsenceTimesInInterval(intervalStart, intervalEnd, employeeOid, selectedEmployeeOids); if(Model.ShowAbsenceTimes) { var allAbsenceTimes = new List(); allAbsenceTimes.AddRange(customerAbsenceTimes); allAbsenceTimes.AddRange(employeeAbsenceTimes); appointments.AddRange(ConvertAbsenceTimesToAppointments(allAbsenceTimes, Model.PossibleCustomers, Model.PossibleEmployees)); } Model.Appointments = appointments; LoadNotificationCount(); } [Authorize] public ActionResult GetNotifications() { LoadNotificationCount(); return PartialView("SchedulerNotificationPartial", Model); } private int LoadNotificationCount() { Model.OpenAppointments = KalenderService.GetAllOpenAppointmentsForEmployee(LoggedInUser.Employee.EmployeeOid); return Model.NotificationCount; } private List ConvertAbsenceTimesToAppointments(List absenceTimes, List allCustomers, List allEmployees) { var appointments = new List(); 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, Krankheitsmeldung = absenceTime.KrankheitsMeldung, IsAbsenceTime = true }; if(false == customer is null && employee is null) { appointment.CustomerList = new List { customer }; } appointments.Add(appointment); } return appointments; } [Authorize] public ActionResult DevExpressScheduler() { if(false == MobileSessionFacade.IsUserLoggedIn() || Model is null) { return RedirectToActionPermanent("Index", "Login"); } Model.Resources = new List(); return View(Model); } [Authorize] public ActionResult SchedulerPagePartial() { return PartialView("SchedulerPagePartial", Model); } [Authorize] public ActionResult EditAppointment() { UpdateAppointment(); return PartialView("SchedulerPagePartial", Model); } [Authorize] private void UpdateAppointment() { var appointmentsToInsert = SchedulerExtension.GetAppointmentsToInsert( "scheduler", Model.Appointments, SchedulerHelper.DefaultAppointmentStorage, SchedulerHelper.DefaultResourceStorage); var appointmentsToUpdate = SchedulerExtension.GetAppointmentsToUpdate( "scheduler", Model.Appointments, SchedulerHelper.DefaultAppointmentStorage, SchedulerHelper.DefaultResourceStorage ); var appointmentsToRemove = SchedulerExtension.GetAppointmentsToRemove( "scheduler", Model.Appointments, SchedulerHelper.DefaultAppointmentStorage, SchedulerHelper.DefaultResourceStorage ); foreach(var appointment in appointmentsToInsert) { appointment.CustomerList = AppointmentModel.SelectedCustomers; appointment.ResourceList = AppointmentModel.SelectedResources; appointment.EmployeeList = new List(); foreach(var selectedEmployee in AppointmentModel.SelectedEmployees ?? new List()) { appointment.EmployeeList.Add(new Employee2SchedulerAppointmentDC { Employee = selectedEmployee }); } appointment.Originator = Model.LoggedInUser.Employee; 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(); foreach(var selectedEmployee in AppointmentModel.SelectedEmployees) { appointment.EmployeeList.Add(new Employee2SchedulerAppointmentDC { Employee = selectedEmployee }); } } appointment.ActivationType = ActivationTypeId.Active; KalenderService.UpdateSchedulerAppointments(new List { appointment }); } KalenderService.DeleteSchedulerAppointments( appointmentsToRemove .Where(appointment => appointment.SchedulerAppointmentOid.HasValue && appointment.NewSchedulerAppointmentVersion.HasValue) .ToDictionary(k => k.SchedulerAppointmentOid.Value, v => v.NewSchedulerAppointmentVersion.Value)); ReloadAppointments(); } [HttpPost] public ActionResult CustomerMultiSelectPartial(string value) { var selectedCustomerOids = GridLookupExtension.GetSelectedValues("CustomerGridLookup") ?? Array.Empty(); AppointmentModel.SelectedCustomerOids = selectedCustomerOids.Where(oid => oid.HasValue).Select(oid => oid.Value).ToList(); return PartialView("CustomerMultiSelectPartial", AppointmentModel); } [HttpPost] public ActionResult ResourceGridLookupPartial(string value) { var selectedResourceOids = GridLookupExtension.GetSelectedValues("ResourceGridLookup") ?? Array.Empty(); AppointmentModel.SelectedResourceOids = selectedResourceOids.Where(oid => oid.HasValue).Select(oid => oid.Value).ToList(); return PartialView("ResourceMultiSelectPartial", AppointmentModel); } [HttpPost] public ActionResult EmployeeGridLookupPartial(string value) { /* * Im AppointmentModel müssen die PossibleEmployees bleiben, denn daraus wählt man die Mitarbeiter, die noch nicht mit dem Termin * verknüpft sind und es müssen - zumindest beim Bearbeiten - die bereits mit dem Termin verbundenen Mitarbeiter-zu-Termin-Relationen * zwischengespeichert werden. * */ var selectedEmployeeOids = GridLookupExtension.GetSelectedValues("EmployeeGridLookup") ?? Array.Empty(); AppointmentModel.SelectedEmployeeOids = selectedEmployeeOids.Where(oid => oid.HasValue).Select(oid => oid.Value).ToList(); return PartialView("EmployeeMultiSelectPartial", AppointmentModel); } [Authorize] public string SelectActiveViewType(string viewTypeName) { if(Enum.TryParse(viewTypeName, out var viewType)) { Model.CurrentViewType = viewType; UpdateUserSettingsWithoutReload(SettingsKeys.SchedulerViewType, ((int) viewType).ToString()); } return LeerzeichenFuerGetMethoden; } /// /// Hier laufen Custom-Aufrufe drüber ab. Im JavaScript mit scheduler.PerformCallback(...) aufrufen. /// /// Etwaige Id des Termin-Objekts /// Die Id der auszuführenden Methode /// Etwaige Parameter für die auszuführende Methode /// Entweder das Scheduler-Partial oder ein anderer Seitenaufruf. [Authorize] public ActionResult CustomCallbackAction(string apptID, string actionId, string[] args) { switch(actionId) { case "ToServiceRecord": return ToServiceRecord(apptID, actionId, args); case "FilterAppointments": return FilterAppointments(args.Length >= 1 ? args[0] : null); case "Reload": ReloadAppointments(); break; } return PartialView("SchedulerPagePartial", Model); } [Authorize] private ActionResult ToServiceRecord(string apptID, string actionId, string[] args) { long? selectedAppointmentOid; var isRecurring = false; // Serientermin if(apptID.Contains("_")) { var splitApptId = apptID.Split('_'); selectedAppointmentOid = long.Parse(splitApptId[0]); var recurrenceIndex = int.Parse(splitApptId[1]); TempData[TempDataConstants.AppointmentRecurrenceIndexKey] = recurrenceIndex; } else { selectedAppointmentOid = long.Parse(apptID); } var appointment = selectedAppointmentOid.HasValue ? Model.GetAppointmentByOid(selectedAppointmentOid.Value) : null; TempData[TempDataConstants.AppointmentOidKey] = appointment?.SchedulerAppointmentOid; TempData[TempDataConstants.AppointmentStartKey] = appointment?.StartDate; TempData[TempDataConstants.AppointmentEndKey] = appointment?.EndDate; TempData[TempDataConstants.AppointmentSubjectKey] = appointment?.Subject; TempData[TempDataConstants.AppointmentIsAllDayKey] = appointment?.AllDay ?? false; TempData[TempDataConstants.AppointmentCustomerOidsKey] = string.Join(",", appointment?.CustomerList.Select(s => s.CustomerOid) ?? new List()); TempData[TempDataConstants.AppointmentEmployeeOidsKey] = string.Join(",", appointment?.EmployeeList.Select(s => s.Employee.EmployeeOid) ?? new List()); TempData[TempDataConstants.AppointmentIsSerienterminKey] = appointment != null && selectedAppointmentOid is null && appointment.RecurrenceInfo is string; return RedirectToActionPermanent("PrepareServiceRecordInsert", "Main"); } [Authorize] public string GetAppointmentType(long oid) { var appointment = Model.GetAppointmentByOid(oid); var showMenuItem = false; var isTask = appointment.IsTask; var isAbsenceTime = appointment.AbsenceReason != null; if(isTask) { //showMenuItem = } return JsonConvert.SerializeObject(showMenuItem); } private void UpdateSelectedObjects() { var list = new List(); Model.ResourceCategories2Resources.Values.DoForEach(l => l.DoForEach(s => list.AddIfNotIn(s))); 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(); 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(); Model.SelectedEmployeesForIntervalFinder = Model.PossibleEmployees.Where(employee => Model.SelectedEmployeeOidsForIntervalFinder.Contains(employee.EmployeeOid)).ToList(); Model.SelectedCustomersForIntervalFinder = Model.PossibleCustomers.Where(customer => Model.SelectedCustomerOidsForIntervalFinder.Contains(customer.CustomerOid)).ToList(); Model.SelectedResourcesForIntervalFinder = list.Where(resource => resource.ResourceOid.HasValue && Model.SelectedResourceOidsForIntervalFinder.Contains(resource.ResourceOid.Value)).ToList(); } [Authorize] public ActionResult CheckEmployeeAvailability(string startString, string endString) { 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); Model.EmployeeAvailabilityObject = employee2Overtime; ViewData[ViewDataConstants.SchedulerEmployeeAvailabilityConstant] = employee2Overtime; return PartialView("SchedulerPagePartial", Model); } [Authorize] public ActionResult SelectAllEmployeesForFiltering(bool isChecked) { if(Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("AptFltEmployeePopupListPartial"); } if(isChecked) { Model.SelectedEmployeesForFiltering = Model.PossibleEmployees; Model.SelectedEmployeeOidsForFiltering = Model.PossibleEmployees.Select(employee => employee.EmployeeOid).ToList(); } else { Model.SelectedEmployeesForFiltering?.Clear(); Model.SelectedEmployeeOidsForFiltering?.Clear(); } return PartialView("AptFltEmployeePopupListPartial", Model); } [Authorize] public ActionResult SelectAllCustomersForFiltering(bool isChecked) { if(Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("AptFltCustomerPopupListPartial"); } if(isChecked) { Model.SelectedCustomerOidsForFiltering = Model.PossibleCustomers.Select(customer => customer.CustomerOid).ToList(); Model.SelectedCustomersForFiltering = Model.PossibleCustomers; } else { Model.SelectedCustomerOidsForFiltering?.Clear(); Model.SelectedCustomersForFiltering?.Clear(); } return PartialView("AptFltCustomerPopupListPartial", Model); } [Authorize] public ActionResult SelectAllResourcesForFiltering(bool isChecked) { if(Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("AptFltResourcePopupListPartial"); } 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(); } return PartialView("AptFltResourcePopupListPartial", Model); } [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) { return PartialView("AptFltEmployeePopupListPartial", Model); } var fullTeamObj = EmployeeService.LoadTeam(teamOid); var teamMembers = fullTeamObj?.Member ?? new List(); Model.SelectedEmployeesForFiltering.AddRangeIfElementsNotIn(teamMembers); Model.SelectedEmployeeOids.AddRangeIfElementsNotIn(teamMembers.Select(member => member.EmployeeOid)); return PartialView("AptFltEmployeePopupListPartial", Model); } [Authorize] public ActionResult UpdateEmployeeSelection(long[] selectedEmployeeOids) { if(Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("AptFltEmployeePopupListPartial"); } var selectedEmployees = Model.PossibleEmployees.Where(possibleEmployee => selectedEmployeeOids.Contains(possibleEmployee.EmployeeOid)).ToList(); Model.SelectedEmployeesForFiltering = selectedEmployees; Model.SelectedEmployeeOidsForFiltering = selectedEmployees.Select(employee => employee.EmployeeOid).ToList(); return PartialView("AptFltEmployeePopupListPartial", Model); } [Authorize] public ActionResult UpdateCustomerSelection(long[] selectedCustomerOids) { if(Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("AptFltCustomerPopupListPartial"); } var selectedCustomers = Model.PossibleCustomers.Where(possibleCustomer => selectedCustomerOids.Contains(possibleCustomer.CustomerOid)).ToList(); Model.SelectedCustomersForFiltering = selectedCustomers; Model.SelectedCustomerOidsForFiltering = selectedCustomers.Select(customer => customer.CustomerOid).ToList(); return PartialView("AptFltCustomerPopupListPartial", Model); } [Authorize] public ActionResult UpdateResourceSelection(long[] selectedResourceOids) { if(Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("AptFltResourcePopupListPartial"); } var selectedResources = Model.PossibleResources.Where(possibleResource => possibleResource.ResourceOid.HasValue && selectedResourceOids.Contains(possibleResource.ResourceOid.Value)).ToList(); Model.SelectedResourcesForFiltering = selectedResources; Model.SelectedResourceOidsForFiltering = selectedResources.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value).ToList(); return PartialView("AptFltResourcePopupListPartial", Model); } [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); } private ActionResult FilterAppointments(string filters) { var filterPairs = filters?.Split(';') ?? Array.Empty(); 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); } } }