public DocumentsView SetViewModel <TDocument>(DocumentsViewModel <TDocument> viewModel)
     where TDocument : Document
 {
     _viewModel  = viewModel;
     DataContext = viewModel;
     _viewModel.ForceSelectItems += ViewModelOnForceSelectItems;
     return(this);
 }
        public void OnDestroy()
        {
            if (this.collectionViewModel != null)
            {
                collectionViewModel.OnDestroy();

                collectionViewModel.OnEntitiesLoadedCallBack       = null;
                this.collectionViewModel.OnEntitiesLoadedCallBack  = null;
                this.collectionViewModel.OnEntitiesChangedCallBack = null;
                collectionViewModel = null;
            }
        }
        public void CreateCollectionViewModel()
        {
            Func <IRepositoryQuery <TEntity>, IQueryable <TProjection> > projection = null;

            if (constructProjectionCallBackFunc != null)
            {
                projection = constructProjectionCallBackFunc();
            }

            this.collectionViewModel = CollectionViewModel <TEntity, TProjection, TPrimaryKey, TUnitOfWork> .CreateCollectionViewModel(this.unitOfWorkFactory, this.getRepositoryFunc, projection);

            this.collectionViewModel.OnEntitiesLoadedCallBack  = OnEntitiesFirstLoaded;
            this.collectionViewModel.OnEntitiesChangedCallBack = collectionViewModelChangedCallBack;
            this.collectionViewModel.Entities.ToList();
        }
 /// <summary>
 /// Конструктор класса UpdateCommand.
 /// </summary>
 /// <param name="viewModel">Ссылка на модель-представление.</param>
 public UpdateCommand(IEntitiesViewModel viewModel)
 {
     vm = viewModel;
     vm.PropertyChanged += vm_PropertyChanged;
 }
        /// <summary>
        /// Generate internal number2 when all required fields are populated
        /// </summary>
        public static string WORKPACK_Generate_InternalNumber2(PROJECT fromPROJECT, WORKPACK fromWORKPACK, IEnumerable <WORKPACK> WORKPACKEntities, IEntitiesViewModel <AREA> lookUpAREA, IEntitiesViewModel <DISCIPLINE> lookUpDISCIPLINE, IEntitiesViewModel <PHASE> lookUpPHASE)
        {
            AREA       findAREA;
            DISCIPLINE findDISCIPLINE;
            PHASE      findPHASE;

            if (fromWORKPACK.AREA == null || fromWORKPACK.DISCIPLINE == null || fromWORKPACK.AREA == null)
            {
                findAREA       = lookUpAREA.Entities.FirstOrDefault(area => area.GUID == fromWORKPACK.GUID_DAREA);
                findPHASE      = lookUpPHASE.Entities.FirstOrDefault(phase => phase.GUID == fromWORKPACK.GUID_DPHASE);
                findDISCIPLINE = lookUpDISCIPLINE.Entities.FirstOrDefault(discipline => discipline.GUID == fromWORKPACK.GUID_DDISCIPLINE);
            }
            else
            {
                findAREA       = fromWORKPACK.AREA;
                findPHASE      = fromWORKPACK.PHASE;
                findDISCIPLINE = fromWORKPACK.DISCIPLINE;
            }

            if (findAREA != null && findDISCIPLINE != null && findPHASE != null)
            {
                string InternalName = fromPROJECT.NUMBER;
                InternalName += "-" + findPHASE.INTERNAL_NUM;
                InternalName += findAREA.INTERNAL_NUM;
                InternalName += findDISCIPLINE.CODE;

                int InternalNameCount = WORKPACKEntities.Count(obj => obj.INTERNAL_NAME2 != null && obj.INTERNAL_NAME2.Contains(InternalName)) + 1;

                InternalName += InternalNameCount.ToString();

                return(InternalName);
            }
            else
            {
                return(string.Empty);
            }
        }