Files
BeWoPlaner/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs

95 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Web.Mvc;
using BeWoPlanerMobil.Models;
using BeWoPlanerMobil.Service;
using BeWoPlanerMobil.Views.DevExpressScheduler;
using BS.Shared.DataContracts;
using DevExpress.Web.Mvc;
namespace BeWoPlanerMobil.Controllers
{
public class DevExpressSchedulerController : AbstractBaseController
{
private DevExpressSchedulerModel _Model;
public DevExpressSchedulerModel Model
{
get
{
if (!MobileSessionFacade.IsUserLoggedIn())
{
Logout();
return null;
}
if (((DevExpressSchedulerModel)Session["DevExpressSchedulerModel"])?.Employee == null)
{
_Model = new DevExpressSchedulerModel { Employee = MobileSessionFacade.LoggedInEmployee };
Session["DevExpressSchedulerModel"] = _Model;
}
else
{
_Model = (DevExpressSchedulerModel)Session["DevExpressSchedulerModel"];
}
return _Model;
}
}
[Authorize]
public ActionResult DevExpressScheduler()
{
if (!MobileSessionFacade.IsUserLoggedIn() || Model == null)
{
return RedirectToActionPermanent("Index", "Login");
}
var appointments = KalenderService.LoadFilteredAppointments(
true,
Model?.Employee?.EmployeeOid ?? 1,
DateTime.Today.AddDays(-60),
DateTime.Today.AddDays(60),
new List<long>(),
new List<long>(),
new List<long>(),
false,
false,
false,
false,
false);
Model.Appointments = appointments;
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<SchedulerAppointmentDC>(SchedulerHelper.GetSchedulerSettings(), Model.Appointments);
var appointmentsToUpdate = SchedulerExtension.GetAppointmentsToUpdate<SchedulerAppointmentDC>(SchedulerHelper.GetSchedulerSettings(), Model.Appointments);
var appointmentsToRemove = SchedulerExtension.GetAppointmentsToRemove<SchedulerAppointmentDC>(SchedulerHelper.GetSchedulerSettings(), Model.Appointments);
}
[Authorize]
public override string SaveCollapsibleStatus(bool isOpen, string identifier)
{
Model.Collapsibles2IsShown[identifier] = isOpen;
return LeerzeichenFuerGetMethoden;
}
}
}