Files
BeWoPlaner/BeWoPlanerMobil/Models/AbstractModel.cs
Lyndon Jetten 197c1b8da6 FaC:
Termine in die Zeiterfassung übernehmen hat jetzt eine Link-Table, um das entsprechende Icon zuverlässig anzuzeigen.

MoK:
Löschen von Quittierungsbelegunterschriften eingebaut.
Bewerten von Zielen/Maßnahmen an das entsprechende Recht gekoppelt.
2023-01-26 12:55:56 +01:00

144 lines
7.1 KiB
C#

using System.Collections.Generic;
using System.Linq;
using BeWoPlanerMobil.Service;
using BeWoPlanerMobil.Util;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
namespace BeWoPlanerMobil.Models
{
public class AbstractModel
{
public static bool IsDeleteBtnVisible => CheckRight(UserRightType.ServiceRecordView_Delete);
public static bool IsAllowedToSeeScheduler => MobileSessionFacade.LoggedInUser != null && CheckRight(UserRightType.KalenderAnsehen) || CheckRight(UserRightType.ViewAll);
public static bool IsAllowedToSeeCustomers => CheckRight(UserRightType.ViewAll) || CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers);
public static bool IsEmployeeSelectionVisible => CheckRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees) || CheckRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember);
public static bool HasRightForGroupBookings => CheckRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking);
public static bool HasRightToViewCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAlleAnsehen) && CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.ViewAll);
public static bool HasRightToViewEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAnsehen) || CheckRight(UserRightType.ViewAll);
public static bool HasRightToViewAllResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAnsehen) || CheckRight(UserRightType.ViewAll);
public EmployeeDC Employee { get; set; }
public string LoggedInEmplyeeFirstNameLastName => Employee != null ? $"{Employee.FirstName} {Employee.LastName}" : "BeWoPlaner";
public static bool HasRightToSeeAllSupportConcepts => CheckRight(UserRightType.SupportConcept_ViewAllSupportConcepts) || CheckRight(UserRightType.ViewAll);
public static bool HasRightToSeeTextModules => CheckRight(UserRightType.TextbausteineNurEigeneAnsehen) || CheckRight(UserRightType.TextbausteineAlleAnsehen);
public static bool HasRightToSeeServiceRecords => CheckRight(UserRightType.ServiceRecordView_View) && CheckRight(UserRightType.ServiceRecordView_Create);
public static string TimeOfLastAction { get; set; }
public static bool HasRightToInsertRessourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAnlegen) || CheckRight(UserRightType.CreateAll);
public static bool IsAllowedToSeeBills
{
get
{
var mandator = new MobileSessionFacade().OperationsService.GetMandator();
var showEmployeeSignatureSetting = MobileUtils.GetSettingValue(mandator.Settings, SettingsKeys.ShowSignature);
return CheckRight(UserRightType.Analysis_ServiceOverview_View) && showEmployeeSignatureSetting != null && showEmployeeSignatureSetting.Equals("1");
}
}
public static bool IsAllowedToSeeSupportConceptFilter
{
get
{
var user = MobileSessionFacade.LoggedInUser;
if(user != null)
{
return
user.CheckForAtLeastOneRight(new List<UserRightType> { UserRightType.ViewAll, UserRightType.SupportConcept_ViewAllSupportConcepts }) ||
user.CheckForRight(UserRightType.SupportConcept_ViewMyTeams);
}
return false;
}
}
public static string UserSettings
{
get
{
var user = MobileSessionFacade.LoggedInUser;
return user?.SettingList.FirstOrDefault(f => f.Type.Equals(SettingsType.ApplicationSettings))?.Value;
}
}
public static bool IsAllowedToSeeCustomerFilter
{
get
{
var user = MobileSessionFacade.LoggedInUser;
if(user != null)
{
return
user.CheckForRight(UserRightType.ViewAll) ||
user.CheckForRight(UserRightType.Customer_ViewMyTeams);
}
return false;
}
}
public static bool IsAllowedToSeeMedikamentenliste
{
get
{
var mandator = new MobileSessionFacade().OperationsService.GetMandator();
var hasSetting = MobileUtils.GetSettingValue(mandator.Settings, SettingsKeys.ShowMedication) == "1";
var hasRight = CheckRight(UserRightType.Customer_ViewMedication);
return hasSetting && hasRight;
}
}
public static bool CheckRight(UserRightType userRightType)
{
return MobileSessionFacade.CheckForUserRight(userRightType);
}
public static bool HasRightToInsertEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAnlegen) ||
CheckRight(UserRightType.CreateAll);
public static bool HasRightToEditEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAendern) || CheckRight(UserRightType.EditAll);
public static bool HasRightToEditResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAendern) || CheckRight(UserRightType.EditAll);
public static bool HasRightToEditOthersResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAndererAendern) || CheckRight(UserRightType.EditAll);
public static bool HasRightToInsertCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAnlegen) &&
(CheckRight(UserRightType.CustomerView_View) ||
CheckRight(UserRightType.Customer_ViewMyCustomers) ||
CheckRight(UserRightType.Customer_ViewMyTeams)) ||
CheckRight(UserRightType.CreateAll);
public static bool HasRightToEditCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAendern) || CheckRight(UserRightType.EditAll);
public static bool ShowServiceRecordInsertedOn { get; set; }
public static bool HasRightToViewCustomerSelectionInScheduler => CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers) || CheckRight(UserRightType.Customer_ViewMyTeams);
public static bool HasRightToViewTeams => CheckRight(UserRightType.TeamView_ViewMyTeams) || CheckRight(UserRightType.TeamView_ViewAll);
public static bool HasRightForMultiBooking => CheckRight(UserRightType.ServiceRecord_AllowCreatingMultiBooking);
public static bool HasRightToDeleteReceiptSignatures => CheckRight(UserRightType.ConfirmationReceiptSignatures_Delete);
public static bool HasRightToRateGoals => CheckRight(UserRightType.BewertenInZeiterfassung);
}
}