Esempio n. 1
0
        public DirectoryViewModel DirectoryDBToViewModelById(int directoryId)
        {
            var _directory = _dataManeger.Derictorys.GetDirectoryById(directoryId, true);
            List <MaterialViewModel> _materialsViewModelList = new List <MaterialViewModel>();

            foreach (var item in _directory.Materials)
            {
                _materialsViewModelList.Add(_materialService.MaterialDBModelToView(item.Id));
            }
            return(new DirectoryViewModel()
            {
                Directory = _directory, Materials = _materialsViewModelList
            });
        }
Esempio n. 2
0
        public DirectoryViewModel DirectoryDBToViewModelById(int directoryId)
        {
            var directory = _logicManager.Directory.GetById(directoryId);
            List <MaterialViewModel> materialViewModels = null;

            try {
                materialViewModels = directory
                                     .Materials.Select(item => _materialService.MaterialDBModelToView(item.Id))
                                     .ToList();
            } catch (NullReferenceException) {}

            return(new DirectoryViewModel {
                Directory = directory,
                Materials = materialViewModels
            });
        }