1. LoginStatus-Meldung wurde nicht angezeigt 2. Farben bei den Terminen hinzugefügt 3. Aufgaben werden angezeigt im Kalender Code aufgeräumt
96 lines
3.5 KiB
C#
96 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BeWoPlanerMobil.Service;
|
|
using BeWoPlanerMobil.Util;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Extensions;
|
|
|
|
namespace BeWoPlanerMobil.Models
|
|
{
|
|
public class SchedulerModel : AbstractModel
|
|
{
|
|
public DateTime SelectedDate { get; set; } = DateTime.Today;
|
|
|
|
public SchedulerAppointmentDC SelectedAppointment { get; set; }
|
|
|
|
public List<SchedulerAppointmentDC> Appointments { get; set; } = new List<SchedulerAppointmentDC>();
|
|
|
|
public List<AppointmentListItem> AppointmentListItems
|
|
{
|
|
get
|
|
{
|
|
var result = new List<AppointmentListItem>();
|
|
|
|
Appointments.DoForEach(app => result.AddIfNotIn(new AppointmentListItem(app)));
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public bool HasRightToEditAppointment(long? appointmentOid)
|
|
{
|
|
if (appointmentOid == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var appointment = Appointments.FirstOrDefault(app => app.SchedulerAppointmentOid.HasValue && app.SchedulerAppointmentOid.Value == appointmentOid);
|
|
|
|
if (appointment == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var hasCustomers = appointment.CustomerList.Any();
|
|
var hasEmployees = appointment.EmployeeList.Any();
|
|
var hasResources = appointment.ResourceList.Any();
|
|
|
|
var result = true;
|
|
|
|
if(hasEmployees)
|
|
{
|
|
result = hasResources ?
|
|
MobileSessionFacade.CheckForUserRight(UserRightType.KalenderRessourcentermineAndererAendern) :
|
|
MobileSessionFacade.CheckForUserRight(UserRightType.KalenderMitarbeitertermineAendern);
|
|
|
|
if (appointment.CustomerList.Any())
|
|
{
|
|
result = MobileSessionFacade.CheckForUserRight(UserRightType.KalenderKliententermineAendern) && result;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(hasCustomers && hasResources)
|
|
{
|
|
result = MobileSessionFacade.CheckForUserRight(UserRightType.KalenderKliententermineAendern) && MobileSessionFacade.CheckForUserRight(UserRightType.KalenderRessourcentermineAendern);
|
|
}
|
|
else if(hasCustomers)
|
|
{
|
|
result = MobileSessionFacade.CheckForUserRight(UserRightType.KalenderKliententermineAendern);
|
|
}
|
|
else if(hasResources)
|
|
{
|
|
result = MobileSessionFacade.CheckForUserRight(UserRightType.KalenderRessourcentermineAendern);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public string DescriptionToEdit => SelectedAppointment?.Description ?? string.Empty;
|
|
|
|
public string SubjectToEdit => SelectedAppointment?.Subject ?? string.Empty;
|
|
|
|
public string StartDateToEdit => SelectedAppointment?.StartDate?.ToShortDateString() ?? SelectedDate.ToShortDateString();
|
|
|
|
public string EndDateToEdit => SelectedAppointment?.EndDate?.ToShortDateString() ?? SelectedDate.ToShortDateString();
|
|
|
|
public string StartTimeToEdit => SelectedAppointment?.StartDate?.ToShortTimeString() ?? string.Empty;
|
|
|
|
public string EndTimeToEdit => SelectedAppointment?.EndDate?.ToShortTimeString() ?? string.Empty;
|
|
|
|
public string LocationToEdit => SelectedAppointment?.Location ?? string.Empty;
|
|
}
|
|
} |