Пример #1
0
        public ActionResult Details(Int32 id)
        {
            var model = new PublisherDetailViewModel();

            model.Publisher = this.DbContext.Publishers
                              .Where(pub => pub.Id == id)
                              .FirstOrDefault();
            model.LayoutModel = this.BaseModel;
            return(View(model));
        }
Пример #2
0
        public PublisherDetailViewModelTests()
        {
            eventAggregatorMock    = new Mock <IEventAggregator>();
            metroDialogServiceMock = new Mock <IMetroDialogService>();
            publishersRepoMock     = new Mock <IRepository <Publisher> >();

            viewModel = new PublisherDetailViewModel(eventAggregatorMock.Object,
                                                     metroDialogServiceMock.Object,
                                                     publishersRepoMock.Object);
        }
Пример #3
0
        public async Task <IActionResult> Details(Guid?Id)
        {
            if (Id == null)
            {
                throw new ArgumentNullException(nameof(Id));
            }

            var publisher = await publishersRepository.GetSelectedAsync((Guid)Id);

            var vm = new PublisherDetailViewModel(publisher);

            return(View(vm));
        }
Пример #4
0
        public PublisherDetailViewModelTests()
        {
            var eventAggregatorMock = new Mock <IEventAggregator>();
            var loggerMock          = new Mock <ILogger>();
            var repositoryMock      = new Mock <IRepository <Publisher> >();

            var publisherService = new PublisherService(repositoryMock.Object);
            var dialogService    = new DialogService();

            viewModel = new PublisherDetailViewModel(eventAggregatorMock.Object,
                                                     loggerMock.Object,
                                                     publisherService,
                                                     dialogService);
        }
        public IActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var publisher      = _dbContext.Publisher.First(p => p.Id == id);
            var publisherGames = _dbContext.Game.Where(g => g.PublisherId == id).ToList();

            foreach (var game in publisherGames)
            {
                game.Category  = _dbContext.Category.First(c => c.Id == game.CategoryId);
                game.Publisher = _dbContext.Publisher.First(p => p.Id == game.PublisherId);
            }

            PublisherDetailViewModel categoryViewModel = new PublisherDetailViewModel(publisher);

            categoryViewModel.GamesTableViewModel = new GamesTableViewModel(publisherGames, "List of games for selected publisher", false);

            return(View(categoryViewModel));
        }