public FuelWriteoffDocumentViewModel(
            IEntityUoWBuilder uoWBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            IEmployeeService employeeService,
            IFuelRepository fuelRepository,
            ISubdivisionRepository subdivisionRepository,
            ICommonServices commonServices,
            IEmployeeJournalFactory employeeJournalFactory,
            IReportViewOpener reportViewOpener,
            ISubdivisionJournalFactory subdivisionJournalFactory,
            IExpenseCategorySelectorFactory expenseCategorySelectorFactory
            )
            : base(uoWBuilder, unitOfWorkFactory, commonServices)
        {
            this.unitOfWorkFactory     = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
            this.employeeService       = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
            this.fuelRepository        = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
            this.subdivisionRepository = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            this.commonServices        = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
            EmployeeJournalFactory     = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            this.reportViewOpener      = reportViewOpener ?? throw new ArgumentNullException(nameof(reportViewOpener));
            SubdivisionJournalFactory  = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));
            ExpenseSelectorFactory     =
                expenseCategorySelectorFactory ?? throw new ArgumentNullException(nameof(expenseCategorySelectorFactory));

            CreateCommands();
            UpdateCashSubdivisions();

            TabName = "Акт выдачи топлива";
            if (CurrentEmployee == null)
            {
                AbortOpening("К вашему пользователю не привязан сотрудник, невозможно открыть документ");
            }

            if (UoW.IsNew)
            {
                Entity.Date    = DateTime.Now;
                Entity.Cashier = CurrentEmployee;
            }

            ValidationContext.ServiceContainer.AddService(typeof(IFuelRepository), fuelRepository);
            ConfigureEntries();
        }
        private void CreateNewDependencies()
        {
            _authorizationServiceFactory   = new AuthorizationServiceFactory();
            _employeeWageParametersFactory = new EmployeeWageParametersFactory();
            _employeeJournalFactory        = this;
            _subdivisionJournalFactory     = new SubdivisionJournalFactory();
            _employeePostsJournalFactory   = new EmployeePostsJournalFactory();

            _cashDistributionCommonOrganisationProvider =
                new CashDistributionCommonOrganisationProvider(new OrganizationParametersProvider(new ParametersProvider()));

            _subdivisionService         = SubdivisionParametersProvider.Instance;
            _emailServiceSettingAdapter = new EmailServiceSettingAdapter();
            _wageCalculationRepository  = new WageCalculationRepository();
            _employeeRepository         = new EmployeeRepository();
            _validationContextFactory   = new ValidationContextFactory();
            _phonesViewModelFactory     = new PhonesViewModelFactory(new PhoneRepository());
            _warehouseRepository        = new WarehouseRepository();
            _routeListRepository        = new RouteListRepository(new StockRepository(), new BaseParametersProvider(new ParametersProvider()));
        }
示例#3
0
        public ExpenseCategoryJournalViewModel(
            ExpenseCategoryJournalFilterViewModel filterViewModel,
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            IFileChooserProvider fileChooserProvider,
            IEmployeeJournalFactory employeeJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory
            ) : base(filterViewModel, unitOfWorkFactory, commonServices)
        {
            _unitOfWorkFactory         = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
            _fileChooserProvider       = fileChooserProvider ?? throw new ArgumentNullException(nameof(fileChooserProvider));
            _employeeJournalFactory    = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            _subdivisionJournalFactory = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));

            TabName = "Категории расхода";

            UpdateOnChanges(
                typeof(ExpenseCategory),
                typeof(Subdivision)
                );
        }
