private void ConfigureSubdivision()
        {
            if (ViewModel.CanManageDriversAndForwarders && !ViewModel.CanManageOfficeWorkers)
            {
                var entityentrySubdivision = new EntityViewModelEntry();
                entityentrySubdivision.SetEntityAutocompleteSelectorFactory(
                    ViewModel.SubdivisionJournalFactory.CreateLogisticSubdivisionAutocompleteSelectorFactory(
                        ViewModel.EmployeeJournalFactory.CreateEmployeeAutocompleteSelectorFactory()));
                entityentrySubdivision.Binding
                .AddBinding(ViewModel.Entity, e => e.Subdivision, w => w.Subject)
                .AddBinding(ViewModel, vm => vm.CanEditEmployee, w => w.Sensitive)
                .InitializeFromSource();
                hboxSubdivision.Add(entityentrySubdivision);
                hboxSubdivision.ShowAll();
                return;
            }

            var entrySubdivision = new yEntryReference();

            entrySubdivision.SubjectType = typeof(Subdivision);
            entrySubdivision.Binding
            .AddBinding(ViewModel.Entity, e => e.Subdivision, w => w.Subject)
            .AddBinding(ViewModel, vm => vm.CanEditEmployee, w => w.Sensitive)
            .InitializeFromSource();
            hboxSubdivision.Add(entrySubdivision);
            hboxSubdivision.ShowAll();

            if (!ViewModel.CanManageOfficeWorkers && !ViewModel.CanManageDriversAndForwarders)
            {
                entrySubdivision.Sensitive = false;
            }
        }
Example #2
0
        private void ConfigureSubdivision()
        {
            if (canManageDriversAndForwarders && !canManageOfficeWorkers)
            {
                var entityentrySubdivision = new EntityViewModelEntry();
                entityentrySubdivision.SetEntityAutocompleteSelectorFactory(
                    new EntityAutocompleteSelectorFactory <SubdivisionsJournalViewModel>(typeof(Subdivision), () => {
                    var filter             = new SubdivisionFilterViewModel();
                    filter.SubdivisionType = SubdivisionType.Logistic;
                    IEntityAutocompleteSelectorFactory employeeSelectorFactory =
                        new DefaultEntityAutocompleteSelectorFactory
                        <Employee, EmployeesJournalViewModel, EmployeeFilterViewModel>(ServicesConfig.CommonServices);
                    return(new SubdivisionsJournalViewModel(
                               filter,
                               UnitOfWorkFactory.GetDefaultFactory,
                               ServicesConfig.CommonServices,
                               employeeSelectorFactory
                               ));
                })
                    );
                entityentrySubdivision.Binding.AddBinding(Entity, e => e.Subdivision, w => w.Subject).InitializeFromSource();
                hboxSubdivision.Add(entityentrySubdivision);
                hboxSubdivision.ShowAll();
                return;
            }

            var entrySubdivision = new yEntryReference();

            entrySubdivision.SubjectType = typeof(Subdivision);
            entrySubdivision.Binding.AddBinding(Entity, e => e.Subdivision, w => w.Subject).InitializeFromSource();
            hboxSubdivision.Add(entrySubdivision);
            hboxSubdivision.ShowAll();

            if (!canManageOfficeWorkers && !canManageDriversAndForwarders)
            {
                entrySubdivision.Sensitive = false;
            }
        }