コード例 #1
0
        public ViewResult Details(string Slug, int SeasonNumber)
        {
            var series = _context.Series.Include(fig => fig.FilmItemGenres).ThenInclude(g => g.Genre).FirstOrDefault(s => s.Slug == Slug);
            var season = _context.Seasons.Include(ep => ep.Episodes)
                         .Include(mr => mr.UserRatings)
                         .Include(r => r.Reviews)
                         .Include(m => m.Media)
                         .Include(v => v.Videos)
                         .Include(p => p.Photos)
                         .Include(l => l.ListItems).ThenInclude(l => l.List)
                         .Where(x => x.Season_SeasonNumber == SeasonNumber)
                         .Where(y => y.SeriesId == series.Id)
                         .FirstOrDefault();

            SeasonDetailsViewModel seasonDetailsViewModel = new SeasonDetailsViewModel
            {
                Season           = season,
                Genres           = series.FilmItemGenres.Select(g => g.Genre.Name).OrderBy(g => g).ToArray(),
                SeasonCount      = series.Series_SeasonCount,
                TotalRuntime     = FilmItemMethods.CalculateSeasonTotalRuntime(season),
                CommentCount     = season.Reviews.Count,
                ListCount        = season.ListItems.Select(l => l.List).ToList().Count,
                FirstEpisodeDate = GetDateTimeFirstEpisode(season)
            };

            return(View(seasonDetailsViewModel));
        }
コード例 #2
0
 private void InitDetailsViewModel(SeasonDetailsViewModel viewModel, SeasonDetails details)
 {
     InitBaseDetailViewModel(details.Detail, viewModel.Detail);
     InitBaseDetailEntityStateChange(viewModel.Detail);
     viewModel.Detail.SeasonTypeName   = GetSeasonTypeName(details.Detail.SeasonTypeId);
     ViewData[Mvc.ViewData.Controller] = Mvc.Controller.Season.Name;
 }
コード例 #3
0
        public ActionResult Edit(SeasonDetailsViewModel viewModel)
        {
            if (viewModel.Detail.Year < DateTime.Now.Year)
            {
                AddModelError(viewModel, m => m.Detail.Year, Dom.Translation.Common.YearLessCurrentYear);
            }
            if (ModelState.IsValid)
            {
                Season season = _seasonRepository.Get <Season>(viewModel.Detail.Id);
                season.Year         = viewModel.Detail.Year;
                season.SeasonTypeId = viewModel.Detail.SeasonTypeId;
                season.Statements.ToList().ForEach(x => _seasonRepository.Delete(x));
                if (viewModel.StatementIds != null)
                {
                    foreach (var pigeon in viewModel.StatementIds)
                    {
                        season.Statements.Add(
                            new Statement
                        {
                            PigeonId = pigeon,
                            SeasonId = season.Id
                        });
                    }
                }
                _seasonRepository.UnitOfWork.SaveChanges();
                return(RedirectToAction(Mvc.Controller.Season.Details, Mvc.Controller.Season.Name, new { id = viewModel.Detail.Id }));
            }

            SeasonDetails details = _seasonRepository.GetSeasonDetails(UserContext.User.Id, UserContext.User.OrganizationId, viewModel.Detail.Id);

            viewModel.Detail.SeasonTypeItems = InitSeasonTypeSelectListItems();
            foreach (var pigeon in details.Pigeons)
            {
                pigeon.Ring        = Format.FormattedRing(pigeon.Year, pigeon.Code, pigeon.Number);
                pigeon.InStatement = details.StatementPigeonIds.Contains(pigeon.Id);
            }
            viewModel.StatementIds   = details.StatementPigeonIds.ToList();
            viewModel.StatementItems = new Dictionary <string, ICollection <SelectListItem> >();
            foreach (var member in details.Members)
            {
                viewModel.StatementItems.Add(
                    Format.FormattedInitials(member.LastName, member.FirstName, member.MiddleName) + $" (#{member.Id})",
                    details.Pigeons
                    .Where(m => m.MemberId == member.Id)
                    .Select(g => new SelectListItem
                {
                    Value    = g.Id.ToString(),
                    Text     = g.Ring,
                    Selected = g.InStatement
                }).ToList()
                    );
            }

            return(View(Mvc.View.Season.Edit, viewModel));
        }
コード例 #4
0
        public ActionResult Details(int id)
        {
            SeasonDetails details = _seasonRepository.GetSeasonDetails(UserContext.User.Id, UserContext.User.OrganizationId, id);

            if (details.Detail == null)
            {
                return(NotFoundResult());
            }

            SeasonDetailsViewModel viewModel = Mapper.Map <SeasonDetailsViewModel>(details);

            InitDetailsViewModel(viewModel, details);

            return(View(Mvc.View.Season.Details, viewModel));
        }
コード例 #5
0
        public IActionResult Index(int id)
        {
            var teamPosition = teamPositionService.GetChampionshipSeasonPositions(id).ToList();

            if (teamPosition.Any())
            {
                var seasonDetais = new SeasonDetailsViewModel
                {
                    ChampionshipName = teamPosition[0].Season.Championship.Name,
                    SeasonName       = teamPosition[0].Season.Name,
                    Country          = teamPosition[0].Season.Championship.Country.Name,
                    Table            = teamPosition.Select(s => new TeamPositionViewModel
                    {
                        TeamName     = s.Club.Name,
                        Points       = s.Points,
                        Won          = s.Won,
                        Drawn        = s.Drawn,
                        Lost         = s.Lost,
                        GoalsFor     = s.GoalsFor,
                        GoalsAgainst = s.GoalsAgainst
                    }).ToList()
                };

                return(View(seasonDetais));
            }
            else
            {
                var season       = seasonService.Get(id);
                var seasonDetais = new SeasonDetailsViewModel()
                {
                    ChampionshipName = season.Championship.Name,
                    SeasonName       = season.Name
                };

                return(View(seasonDetais));
            }
        }
コード例 #6
0
        public ActionResult Edit(int id)
        {
            SeasonDetails details = _seasonRepository.GetSeasonDetails(UserContext.User.Id, UserContext.User.OrganizationId, id);

            if (details.Detail == null)
            {
                return(NotFoundResult());
            }

            SeasonDetailsViewModel viewModel = Mapper.Map <SeasonDetailsViewModel>(details);

            viewModel.Detail.SeasonTypeItems = InitSeasonTypeSelectListItems();
            foreach (var pigeon in details.Pigeons)
            {
                pigeon.Ring        = Format.FormattedRing(pigeon.Year, pigeon.Code, pigeon.Number);
                pigeon.InStatement = details.StatementPigeonIds.Contains(pigeon.Id);
            }
            viewModel.StatementIds   = details.StatementPigeonIds.ToList();
            viewModel.StatementItems = new Dictionary <string, ICollection <SelectListItem> >();
            foreach (var member in details.Members)
            {
                viewModel.StatementItems.Add(
                    Format.FormattedInitials(member.LastName, member.FirstName, member.MiddleName) + $" (#{member.Id})",
                    details.Pigeons
                    .Where(m => m.MemberId == member.Id)
                    .Select(g => new SelectListItem
                {
                    Value    = g.Id.ToString(),
                    Text     = g.Ring,
                    Selected = g.InStatement
                }).ToList()
                    );
            }

            return(View(Mvc.View.Season.Edit, viewModel));
        }