示例#4
0
        public IncomeCategoryViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            IEmployeeJournalFactory employeeJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory,
            IIncomeCategorySelectorFactory incomeCategorySelectorFactory
            ) : base(uowBuilder, unitOfWorkFactory, commonServices)
        {
            IncomeCategoryAutocompleteSelectorFactory =
                (incomeCategorySelectorFactory ?? throw new ArgumentNullException(nameof(incomeCategorySelectorFactory)))
                .CreateDefaultIncomeCategoryAutocompleteSelectorFactory();

            var employeeAutocompleteSelector =
                (employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory)))
                .CreateEmployeeAutocompleteSelectorFactory();

            SubdivisionAutocompleteSelectorFactory =
                (subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory)))
                .CreateDefaultSubdivisionAutocompleteSelectorFactory(employeeAutocompleteSelector);

            TabName = uowBuilder.IsNewEntity ? "Создание новой категории дохода" : $"{Entity.Title}";
        }
        public ExpenseCategoryViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            IFileChooserProvider fileChooserProvider,
            ExpenseCategoryJournalFilterViewModel journalFilterViewModel,
            IEmployeeJournalFactory employeeJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory
            ) : base(uowBuilder, unitOfWorkFactory, commonServices)
        {
            if (employeeJournalFactory == null)
            {
                throw new ArgumentNullException(nameof(employeeJournalFactory));
            }

            if (subdivisionJournalFactory == null)
            {
                throw new ArgumentNullException(nameof(subdivisionJournalFactory));
            }

            ExpenseCategoryAutocompleteSelectorFactory =
                new ExpenseCategoryAutoCompleteSelectorFactory(
                    commonServices, journalFilterViewModel, fileChooserProvider, employeeJournalFactory, subdivisionJournalFactory);

            SubdivisionAutocompleteSelectorFactory =
                subdivisionJournalFactory.CreateDefaultSubdivisionAutocompleteSelectorFactory(
                    employeeJournalFactory.CreateEmployeeAutocompleteSelectorFactory());

            if (uowBuilder.IsNewEntity)
            {
                TabName = "Создание новой категории расхода";
            }
            else
            {
                TabName = $"{Entity.Title}";
            }
        }
        public RouteListJournalViewModel(
            RouteListJournalFilterViewModel filterViewModel,
            IRouteListRepository routeListRepository,
            IFuelRepository fuelRepository,
            ISubdivisionRepository subdivisionRepository,
            ICategoryRepository categoryRepository,
            ITrackRepository trackRepository,
            IUndeliveredOrdersRepository undeliveredOrdersRepository,
            IDeliveryShiftRepository deliveryShiftRepository,
            IUnitOfWorkFactory unitOfWorkFactory,
            IRouteListParametersProvider routeListParametersProvider,
            ICallTaskWorker callTaskWorker,
            IWarehouseRepository warehouseRepository,
            ICarJournalFactory carJournalFactory,
            IEmployeeJournalFactory employeeJournalFactory,
            IEmployeeRepository employeeRepository,
            IGtkTabsOpener gtkTabsOpener,
            IOrderSelectorFactory orderSelectorFactory,
            ICounterpartyJournalFactory counterpartyJournalFactory,
            IDeliveryPointJournalFactory deliveryPointJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory,
            IUndeliveredOrdersJournalOpener undeliveredOrdersJournalOpener,
            IStockRepository stockRepository,
            IReportPrinter reportPrinter,
            ITerminalNomenclatureProvider terminalNomenclatureProvider,
            IEmployeeSettings employeeSettings,
            ICommonServices commonServices)
            : base(filterViewModel, unitOfWorkFactory, commonServices)
        {
            _routeListRepository         = routeListRepository ?? throw new ArgumentNullException(nameof(routeListRepository));
            _fuelRepository              = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
            _subdivisionRepository       = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            _categoryRepository          = categoryRepository ?? throw new ArgumentNullException(nameof(categoryRepository));
            _trackRepository             = trackRepository ?? throw new ArgumentNullException(nameof(trackRepository));
            _undeliveredOrdersRepository =
                undeliveredOrdersRepository ?? throw new ArgumentNullException(nameof(undeliveredOrdersRepository));
            _deliveryShiftRepository     = deliveryShiftRepository ?? throw new ArgumentNullException(nameof(deliveryShiftRepository));
            _routeListParametersProvider =
                routeListParametersProvider ?? throw new ArgumentNullException(nameof(routeListParametersProvider));
            _callTaskWorker              = callTaskWorker ?? throw new ArgumentNullException(nameof(callTaskWorker));
            _warehouseRepository         = warehouseRepository ?? throw new ArgumentNullException(nameof(warehouseRepository));
            _carJournalFactory           = carJournalFactory ?? throw new ArgumentNullException(nameof(carJournalFactory));
            _employeeJournalFactory      = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            _employeeRepository          = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
            _gtkTabsOpener               = gtkTabsOpener ?? throw new ArgumentNullException(nameof(gtkTabsOpener));
            _orderSelectorFactory        = orderSelectorFactory ?? throw new ArgumentNullException(nameof(orderSelectorFactory));
            _counterpartyJournalFactory  = counterpartyJournalFactory ?? throw new ArgumentNullException(nameof(counterpartyJournalFactory));
            _deliveryPointJournalFactory =
                deliveryPointJournalFactory ?? throw new ArgumentNullException(nameof(deliveryPointJournalFactory));
            _subdivisionJournalFactory      = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));
            _undeliveredOrdersJournalOpener =
                undeliveredOrdersJournalOpener ?? throw new ArgumentNullException(nameof(undeliveredOrdersJournalOpener));
            _stockRepository = stockRepository ?? throw new ArgumentNullException(nameof(stockRepository));
            _reportPrinter   = reportPrinter ?? throw new ArgumentNullException(nameof(reportPrinter));
            _terminalNomenclatureProvider = terminalNomenclatureProvider ?? throw new ArgumentNullException(nameof(terminalNomenclatureProvider));
            _employeeSettings             = employeeSettings ?? throw new ArgumentNullException(nameof(employeeSettings));
            TabName = "Журнал МЛ";

            NotifyConfiguration.Enable();
            NotifyConfiguration.Instance.BatchSubscribeOnEntity <RouteList>(changeEvents => Refresh());

            InitPopupActions();
        }
        public UndeliveredOrdersFilterViewModel(ICommonServices commonServices, IOrderSelectorFactory orderSelectorFactory,
                                                IEmployeeJournalFactory employeeJournalFactory, ICounterpartyJournalFactory counterpartyJournalFactory,
                                                IDeliveryPointJournalFactory deliveryPointJournalFactory, ISubdivisionJournalFactory subdivisionJournalFactory)
        {
            OrderSelectorFactory = (orderSelectorFactory ?? throw new ArgumentNullException(nameof(orderSelectorFactory)))
                                   .CreateOrderAutocompleteSelectorFactory();

            DriverEmployeeSelectorFactory = (employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory)))
                                            .CreateWorkingDriverEmployeeAutocompleteSelectorFactory();

            OfficeEmployeeSelectorFactory = employeeJournalFactory.CreateWorkingOfficeEmployeeAutocompleteSelectorFactory();

            CounterpartySelectorFactory = (counterpartyJournalFactory ?? throw new ArgumentNullException(nameof(counterpartyJournalFactory)))
                                          .CreateCounterpartyAutocompleteSelectorFactory();

            DeliveryPointSelectorFactory = (deliveryPointJournalFactory ?? throw new ArgumentNullException(nameof(deliveryPointJournalFactory)))
                                           .CreateDeliveryPointAutocompleteSelectorFactory();

            AuthorSubdivisionSelectorFactory = (subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory)))
                                               .CreateDefaultSubdivisionAutocompleteSelectorFactory(employeeJournalFactory.CreateEmployeeAutocompleteSelectorFactory());

            Subdivisions = UoW.GetAll <Subdivision>();
            RestrictOldOrderStartDate = DateTime.Today.AddMonths(-1);
            RestrictOldOrderEndDate   = DateTime.Today.AddMonths(1);
        }
