Ejemplo n.º 1
0
        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 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);
        }