2020-04-02 13:19:14 +02:00
|
|
|
|
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
|
2019-07-25 14:58:13 +02:00
|
|
|
|
{
|
2020-02-07 15:21:36 +01:00
|
|
|
|
public class SchedulerModel : AbstractModel
|
2019-07-25 14:58:13 +02:00
|
|
|
|
{
|
2020-04-02 13:19:14 +02:00
|
|
|
|
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>();
|
|
|
|
|
|
|
2020-04-24 19:08:09 +02:00
|
|
|
|
Appointments.DoForEach(app => result.AddIfNotIn(new AppointmentListItem(app)));
|
2020-04-02 13:19:14 +02:00
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-24 19:08:09 +02:00
|
|
|
|
public bool HasRightToEditAppointment(long? appointmentOid)
|
2020-04-02 13:19:14 +02:00
|
|
|
|
{
|
2020-04-24 19:08:09 +02:00
|
|
|
|
if (appointmentOid == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-02 13:19:14 +02:00
|
|
|
|
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;
|
2020-04-24 19:08:09 +02:00
|
|
|
|
|
2020-04-02 13:19:14 +02:00
|
|
|
|
public string SubjectToEdit => SelectedAppointment?.Subject ?? string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
public string StartDateToEdit => SelectedAppointment?.StartDate?.ToShortDateString() ?? SelectedDate.ToShortDateString();
|
2020-04-24 19:08:09 +02:00
|
|
|
|
|
2020-04-02 13:19:14 +02:00
|
|
|
|
public string EndDateToEdit => SelectedAppointment?.EndDate?.ToShortDateString() ?? SelectedDate.ToShortDateString();
|
|
|
|
|
|
|
|
|
|
|
|
public string StartTimeToEdit => SelectedAppointment?.StartDate?.ToShortTimeString() ?? string.Empty;
|
2020-04-24 19:08:09 +02:00
|
|
|
|
|
2020-04-02 13:19:14 +02:00
|
|
|
|
public string EndTimeToEdit => SelectedAppointment?.EndDate?.ToShortTimeString() ?? string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
public string LocationToEdit => SelectedAppointment?.Location ?? string.Empty;
|
2020-06-29 19:24:24 +02:00
|
|
|
|
|
|
|
|
|
|
public List<ResourceDC> AllResources { get; set; } = new List<ResourceDC>();
|
|
|
|
|
|
|
|
|
|
|
|
public List<ResourceDC> SelectedResources { get; set; } = new List<ResourceDC>();
|
|
|
|
|
|
|
|
|
|
|
|
public Dictionary<ValueListEntryDC, List<ResourceDC>> ResourceCategories2Resources { get; set; } = new Dictionary<ValueListEntryDC, List<ResourceDC>>();
|
|
|
|
|
|
|
|
|
|
|
|
public List<SchedulerAppointmentDC> RecurringAppointments { get; set; } = new List<SchedulerAppointmentDC>();
|
2019-07-25 14:58:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|