示例#8
0
        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)));
            }
        }
示例#9
0
        public ComplaintsJournalViewModel(
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            IUndeliveredOrdersJournalOpener undeliveredOrdersJournalOpener,
            IEmployeeService employeeService,
            IEntityAutocompleteSelectorFactory counterpartySelectorFactory,
            IRouteListItemRepository routeListItemRepository,
            ISubdivisionService subdivisionService,
            ComplaintFilterViewModel filterViewModel,
            IFilePickerService filePickerService,
            ISubdivisionRepository subdivisionRepository,
            IReportViewOpener reportViewOpener,
            IGtkTabsOpener gtkDialogsOpener,
            INomenclatureRepository nomenclatureRepository,
            IUserRepository userRepository,
            IOrderSelectorFactory orderSelectorFactory,
            IEmployeeJournalFactory employeeJournalFactory,
            ICounterpartyJournalFactory counterpartyJournalFactory,
            IDeliveryPointJournalFactory deliveryPointJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory,
            ISalesPlanJournalFactory salesPlanJournalFactory,
            INomenclatureSelectorFactory nomenclatureSelector,
            IUndeliveredOrdersRepository undeliveredOrdersRepository) : base(filterViewModel, unitOfWorkFactory, commonServices)
        {
            this._unitOfWorkFactory         = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
            this._commonServices            = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
            _undeliveredOrdersJournalOpener = undeliveredOrdersJournalOpener ?? throw new ArgumentNullException(nameof(undeliveredOrdersJournalOpener));
            _employeeService             = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
            _counterpartySelectorFactory = counterpartySelectorFactory ?? throw new ArgumentNullException(nameof(counterpartySelectorFactory));
            _filePickerService           = filePickerService ?? throw new ArgumentNullException(nameof(filePickerService));
            _subdivisionRepository       = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            _routeListItemRepository     = routeListItemRepository ?? throw new ArgumentNullException(nameof(routeListItemRepository));
            _subdivisionService          = subdivisionService ?? throw new ArgumentNullException(nameof(subdivisionService));
            _reportViewOpener            = reportViewOpener ?? throw new ArgumentNullException(nameof(reportViewOpener));
            _gtkDlgOpener                = gtkDialogsOpener ?? throw new ArgumentNullException(nameof(gtkDialogsOpener));
            _nomenclatureRepository      = nomenclatureRepository ?? throw new ArgumentNullException(nameof(nomenclatureRepository));
            _userRepository              = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
            _orderSelectorFactory        = orderSelectorFactory ?? throw new ArgumentNullException(nameof(orderSelectorFactory));
            _employeeJournalFactory      = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            _counterpartyJournalFactory  = counterpartyJournalFactory ?? throw new ArgumentNullException(nameof(counterpartyJournalFactory));
            _deliveryPointJournalFactory = deliveryPointJournalFactory ?? throw new ArgumentNullException(nameof(deliveryPointJournalFactory));
            _subdivisionJournalFactory   = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));
            _salesPlanJournalFactory     = salesPlanJournalFactory ?? throw new ArgumentNullException(nameof(salesPlanJournalFactory));
            _nomenclatureSelector        = nomenclatureSelector ?? throw new ArgumentNullException(nameof(nomenclatureSelector));
            _undeliveredOrdersRepository =
                undeliveredOrdersRepository ?? throw new ArgumentNullException(nameof(undeliveredOrdersRepository));

            TabName = "Журнал рекламаций";

            RegisterComplaints();

            var threadLoader = DataLoader as ThreadDataLoader <ComplaintJournalNode>;

            threadLoader.MergeInOrderBy(x => x.Id, true);

            FinishJournalConfiguration();

            FilterViewModel.SubdivisionService = subdivisionService;
            FilterViewModel.EmployeeService    = employeeService;

            var currentUserSettings        = userRepository.GetUserSettings(UoW, commonServices.UserService.CurrentUserId);
            var defaultSubdivision         = currentUserSettings.DefaultSubdivision;
            var currentEmployeeSubdivision = employeeService.GetEmployeeForUser(UoW, commonServices.UserService.CurrentUserId).Subdivision;

            FilterViewModel.CurrentUserSubdivision = currentEmployeeSubdivision;

            if (FilterViewModel.SubdivisionService.GetOkkId() == currentEmployeeSubdivision.Id)
            {
                FilterViewModel.ComplaintStatus = ComplaintStatuses.Checking;
            }
            else
            {
                if (currentUserSettings.UseEmployeeSubdivision)
                {
                    FilterViewModel.Subdivision = currentEmployeeSubdivision;
                }
                else
                {
                    FilterViewModel.Subdivision = defaultSubdivision;
                }

                FilterViewModel.ComplaintStatus = currentUserSettings.DefaultComplaintStatus;
            }

            UpdateOnChanges(
                typeof(Complaint),
                typeof(ComplaintGuiltyItem),
                typeof(ComplaintResult),
                typeof(Subdivision),
                typeof(ComplaintDiscussion),
                typeof(DeliveryPoint),
                typeof(Fine),
                typeof(Order),
                typeof(RouteList),
                typeof(RouteListItem),
                typeof(ComplaintObject)
                );
            this.DataLoader.ItemsListUpdated += (sender, e) => CurrentObjectChanged?.Invoke(this, new CurrentObjectChangedArgs(null));

            DataLoader.PostLoadProcessingFunc = BeforeItemsUpdated;
        }
