PackageViewModel CreatePackageViewModel(IPackage package)
        {
            var repository            = registeredPackageRepositories.ActiveRepository;
            var packageFromRepository = new PackageFromRepository(package, repository);

            return(packageViewModelFactory.CreatePackageViewModel(packageFromRepository));
        }
        /// <summary>
        ///     Mediator pattern is overkill in this instance, but here as an example to return response codes to a controller, and
        ///     keep the controller dumb as a result
        /// </summary>
        /// <returns>A mediator response with the result of the view model instantiation</returns>
        public MediatorResponse <PackagesViewModel> RequestPackageViewModel(string query)
        {
            var packageItemDataSource = _packageService.GetPackagesSearch(query);

            if (packageItemDataSource == null && !packageItemDataSource.Any())
            {
                return(_mediatorService.GetMediatorResponse <PackagesViewModel>(Constants.MediatorCodes.PackageSearchResponse.DataSourceError));
            }

            var viewModel =
                _packageViewModelFactory.CreatePackageViewModel(packageItemDataSource, _packageService.IsExperienceEditor);

            if (viewModel == null)
            {
                return(_mediatorService.GetMediatorResponse <PackagesViewModel>(Constants.MediatorCodes.PackageSearchResponse.ViewModelError));
            }

            return(_mediatorService.GetMediatorResponse(Constants.MediatorCodes.PackageSearchResponse.Ok, viewModel));
        }
Ejemplo n.º 3
0
        protected virtual PackageViewModel CreatePackageViewModel(IPackage package, PackageSearchCriteria search)
        {
            PackageFromRepository packageFromRepository = CreatePackageFromRepository(package);

            return(packageViewModelFactory.CreatePackageViewModel(this, packageFromRepository));
        }
Ejemplo n.º 4
0
        PackageViewModel CreatePackageViewModel(IPackage package)
        {
            PackageFromRepository packageFromRepository = CreatePackageFromRepository(package);

            return(packageViewModelFactory.CreatePackageViewModel(this, packageFromRepository));
        }
Ejemplo n.º 5
0
 PackageViewModel CreatePackageViewModel(IPackage package)
 {
     return(packageViewModelFactory.CreatePackageViewModel(package));
 }