public MovementDocumentViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, IWarehousePermissionService warehousePermissionService, IEmployeeService employeeService, IEntityExtendedPermissionValidator entityExtendedPermissionValidator, INomenclatureSelectorFactory nomenclatureSelectorFactory, IOrderSelectorFactory orderSelectorFactory, IWarehouseRepository warehouseRepository, IUserRepository userRepository, IRDLPreviewOpener rdlPreviewOpener, ICommonServices commonServices) : base(uowBuilder, unitOfWorkFactory, commonServices) { this.unitOfWorkFactory = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory)); this.employeeService = employeeService ?? throw new ArgumentNullException(nameof(employeeService)); this.entityExtendedPermissionValidator = entityExtendedPermissionValidator ?? throw new ArgumentNullException(nameof(entityExtendedPermissionValidator)); this.nomenclatureSelectorFactory = nomenclatureSelectorFactory ?? throw new ArgumentNullException(nameof(nomenclatureSelectorFactory)); this.orderSelectorFactory = orderSelectorFactory ?? throw new ArgumentNullException(nameof(orderSelectorFactory)); this.warehouseRepository = warehouseRepository ?? throw new ArgumentNullException(nameof(warehouseRepository)); this.userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository)); this.rdlPreviewOpener = rdlPreviewOpener ?? throw new ArgumentNullException(nameof(rdlPreviewOpener)); warehousePermissionValidator = warehousePermissionService.GetValidator(CommonServices.UserService.CurrentUserId); canEditRectroactively = entityExtendedPermissionValidator.Validate(typeof(MovementDocument), CommonServices.UserService.CurrentUserId, nameof(RetroactivelyClosePermission)); ConfigureEntityChangingRelations(); if (UoW.IsNew) { Entity.DocumentType = MovementDocumentType.Transportation; SetDefaultWarehouseFrom(); } ValidationContext.ServiceContainer.AddService(typeof(IWarehouseRepository), warehouseRepository); }
public IncomingInvoiceViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, IWarehousePermissionService warehousePermissionService, IEmployeeService employeeService, IEntityExtendedPermissionValidator entityExtendedPermissionValidator, INomenclatureJournalFactory nomenclatureSelectorFactory, IOrderSelectorFactory orderSelectorFactory, IWarehouseRepository warehouseRepository, IRDLPreviewOpener rdlPreviewOpener, ICommonServices commonServices, IStockRepository stockRepository) : base(uowBuilder, unitOfWorkFactory, commonServices) { this.employeeService = employeeService ?? throw new ArgumentNullException(nameof(employeeService)); this.entityExtendedPermissionValidator = entityExtendedPermissionValidator ?? throw new ArgumentNullException(nameof(entityExtendedPermissionValidator)); this.nomenclatureSelectorFactory = nomenclatureSelectorFactory ?? throw new ArgumentNullException(nameof(nomenclatureSelectorFactory)); this.orderSelectorFactory = orderSelectorFactory ?? throw new ArgumentNullException(nameof(orderSelectorFactory)); this.warehouseRepository = warehouseRepository ?? throw new ArgumentNullException(nameof(warehouseRepository)); this.rdlPreviewOpener = rdlPreviewOpener ?? throw new ArgumentNullException(nameof(rdlPreviewOpener)); _stockRepository = stockRepository ?? throw new ArgumentNullException(nameof(stockRepository)); warehousePermissionValidator = warehousePermissionService.GetValidator(CommonServices.UserService.CurrentUserId); canEditRectroactively = entityExtendedPermissionValidator.Validate(typeof(MovementDocument), CommonServices.UserService.CurrentUserId, nameof(RetroactivelyClosePermission)); ConfigureEntityChangingRelations(); ValidationContext.ServiceContainer.AddService(typeof(IWarehouseRepository), warehouseRepository); UserHasOnlyAccessToWarehouseAndComplaints = CommonServices.CurrentPermissionService.ValidatePresetPermission("user_have_access_only_to_warehouse_and_complaints") && !CurrentUser.IsAdmin; }
public OrganizationCashTransferDocumentViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, ICommonServices commonServices, IEntityExtendedPermissionValidator entityExtendedPermissionValidator, IEmployeeService employeeService) : base(uowBuilder, unitOfWorkFactory, commonServices) { if (employeeService == null) { throw new ArgumentNullException(nameof(employeeService)); } Organizations = UoW.GetAll <Organization>(); author = employeeService.GetEmployeeForUser(UoW, UserService.CurrentUserId); CanEditRectroactively = entityExtendedPermissionValidator.Validate(typeof(OrganizationCashTransferDocument), CommonServices.UserService.CurrentUserId, nameof(RetroactivelyClosePermission)); CanEdit = (Entity.Id == 0 && PermissionResult.CanCreate) || (PermissionResult.CanUpdate && Entity.DocumentDate.Date == DateTime.Now.Date) || CanEditRectroactively; if (Entity.Id == 0) { Entity.DocumentDate = DateTime.Now; Entity.Author = author; } }