示例#10
0
        public ComplaintViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory uowFactory,
            ICommonServices commonServices,
            IUndeliveredOrdersJournalOpener undeliveryViewOpener,
            IEmployeeService employeeService,
            IEntityAutocompleteSelectorFactory counterpartySelectorFactory,
            IFilePickerService filePickerService,
            ISubdivisionRepository subdivisionRepository,
            INomenclatureRepository nomenclatureRepository,
            IUserRepository userRepository,
            IOrderSelectorFactory orderSelectorFactory,
            IEmployeeJournalFactory driverJournalFactory,
            ICounterpartyJournalFactory counterpartyJournalFactory,
            IDeliveryPointJournalFactory deliveryPointJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory,
            IGtkTabsOpener gtkDialogsOpener,
            IUndeliveredOrdersJournalOpener undeliveredOrdersJournalOpener,
            ISalesPlanJournalFactory salesPlanJournalFactory,
            INomenclatureSelectorFactory nomenclatureSelector,
            IUndeliveredOrdersRepository undeliveredOrdersRepository) : base(uowBuilder, uowFactory, commonServices)
        {
            _filePickerService          = filePickerService ?? throw new ArgumentNullException(nameof(filePickerService));
            _subdivisionRepository      = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            CounterpartySelectorFactory = counterpartySelectorFactory ?? throw new ArgumentNullException(nameof(counterpartySelectorFactory));
            _undeliveryViewOpener       = undeliveryViewOpener ?? throw new ArgumentNullException(nameof(undeliveryViewOpener));
            EmployeeService             = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
            NomenclatureRepository      = nomenclatureRepository ?? throw new ArgumentNullException(nameof(nomenclatureRepository));
            UserRepository              = userRepository ?? throw new ArgumentNullException(nameof(userRepository));
            _salesPlanJournalFactory    = salesPlanJournalFactory ?? throw new ArgumentNullException(nameof(salesPlanJournalFactory));
            NomenclatureSelector        = nomenclatureSelector ?? throw new ArgumentNullException(nameof(nomenclatureSelector));
            UndeliveredOrdersRepository =
                undeliveredOrdersRepository ?? throw new ArgumentNullException(nameof(undeliveredOrdersRepository));

            OrderSelectorFactory           = orderSelectorFactory ?? throw new ArgumentNullException(nameof(orderSelectorFactory));
            EmployeeJournalFactory         = driverJournalFactory ?? throw new ArgumentNullException(nameof(driverJournalFactory));
            _employeeSelectorFactory       = EmployeeJournalFactory.CreateEmployeeAutocompleteSelectorFactory();
            CounterpartyJournalFactory     = counterpartyJournalFactory ?? throw new ArgumentNullException(nameof(counterpartyJournalFactory));
            DeliveryPointJournalFactory    = deliveryPointJournalFactory ?? throw new ArgumentNullException(nameof(deliveryPointJournalFactory));
            SubdivisionJournalFactory      = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));
            GtkDialogsOpener               = gtkDialogsOpener ?? throw new ArgumentNullException(nameof(gtkDialogsOpener));
            UndeliveredOrdersJournalOpener = undeliveredOrdersJournalOpener ?? throw new ArgumentNullException(nameof(undeliveredOrdersJournalOpener));

            Entity.ObservableComplaintDiscussions.ElementChanged     += ObservableComplaintDiscussions_ElementChanged;
            Entity.ObservableComplaintDiscussions.ListContentChanged += ObservableComplaintDiscussions_ListContentChanged;
            Entity.ObservableFines.ListContentChanged += ObservableFines_ListContentChanged;

            if (uowBuilder.IsNewEntity)
            {
                AbortOpening("Невозможно создать новую рекламацию из текущего диалога, необходимо использовать диалоги создания");
            }

            if (CurrentEmployee == null)
            {
                AbortOpening("Невозможно открыть рекламацию так как к вашему пользователю не привязан сотрудник");
            }

            ConfigureEntityChangingRelations();

            CreateCommands();

            _complaintKinds = complaintKindSource = UoW.GetAll <ComplaintKind>().Where(k => !k.IsArchive).ToList();

            ComplaintObject = Entity.ComplaintKind?.ComplaintObject;

            TabName = $"Рекламация №{Entity.Id} от {Entity.CreationDate.ToShortDateString()}";
        }
