public SubdivisionViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, ITdiCompatibilityNavigation navigation, IValidator validator, ILifetimeScope autofacScope, FeaturesService featuresService ) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { this.navigation = navigation ?? throw new ArgumentNullException(nameof(navigation)); this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService)); var builder = new CommonEEVMBuilderFactory <Subdivision>(this, Entity, UoW, NavigationManager, autofacScope); EntryWarehouse = builder.ForProperty(x => x.Warehouse) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); EntrySubdivisionViewModel = builder.ForProperty(x => x.ParentSubdivision) .UseViewModelJournalAndAutocompleter <SubdivisionJournalViewModel>() .UseViewModelDialog <SubdivisionViewModel>() .Finish(); NotifyConfiguration.Instance.BatchSubscribe(SubdivisionOperationChanged) .IfEntity <SubdivisionIssueOperation>() .AndWhere(x => x.Subdivision.Id == Entity.Id); }
public NormFilterViewModel(JournalViewModelBase journal, INavigationManager navigation, ILifetimeScope autofacScope, IUnitOfWorkFactory unitOfWorkFactory = null) : base(journal, unitOfWorkFactory) { var builder = new CommonEEVMBuilderFactory <NormFilterViewModel>(journal, this, UoW, navigation, autofacScope); EntryPost = builder.ForProperty(x => x.Post).MakeByType().Finish(); EntryProtectionTools = builder.ForProperty(x => x.ProtectionTools).MakeByType().Finish(); }
public NomenclatureViewModel( BaseParameters baseParameters, IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, ILifetimeScope autofacScope, IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { var entryBuilder = new CommonEEVMBuilderFactory <Nomenclature>(this, Entity, UoW, navigation, autofacScope); ItemTypeEntryViewModel = entryBuilder.ForProperty(x => x.Type) .MakeByType() .Finish(); Validations.Clear(); Validations.Add( new ValidationRequest(Entity, new ValidationContext(Entity, new Dictionary <object, object> { { nameof(BaseParameters), baseParameters }, { nameof(IUnitOfWork), UoW } }))); Entity.PropertyChanged += Entity_PropertyChanged; }
public UserSettingsViewModel (IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, ILifetimeScope autofacScope, FeaturesService featuresService, IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { this.AutofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService)); var entryBuilder = new CommonEEVMBuilderFactory <UserSettings>(this, Entity, UoW, navigation, autofacScope); WarehouseFromEntryViewModel = entryBuilder.ForProperty(x => x.DefaultWarehouse) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); LeaderFromEntryViewModel = entryBuilder.ForProperty(x => x.DefaultLeader) .UseViewModelJournalAndAutocompleter <LeadersJournalViewModel>() .UseViewModelDialog <LeadersViewModel>() .Finish(); ResponsiblePersonFromEntryViewModel = entryBuilder.ForProperty(x => x.DefaultResponsiblePerson) .UseViewModelJournalAndAutocompleter <LeadersJournalViewModel>() .UseViewModelDialog <LeadersViewModel>() .Finish(); OrganizationFromEntryViewModel = entryBuilder.ForProperty(x => x.DefaultOrganization) .UseViewModelJournalAndAutocompleter <OrganizationJournalViewModel>() .UseViewModelDialog <OrganizationViewModel>() .Finish(); }
public LeadersViewModel(IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, ILifetimeScope autofacScope, IValidator validator) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); var builder = new CommonEEVMBuilderFactory <Leader>(this, Entity, UoW, NavigationManager, autofacScope); EntryEmployee = builder.ForProperty(x => x.Employee).MakeByType().Finish(); }
public DepartmentViewModel(IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, ILifetimeScope autofacScope, IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); var builder = new CommonEEVMBuilderFactory <Department>(this, Entity, UoW, NavigationManager, autofacScope); EntrySubdivision = builder.ForProperty(x => x.Subdivision) .UseViewModelJournalAndAutocompleter <SubdivisionJournalViewModel>() .UseViewModelDialog <SubdivisionViewModel>() .Finish(); }
public RequestSheetViewModel(RdlViewerViewModel rdlViewerViewModel, IUnitOfWorkFactory uowFactory, INavigationManager navigation, ILifetimeScope AutofacScope) : base(rdlViewerViewModel) { Title = "Заявка на спецодежду"; Identifier = "RequestSheet"; uow = uowFactory.CreateWithoutRoot(); var builder = new CommonEEVMBuilderFactory(rdlViewerViewModel, uow, navigation, AutofacScope); EntrySubdivisionViewModel = builder.ForEntity <Subdivision>().MakeByType().Finish(); }
public IssueByIdentifierViewModel( IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, IGuiDispatcher guiDispatcher, IUserService userService, ILifetimeScope autofacScope, StockRepository stockRepository, EmployeeRepository employeeRepository, FeaturesService featuresService, IValidator validator, BaseParameters baseParameters, IInteractiveQuestion interactive, IChangeableConfiguration configuration, SizeService sizeService, ICardReaderService cardReaderService = null) : base(navigation) { this.unitOfWorkFactory = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory)); this.guiDispatcher = guiDispatcher ?? throw new ArgumentNullException(nameof(guiDispatcher)); this.userService = userService ?? throw new ArgumentNullException(nameof(userService)); this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); this.employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository)); this.validator = validator ?? throw new ArgumentNullException(nameof(validator)); this.BaseParameters = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters)); this.interactive = interactive ?? throw new ArgumentNullException(nameof(interactive)); this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); SizeService = sizeService ?? throw new ArgumentNullException(nameof(sizeService)); this.cardReaderService = cardReaderService; IsModal = false; EnableMinimizeMaximize = true; Title = "Выдача по картам СКУД"; UowOfDialog = unitOfWorkFactory.CreateWithoutRoot(); var entryBuilder = new CommonEEVMBuilderFactory <IssueByIdentifierViewModel>(this, this, UowOfDialog, navigation, autofacScope); if (cardReaderService != null) { cardReaderService.RefreshDevices(); cardReaderService.СardStatusRead += RusGuardService_СardStatusRead; cardReaderService.CardFamilies.ListChanged += CardFamilies_ListChanged; } UpdateState(); WarehouseEntryViewModel = entryBuilder.ForProperty(x => x.Warehouse).MakeByType().Finish(); Warehouse = stockRepository.GetDefaultWarehouse(UowOfDialog, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId); //Настройка таймера сброса timerCleanSuccessfullyText = new Timer(40000); timerCleanSuccessfullyText.AutoReset = false; timerCleanSuccessfullyText.Elapsed += delegate(object sender, ElapsedEventArgs e) { guiDispatcher.RunInGuiTread(() => SuccessfullyText = null); }; ReadConfig(); }
public NomenclatureFilterViewModel( JournalViewModelBase journalViewModel, INavigationManager navigation, ILifetimeScope autofacScope, IUnitOfWorkFactory unitOfWorkFactory = null ) : base(journalViewModel, unitOfWorkFactory) { var builder = new CommonEEVMBuilderFactory <NomenclatureFilterViewModel>(journalViewModel, this, UoW, navigation, autofacScope); EntryItemsType = builder.ForProperty(x => x.ItemType).MakeByType().Finish(); }
public AverageAnnualNeedViewModel(RdlViewerViewModel rdlViewerViewModel, IUnitOfWorkFactory uowFactory, INavigationManager navigation, ILifetimeScope autofacScope) : base(rdlViewerViewModel) { Title = "Среднегодовая потребность"; Identifier = "AverageAnnualNeed"; UoW = uowFactory.CreateWithoutRoot(); var builder = new CommonEEVMBuilderFactory(rdlViewerViewModel, UoW, navigation, autofacScope); SubdivisionEntry = builder.ForEntity <Subdivision>().MakeByType().Finish(); }
public CompletionViewModel(IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, IUserService userService, StockRepository stockRepository, FeaturesService featuresService, ILifetimeScope autofacScope, BaseParameters baseParameters, IInteractiveQuestion interactive, SizeService sizeService, IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { var entryBuilder = new CommonEEVMBuilderFactory <Completion>(this, Entity, UoW, navigation, autofacScope); this.interactive = interactive; this.featuresService = featuresService; SizeService = sizeService; if (UoW.IsNew) { Entity.CreatedbyUser = userService.GetCurrentUser(UoW); } if (Entity.SourceWarehouse == null) { Entity.SourceWarehouse = stockRepository.GetDefaultWarehouse (UoW, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId); } WarehouseExpenseEntryViewModel = entryBuilder.ForProperty(x => x.SourceWarehouse) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); if (Entity.ResultWarehouse == null) { Entity.ResultWarehouse = stockRepository.GetDefaultWarehouse (UoW, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId); } WarehouseReceiptEntryViewModel = entryBuilder.ForProperty(x => x.ResultWarehouse) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); Validations.Clear(); Validations.Add(new ValidationRequest(Entity, new ValidationContext(Entity, new Dictionary <object, object> { { nameof(BaseParameters), baseParameters }, { nameof(IUnitOfWork), UoW } }))); Entity.PropertyChanged += Entity_PropertyChanged; lastWarehouse = Entity.SourceWarehouse; }
public ProtectionToolsViewModel(IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, IInteractiveService interactiveService, INavigationManager navigation, ILifetimeScope autofacScope, IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { this.interactiveService = interactiveService ?? throw new ArgumentNullException(nameof(interactiveService)); this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); var entryBuilder = new CommonEEVMBuilderFactory <ProtectionTools>(this, Entity, UoW, navigation, autofacScope); ItemTypeEntryViewModel = entryBuilder.ForProperty(x => x.Type) .MakeByType() .Finish(); Entity.ObservableNomenclatures.ListContentChanged += (sender, args) => OnPropertyChanged(nameof(SensetiveCreateNomenclature)); }
public NotIssuedSheetViewModel(RdlViewerViewModel rdlViewerViewModel, IUnitOfWorkFactory uowFactory, INavigationManager navigation, ILifetimeScope autofacScope) : base(rdlViewerViewModel) { Title = "Справка по невыданному (Детально)"; Identifier = "NotIssuedSheet"; UoW = uowFactory.CreateWithoutRoot(); var builder = new CommonEEVMBuilderFactory(rdlViewerViewModel, UoW, navigation, autofacScope); SubdivisionEntry = builder.ForEntity <Subdivision>().MakeByType().Finish(); excludeInVacation = true; }
public SubdivisionBalanceFilterViewModel( JournalViewModelBase journalViewModel, INavigationManager navigation, ILifetimeScope autofacScope, IUnitOfWorkFactory unitOfWorkFactory = null) : base(journalViewModel, unitOfWorkFactory) { var builder = new CommonEEVMBuilderFactory <SubdivisionBalanceFilterViewModel>( journalViewModel, this, UoW, navigation, autofacScope); SubdivisionEntry = builder.ForProperty(x => x.Subdivision) .MakeByType() .Finish(); Date = DateTime.Today; }
public IssuanceSheetViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigationManager, IValidator validator, ILifetimeScope autofacScope, SizeService sizeService, CommonMessages commonMessages) : base(uowBuilder, unitOfWorkFactory, navigationManager, validator) { this.AutofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); SizeService = sizeService ?? throw new ArgumentNullException(nameof(sizeService)); this.commonMessages = commonMessages; var entryBuilder = new CommonEEVMBuilderFactory <IssuanceSheet>(this, Entity, UoW, navigationManager) { AutofacScope = AutofacScope }; OrganizationEntryViewModel = entryBuilder.ForProperty(x => x.Organization) .UseViewModelJournalAndAutocompleter <OrganizationJournalViewModel>() .UseViewModelDialog <OrganizationViewModel>() .Finish(); SubdivisionEntryViewModel = entryBuilder.ForProperty(x => x.Subdivision) .UseViewModelJournalAndAutocompleter <SubdivisionJournalViewModel>() .UseViewModelDialog <SubdivisionViewModel>() .Finish(); ResponsiblePersonEntryViewModel = entryBuilder.ForProperty(x => x.ResponsiblePerson) .UseViewModelJournalAndAutocompleter <LeadersJournalViewModel>() .UseViewModelDialog <LeadersViewModel>() .Finish(); HeadOfDivisionPersonEntryViewModel = entryBuilder.ForProperty(x => x.HeadOfDivisionPerson) .UseViewModelJournalAndAutocompleter <LeadersJournalViewModel>() .UseViewModelDialog <LeadersViewModel>() .Finish(); Entity.PropertyChanged += Entity_PropertyChanged; NotifyConfiguration.Instance.BatchSubscribeOnEntity <ExpenseItem>(Expense_Changed); NotifyConfiguration.Instance.BatchSubscribeOnEntity <CollectiveExpenseItem>(CollectiveExpense_Changed); if (Entity.Id == 0) { GetDefualtSetting(); } Entity.ObservableItems.ListContentChanged += (sender, args) => OnPropertyChanged(nameof(Sum)); }
public ReplaceEntityViewModel(IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, ILifetimeScope autofacScope, ReplaceEntity replaceEntity, IGuiDispatcher guiDispatcher, IValidator validator = null) : base(unitOfWorkFactory, navigation, validator) { Title = "Замена ссылок на объекты"; this.replaceEntity = replaceEntity ?? throw new ArgumentNullException(nameof(replaceEntity)); this.guiDispatcher = guiDispatcher ?? throw new ArgumentNullException(nameof(guiDispatcher)); var entryBuilder = new CommonEEVMBuilderFactory(this, UoW, navigation) { AutofacScope = autofacScope }; SourceEntryViewModel = entryBuilder.ForEntity <ProtectionTools>().MakeByType().Finish(); TargetEntryViewModel = entryBuilder.ForEntity <ProtectionTools>().MakeByType().Finish(); SourceEntryViewModel.Changed += SourceEntryViewModel_Changed; TargetEntryViewModel.Changed += TargetEntryViewModel_Changed; }
public CollectiveExpenseViewModel(IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, ILifetimeScope autofacScope, IValidator validator, IUserService userService, UserRepository userRepository, IInteractiveQuestion interactive, StockRepository stockRepository, CommonMessages commonMessages, FeaturesService featuresService, BaseParameters baseParameters ) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); this.userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository)); this.interactive = interactive; this.commonMessages = commonMessages ?? throw new ArgumentNullException(nameof(commonMessages)); this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService)); this.baseParameters = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters)); var entryBuilder = new CommonEEVMBuilderFactory <CollectiveExpense>(this, Entity, UoW, navigation, autofacScope); if (UoW.IsNew) { Entity.CreatedbyUser = userService.GetCurrentUser(UoW); } if (Entity.Warehouse == null) { Entity.Warehouse = stockRepository.GetDefaultWarehouse(UoW, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId); } WarehouseEntryViewModel = entryBuilder.ForProperty(x => x.Warehouse).MakeByType().Finish(); var parameter = new TypedParameter(typeof(CollectiveExpenseViewModel), this); CollectiveExpenseItemsViewModel = this.autofacScope.Resolve <CollectiveExpenseItemsViewModel>(parameter); //Переопределяем параметры валидации Validations.Clear(); Validations.Add(new ValidationRequest(Entity, new ValidationContext(Entity, new Dictionary <object, object> { { nameof(BaseParameters), baseParameters } }))); }
public WarehouseTransferViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigationManager, ILifetimeScope autofacScope, IValidator validator, IUserService userService, BaseParameters baseParameters, IInteractiveQuestion interactive) : base(uowBuilder, unitOfWorkFactory, navigationManager, validator) { this.AutofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); this.interactive = interactive ?? throw new ArgumentNullException(nameof(interactive)); if (UoW.IsNew) { Entity.CreatedbyUser = userService.GetCurrentUser(UoW); } var entryBuilder = new CommonEEVMBuilderFactory <Transfer>(this, Entity, UoW, navigationManager) { AutofacScope = AutofacScope }; WarehouseFromEntryViewModel = entryBuilder.ForProperty(x => x.WarehouseFrom) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); WarehouseToEntryViewModel = entryBuilder.ForProperty(x => x.WarehouseTo) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); LoadActualAmountFromStock(); Entity.PropertyChanged += Entity_PropertyChanged; lastWarehouse = Entity.WarehouseFrom; //Переопределяем параметры валидации Validations.Clear(); Validations.Add(new ValidationRequest(Entity, new ValidationContext(Entity, new Dictionary <object, object> { { nameof(BaseParameters), baseParameters } }))); }
public ExpenseEmployeeViewModel(IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, ILifetimeScope autofacScope, IValidator validator, IUserService userService, UserRepository userRepository, IInteractiveQuestion interactive, StockRepository stockRepository, CommonMessages commonMessages, FeaturesService featuresService, BaseParameters baseParameters, EmployeeCard employee = null ) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); this.userRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository)); this.interactive = interactive; this.commonMessages = commonMessages ?? throw new ArgumentNullException(nameof(commonMessages)); this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService)); this.baseParameters = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters)); var entryBuilder = new CommonEEVMBuilderFactory <Expense>(this, Entity, UoW, navigation, autofacScope); if (UoW.IsNew) { Entity.CreatedbyUser = userService.GetCurrentUser(UoW); Entity.Operation = ExpenseOperations.Employee; } if (Entity.Operation != ExpenseOperations.Employee) { throw new InvalidOperationException("Диалог предназначен только для операций выдачи сотруднику."); } if (employee != null) { Entity.Employee = UoW.GetById <EmployeeCard>(employee.Id); Entity.Warehouse = Entity.Employee.Subdivision?.Warehouse; } if (Entity.Warehouse == null) { Entity.Warehouse = stockRepository.GetDefaultWarehouse(UoW, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId); } if (employee != null) { FillUnderreceived(); } if (Entity.WriteOffDoc != null) { FillAktNumber(); } WarehouseEntryViewModel = entryBuilder.ForProperty(x => x.Warehouse) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); EmployeeCardEntryViewModel = entryBuilder.ForProperty(x => x.Employee) .UseViewModelJournalAndAutocompleter <EmployeeJournalViewModel>() .UseViewModelDialog <EmployeeViewModel>() .Finish(); var parameter = new TypedParameter(typeof(ExpenseEmployeeViewModel), this); DocItemsEmployeeViewModel = this.autofacScope.Resolve <ExpenseDocItemsEmployeeViewModel>(parameter); Entity.PropertyChanged += EntityChange; //Переопределяем параметры валидации Validations.Clear(); Validations.Add(new ValidationRequest(Entity, new ValidationContext(Entity, new Dictionary <object, object> { { nameof(BaseParameters), baseParameters } }))); }
public EmployeeViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, IValidator validator, IUserService userService, ILifetimeScope autofacScope, PersonNames personNames, IInteractiveService interactive, FeaturesService featuresService, EmployeeRepository employeeRepository, NormRepository normRepository, LkUserManagerService lkUserManagerService, BaseParameters baseParameters, SizeService sizeService, CommonMessages messages) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { AutofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); this.personNames = personNames ?? throw new ArgumentNullException(nameof(personNames)); this.interactive = interactive ?? throw new ArgumentNullException(nameof(interactive)); this.featuresService = featuresService ?? throw new ArgumentNullException(nameof(featuresService)); this.employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository)); NormRepository = normRepository ?? throw new ArgumentNullException(nameof(normRepository)); this.lkUserManagerService = lkUserManagerService ?? throw new ArgumentNullException(nameof(lkUserManagerService)); this.baseParameters = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters)); this.messages = messages ?? throw new ArgumentNullException(nameof(messages)); var builder = new CommonEEVMBuilderFactory <EmployeeCard>(this, Entity, UoW, NavigationManager, AutofacScope); SizeService = sizeService; EntryLeaderViewModel = builder.ForProperty(x => x.Leader) .UseViewModelJournalAndAutocompleter <LeadersJournalViewModel>() .UseViewModelDialog <LeadersViewModel>() .Finish(); EntrySubdivisionViewModel = builder.ForProperty(x => x.Subdivision) .UseViewModelJournalAndAutocompleter <SubdivisionJournalViewModel>() .UseViewModelDialog <SubdivisionViewModel>() .Finish(); EntryDepartmentViewModel = builder.ForProperty(x => x.Department) .UseViewModelDialog <DepartmentViewModel>() .Finish(); EntryDepartmentViewModel.EntitySelector = new DepartmentJournalViewModelSelector( this, NavigationManager, EntrySubdivisionViewModel); EntryPostViewModel = builder.ForProperty(x => x.Post) .UseViewModelJournalAndAutocompleter <PostJournalViewModel>() .UseViewModelDialog <PostViewModel>() .Finish(); Entity.PropertyChanged += Entity_PropertyChanged; Entity.PropertyChanged += PostChangedCheck; if (UoW.IsNew) { Entity.CreatedbyUser = userService.GetCurrentUser(UoW); logger.Info("Создание карточки для нового сотрудника"); } else { AutoCardNumber = String.IsNullOrWhiteSpace(Entity.CardNumber); } lastSubdivision = Entity.Subdivision; lastPost = Entity.Post; //Создаем вкладки var parameter = new TypedParameter(typeof(EmployeeViewModel), this); NormsViewModel = AutofacScope.Resolve <EmployeeNormsViewModel>(parameter); WearItemsViewModel = AutofacScope.Resolve <EmployeeWearItemsViewModel>(parameter); ListedItemsViewModel = AutofacScope.Resolve <EmployeeListedItemsViewModel>(parameter); MovementsViewModel = AutofacScope.Resolve <EmployeeMovementsViewModel>(parameter); VacationsViewModel = AutofacScope.Resolve <EmployeeVacationsViewModel>(parameter); //Панели EmployeePhotoViewModel = AutofacScope.Resolve <EmployeePhotoViewModel>(parameter); VisiblePhoto = Entity.Photo != null; lkLastPhone = Entity.PhoneNumber; LkPassword = Entity.LkRegistered ? unknownPassword : String.Empty; Validations.Add(new ValidationRequest(this)); }
public ExpenseObjectViewModel(IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, ILifetimeScope autofacScope, IValidator validator, IUserService userService, IInteractiveQuestion interactive, StockRepository stockRepository, FeaturesService featutesService, BaseParameters baseParameters, Subdivision subdivision = null ) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { Entity.Date = DateTime.Today; this.interactive = interactive; this.stockRepository = stockRepository ?? throw new ArgumentNullException(nameof(stockRepository)); this.baseParameters = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters)); if (subdivision != null) { Entity.Subdivision = subdivision; Entity.Warehouse = subdivision.Warehouse; } if (UoW.IsNew) { Entity.Operation = ExpenseOperations.Object; Entity.CreatedbyUser = userService.GetCurrentUser(UoW); } if (Entity.Operation != ExpenseOperations.Object) { throw new InvalidOperationException("Диалог предназначен только для операций выдачи на подразделение."); } if (Entity.Warehouse == null) { Entity.Warehouse = stockRepository.GetDefaultWarehouse(UoW, featutesService, autofacScope.Resolve <IUserService>().CurrentUserId); } this.autofacScope = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope)); var entryBuilder = new CommonEEVMBuilderFactory <Expense>(this, Entity, UoW, navigation, autofacScope); WarehouseExpenceViewModel = entryBuilder.ForProperty(x => x.Warehouse) .UseViewModelJournalAndAutocompleter <WarehouseJournalViewModel>() .UseViewModelDialog <WarehouseViewModel>() .Finish(); SubdivisionViewModel = entryBuilder.ForProperty(x => x.Subdivision) .UseViewModelJournalAndAutocompleter <SubdivisionJournalViewModel>() .UseViewModelDialog <SubdivisionViewModel>() .Finish(); var parameter = new TypedParameter(typeof(ExpenseObjectViewModel), this); DocItemsObjectViewModel = this.autofacScope.Resolve <ExpenseDocItemsObjectViewModel>(parameter); //Переопределяем параметры валидации Validations.Clear(); Validations.Add(new ValidationRequest(Entity, new ValidationContext(Entity, new Dictionary <object, object> { { nameof(BaseParameters), baseParameters } }))); }