protected void InitializePermissionValidator() { var user = UserRepository.GetCurrentUser(UoW); permissionResult = ServicesConfig.CommonServices.PermissionService.ValidateUserPermission(objectType, user.Id); if (!permissionResult.CanRead) { var message = PermissionsSettings.GetEntityReadValidateResult(objectType); MessageDialogHelper.RunErrorDialog(message); FailInitialize = true; } }
public PermissionControlledRepresentationJournal(IRepresentationModel representationModel, Buttons buttons = Buttons.All) : base(representationModel) { if (RepresentationModel.EntityType != null) { UpdateUserEntityPermission(); if (!permissionResult.CanRead) { var message = PermissionsSettings.GetEntityReadValidateResult(RepresentationModel.EntityType); MessageDialogHelper.RunErrorDialog(message); FailInitialize = true; } } this.buttons = buttons; ConfigureActionButtons(); }
protected void InitializePermissionValidator() { permissionResult = new PermissionResult(EntityPermission.AllAllowed); Type entityType = typeof(TEntity); int? currUserId; using (IUnitOfWork uow = UnitOfWorkFactory.CreateWithoutRoot()) { currUserId = UserRepository.GetCurrentUser(uow)?.Id; } if (!currUserId.HasValue) { return; } permissionResult = ServicesConfig.CommonServices.PermissionService.ValidateUserPermission(entityType, currUserId.Value); if (!permissionResult.CanRead) { var message = PermissionsSettings.GetEntityReadValidateResult(entityType); MessageDialogHelper.RunErrorDialog(message); FailInitialize = true; } }
public EmployeeViewModel( IAuthorizationService authorizationService, IEmployeeWageParametersFactory employeeWageParametersFactory, IEmployeeJournalFactory employeeJournalFactory, ISubdivisionJournalFactory subdivisionJournalFactory, IEmployeePostsJournalFactory employeePostsJournalFactory, ICashDistributionCommonOrganisationProvider commonOrganisationProvider, ISubdivisionService subdivisionService, IEmailServiceSettingAdapter emailServiceSettingAdapter, IWageCalculationRepository wageCalculationRepository, IEmployeeRepository employeeRepository, IUnitOfWorkGeneric <Employee> uowGeneric, ICommonServices commonServices, IValidationContextFactory validationContextFactory, IPhonesViewModelFactory phonesViewModelFactory, IWarehouseRepository warehouseRepository, IRouteListRepository routeListRepository, DriverApiUserRegisterEndpoint driverApiUserRegisterEndpoint, UserSettings userSettings, IUserRepository userRepository, BaseParametersProvider baseParametersProvider, bool traineeToEmployee = false, INavigationManager navigationManager = null ) : base(commonServices?.InteractiveService, navigationManager) { _authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService)); EmployeeWageParametersFactory = employeeWageParametersFactory ?? throw new ArgumentNullException(nameof(employeeWageParametersFactory)); EmployeeJournalFactory = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory)); EmployeePostsJournalFactory = employeePostsJournalFactory ?? throw new ArgumentNullException(nameof(employeePostsJournalFactory)); SubdivisionJournalFactory = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory)); if (commonOrganisationProvider == null) { throw new ArgumentNullException(nameof(commonOrganisationProvider)); } _subdivisionService = subdivisionService ?? throw new ArgumentNullException(nameof(subdivisionService)); _emailServiceSettingAdapter = emailServiceSettingAdapter ?? throw new ArgumentNullException(nameof(emailServiceSettingAdapter)); _wageCalculationRepository = wageCalculationRepository ?? throw new ArgumentNullException(nameof(wageCalculationRepository)); _employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository)); _warehouseRepository = warehouseRepository ?? throw new ArgumentNullException(nameof(warehouseRepository)); _routeListRepository = routeListRepository ?? throw new ArgumentNullException(nameof(routeListRepository)); _driverApiUserRegisterEndpoint = driverApiUserRegisterEndpoint ?? throw new ArgumentNullException(nameof(driverApiUserRegisterEndpoint)); _userSettings = userSettings ?? throw new ArgumentNullException(nameof(userSettings)); UoWGeneric = uowGeneric ?? throw new ArgumentNullException(nameof(uowGeneric)); _commonServices = commonServices ?? throw new ArgumentNullException(nameof(commonServices)); _userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository)); _baseParametersProvider = baseParametersProvider ?? throw new ArgumentNullException(nameof(baseParametersProvider)); if (validationContextFactory == null) { throw new ArgumentNullException(nameof(validationContextFactory)); } ConfigureValidationContext(validationContextFactory); if (phonesViewModelFactory == null) { throw new ArgumentNullException(nameof(phonesViewModelFactory)); } PhonesViewModel = phonesViewModelFactory.CreateNewPhonesViewModel(UoW); if (Entity.Id == 0) { Entity.OrganisationForSalary = commonOrganisationProvider.GetCommonOrganisation(UoW); TabName = "Новый сотрудник"; } else { TabName = Entity.GetPersonNameWithInitials(); } if (Entity.Phones == null) { Entity.Phones = new List <Phone>(); } SetPermissions(); Entity.PropertyChanged += OnEntityPropertyChanged; organizations = UoW.GetAll <Organization>().ToList(); FillHiddenCategories(traineeToEmployee); CanRegisterMobileUser = string.IsNullOrWhiteSpace(Entity.AndroidLogin) && string.IsNullOrWhiteSpace(Entity.AndroidPassword); var permissionResult = _commonServices.PermissionService.ValidateUserPermission(typeof(Employee), _commonServices.UserService.CurrentUserId); if (!permissionResult.CanRead) { AbortOpening(PermissionsSettings.GetEntityReadValidateResult(typeof(Employee))); } }