示例#11
0
        public CashRequestViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            IFileChooserProvider fileChooserProvider,
            IEmployeeRepository employeeRepository,
            ICashRepository cashRepository,
            IEmployeeJournalFactory employeeJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory
            ) : base(uowBuilder, unitOfWorkFactory, commonServices)
        {
            this.uowBuilder           = uowBuilder ?? throw new ArgumentNullException(nameof(uowBuilder));
            _cashRepository           = cashRepository ?? throw new ArgumentNullException(nameof(cashRepository));
            EmployeeJournalFactory    = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            SubdivisionJournalFactory = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));
            var filterViewModel = new ExpenseCategoryJournalFilterViewModel {
                ExcludedIds    = new CategoryRepository(new ParametersProvider()).ExpenseSelfDeliveryCategories(UoW).Select(x => x.Id),
                HidenByDefault = true
            };

            ExpenseCategoryAutocompleteSelectorFactory =
                new SimpleEntitySelectorFactory <ExpenseCategory, ExpenseCategoryViewModel>(
                    () =>
            {
                var expenseCategoryJournalViewModel =
                    new SimpleEntityJournalViewModel <ExpenseCategory, ExpenseCategoryViewModel>(
                        x => x.Name,
                        () => new ExpenseCategoryViewModel(
                            EntityUoWBuilder.ForCreate(),
                            unitOfWorkFactory,
                            ServicesConfig.CommonServices,
                            fileChooserProvider,
                            filterViewModel,
                            EmployeeJournalFactory,
                            SubdivisionJournalFactory
                            ),
                        node => new ExpenseCategoryViewModel(
                            EntityUoWBuilder.ForOpen(node.Id),
                            unitOfWorkFactory,
                            ServicesConfig.CommonServices,
                            fileChooserProvider,
                            filterViewModel,
                            EmployeeJournalFactory,
                            SubdivisionJournalFactory
                            ),
                        unitOfWorkFactory,
                        ServicesConfig.CommonServices
                        )
                {
                    SelectionMode = JournalSelectionMode.Single
                };
                expenseCategoryJournalViewModel.SetFilter(filterViewModel,
                                                          filter => Restrictions.Not(Restrictions.In("Id", filter.ExcludedIds.ToArray())));

                return(expenseCategoryJournalViewModel);
            });

            var expenseCategorySelectorFactory =
                CurrentEmployee = employeeRepository.GetEmployeeForCurrentUser(UoW);

            if (uowBuilder.IsNewEntity)
            {
                TabName = "Создание новой заявки на выдачу ДС";
            }
            else
            {
                TabName = $"{Entity.Title}";
            }

            int userId = ServicesConfig.CommonServices.UserService.CurrentUserId;

            UserRoles = getUserRoles(userId);
            IsRoleChooserSensitive = UserRoles.Count() > 1;
            UserRole = UserRoles.First();

            IsNewEntity = uowBuilder.IsNewEntity;
            ConfigureEntityChangingRelations();
        }