Files
BeWoPlaner/Shared/Core/SchedulerUtils.cs
Lyndon Jetten 58b361498f FaC:
ServiceRecord-Fremdschlüssel zu NewSchedulerAppointment-Tabelle hinzugefügt. Funktionalität ist noch nicht implementiert.

MoK:
Ziele/Maßnahmen verbessert; Suche funktioniert jetzt richtig
Mehrfachbuchung implementiert
Kalender:
Termine sind jetzt löschbar, wenn Recht zu bearbeiten vorhanden ist.
Unterscheidung zwischen Mitarbeiter-, Klienten-, und Ressourcenauswahl bei Ansicht und Formular
2022-12-30 16:28:23 +01:00

103 lines
4.6 KiB
C#

using System;
using System.Collections.Generic;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
namespace BS.Shared.Core
{
public static class SchedulerUtils
{
public static List<SchedulerAppointmentDC> GenerateSeveralDaysAppointments(List<SchedulerAppointmentDC> severalDaysAppointments)
{
var result = new List<SchedulerAppointmentDC>();
foreach(var termin in severalDaysAppointments)
{
if(termin.StartDate is null || termin.EndDate is null)
{
continue;
}
var tage = termin.StartDate.Value.GetDayNumberBetweenTwoDates(termin.EndDate.Value);
if(tage > 31)
{
tage = 31;
}
if(termin.AllDay)
{
tage -= 1;
}
if(tage > 0)
{
if(termin.AllDay)
{
for(var i = 0; i <= tage; i++)
{
var isAllDay = termin.AllDay;
var startDate = new DateTime(termin.StartDate.Value.AddDays(i).Year, termin.StartDate.Value.AddDays(i).Month, termin.StartDate.Value.AddDays(i).Day);
var endDate = new DateTime(termin.StartDate.Value.AddDays(i + 1).Year, termin.StartDate.Value.AddDays(i + 1).Month, termin.StartDate.Value.AddDays(i + 1).Day);
result.Add(CreateAppointment(isAllDay, startDate, endDate, termin));
}
}
else
{
for(var i = 0; i <= tage; i++)
{
if(i == 0)
{
var startDate = termin.StartDate.Value;
var endDate = new DateTime(termin.StartDate.Value.AddDays(1).Year, termin.StartDate.Value.AddDays(1).Month, termin.StartDate.Value.AddDays(1).Day);
result.Add(CreateAppointment(false, startDate, endDate, termin));
}
else if(i == tage)
{
var startDate = new DateTime(termin.EndDate.Value.Year, termin.EndDate.Value.Month, termin.EndDate.Value.Day);
var endDate = termin.EndDate.Value;
result.Add(CreateAppointment(false, startDate, endDate, termin));
}
else
{
var startDate = new DateTime(termin.StartDate.Value.AddDays(i).Year, termin.StartDate.Value.AddDays(i).Month, termin.StartDate.Value.AddDays(i).Day);
var endDate = new DateTime(termin.StartDate.Value.AddDays(i + 1).Year, termin.StartDate.Value.AddDays(i + 1).Month, termin.StartDate.Value.AddDays(i + 1).Day);
result.Add(CreateAppointment(true, startDate, endDate, termin));
}
}
}
}
}
return result;
}
private static SchedulerAppointmentDC CreateAppointment(bool isAllDay, DateTime startDate, DateTime endDate, SchedulerAppointmentDC appointment)
{
return new SchedulerAppointmentDC
{
AllDay = isAllDay,
CustomerList = appointment.CustomerList,
Description = appointment.Description,
EmployeeList = appointment.EmployeeList,
EndDate = endDate,
FormerBookingSequenceOid = appointment.FormerBookingSequenceOid,
IsPrivate = appointment.IsPrivate,
LabelKey = appointment.LabelKey,
Location = appointment.Location,
Originator = appointment.Originator,
RecurrenceInfo = appointment.RecurrenceInfo,
ReminderInfo = appointment.ReminderInfo,
ResourceList = appointment.ResourceList,
StartDate = startDate,
Status = appointment.Status,
Subject = appointment.Subject,
Type = appointment.Type
};
}
}
}