Speichern von Zeiterfassung außerhalb HP-Zeitraum zulassen falls Recht vorhanden
This commit is contained in:
@@ -370,6 +370,7 @@
|
||||
<Compile Include="LoggedInUserOperationContextExt.cs" />
|
||||
<Compile Include="MultitenancyOperationContextExt.cs" />
|
||||
<Compile Include="Security\BCrypt.cs" />
|
||||
<Compile Include="Security\UserRightHelper.cs" />
|
||||
<Compile Include="SessionFacade.cs" />
|
||||
<Compile Include="SessionOperationContextExt.cs" />
|
||||
<Compile Include="Entities\BeWoEntityBase.cs" />
|
||||
|
||||
56
Data/Security/UserRightHelper.cs
Normal file
56
Data/Security/UserRightHelper.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using BeWo.Data.Entities;
|
||||
using BS.Shared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeWo.Data.Security
|
||||
{
|
||||
public class UserRightHelper
|
||||
{
|
||||
public static ApplicationUser GetLoggedInUser()
|
||||
{
|
||||
|
||||
if (LoggedInUserOperationContextExt.Current != null &&
|
||||
LoggedInUserOperationContextExt.Current.User != null)
|
||||
{
|
||||
return LoggedInUserOperationContextExt.Current.User;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SessionFacade.LoggedInUser;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool LoggedInUserHasRight(UserRightType right)
|
||||
{
|
||||
return GetGrantedRights(GetLoggedInUser()).Contains(right);
|
||||
|
||||
}
|
||||
|
||||
public static bool UserHasRight(ApplicationUser user, UserRightType right)
|
||||
{
|
||||
return GetGrantedRights(user).Contains(right);
|
||||
|
||||
}
|
||||
|
||||
public static List<UserRightType> GetGrantedRights(ApplicationUser user)
|
||||
{
|
||||
var rights = new List<UserRightType>();
|
||||
foreach (var ug in user.UserGroups)
|
||||
{
|
||||
foreach (var rr in ug.Rights)
|
||||
{
|
||||
rights.Add(rr.RightType);
|
||||
}
|
||||
}
|
||||
|
||||
return rights;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.Extensions;
|
||||
using BS.Shared.Services;
|
||||
using BeWo.Service.Configuration;
|
||||
using BeWo.Data.Security;
|
||||
|
||||
namespace BeWo.Service.Plugins
|
||||
{
|
||||
@@ -388,11 +389,22 @@ namespace BeWo.Service.Plugins
|
||||
if (reldc.StartDate.HasValue && reldc.EndDate.HasValue)
|
||||
if (!start.InBetween(reldc.StartDate.Value, reldc.EndDate.Value, true))
|
||||
{
|
||||
String handlungsOption = "Das Speichern ist nicht möglich.";
|
||||
bool hatDasRechtTrotzdemZuSpeichern = false;
|
||||
|
||||
if (UserRightHelper.LoggedInUserHasRight(UserRightType.BookServiceRecordOutOfSupportConcept))
|
||||
{
|
||||
handlungsOption = "Trotzdem Speichern?";
|
||||
hatDasRechtTrotzdemZuSpeichern = true;
|
||||
}
|
||||
|
||||
var dc = new ServiceRecordValidationResultDC
|
||||
{
|
||||
ResultType = ServiceRecordValidationResult.OutsideOfSupportConcept,
|
||||
ResultType = ServiceRecordValidationResult.Custom,
|
||||
Message = $"Das gewählte Datum '{start}' liegt außerhalb des Hilfeplanzeitraums ('{reldc.StartDate.Value.ToShortDateString()}' bis '{reldc.EndDate.Value.ToShortDateString()}').\n" + handlungsOption,
|
||||
StartDate = reldc.StartDate.Value,
|
||||
EndDate = reldc.EndDate.Value
|
||||
EndDate = reldc.EndDate.Value,
|
||||
Allow = hatDasRechtTrotzdemZuSpeichern
|
||||
};
|
||||
result.Add(dc);
|
||||
}
|
||||
@@ -467,7 +479,7 @@ namespace BeWo.Service.Plugins
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public virtual ServiceRecordValidationResultDC CheckAbwesenheiten(ServiceRecordDC newServiceRecord, IList<ServiceRecord> allRecords, SupportConceptCostBearerRelDC reldc, decimal rd, bool isGroupRecord)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user