Files
BeWoPlaner/BeWoPlanerMobil/Service/MobileUpdInsInterceptor.cs
Lyndon Jetten c6282ec1a9 BeWoWebApi:
BeWoWebApi für den neuen Mobilklient

BeWoPlanerMobil:
.NET Version auf 4.7.2 gesetzt.
GetState im Mobilklienten
Abwesenheiten im Mobilklienten auskommentiert
2020-01-15 16:14:39 +01:00

55 lines
1.4 KiB
C#

using System;
using BeWo.Data.Entities;
using BS.Shared.Extensions;
using NHibernate;
using NHibernate.Type;
namespace BeWoPlanerMobil.Service
{
public class MobileUpdInsInterceptor : EmptyInterceptor
{
public override bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types)
{
var i = propertyNames.IndexOf(BeWoEntityBase.PropertyName_UdpUser);
if (i >= 0)
{
if (MobileSessionFacade.IsUserLoggedIn())
{
currentState[i] = $"{MobileSessionFacade.EmployeeFullname}";
}
else
{
currentState[i] = null;
}
}
return base.OnFlushDirty(entity, id, currentState, previousState, propertyNames, types);
}
public override bool OnSave(object entity, object id, object[] state, string[] propertyNames, IType[] types)
{
if (MobileSessionFacade.IsUserLoggedIn())
{
var i = propertyNames.IndexOf(BeWoEntityBase.PropertyName_InsUser);
if (i >= 0)
{
state[i] = $"{MobileSessionFacade.EmployeeFullname}";
}
i = propertyNames.IndexOf(BeWoEntityBase.PropertyName_UdpUser);
if (i >= 0)
{
state[i] = $"{MobileSessionFacade.EmployeeFullname}";
}
}
var i2 = propertyNames.IndexOf(BeWoEntityBase.PropertyName_InsTs);
if (i2 >= 0)
state[i2] = DateTime.Now;
return base.OnSave(entity, id, state, propertyNames, types);
}
}
}