public PartialViewResult GetUpcomingFights(int id, int?page = 1, string active = "")
        {
            var        referee        = refereeService.GetById((int)id);
            var        fights         = fightService.GetWithFilter(x => x.Category.Timelines.Any(s => s.LevelId == x.LevelId && s.RefereeId == id) && x.Fighters.Where(y => y.IsWinner).Count() == 0);
            HttpCookie pageSizeCookie = Request.Cookies["_pageSize"];
            int        pageSize       = Convert.ToInt16(pageSizeCookie.Value);

            string email = string.Empty;

            if (referee != null)
            {
                email = referee.RefereeEmail;
            }
            var tab = new TableViewModel <Fight>()
            {
                TableData           = fights.OrderBy(x => x.Category.Timelines.Where(s => s.LevelId == x.LevelId && s.RefereeId == id).FirstOrDefault().Id).ThenByDescending(k => k.FightInLevel).ToPagedList((int)page, pageSize),
                Active              = active,
                Controller          = "Referees",
                ChildController     = "Test",
                TournamentOrganizer = email
            };

            return(PartialView("_Competitions", tab));
        }
Exemplo n.º 2
0
        public ActionResult GetFighter(int id, string active, bool showWinnerItem)
        {
            Fighter  fighter  = fighterService.GetById(id);
            Timeline timeline = timelineService.GetWithFilter(x => x.CategoryId == fighter.Fight.CategoryId && x.LevelId == fighter.Fight.LevelId).SingleOrDefault();

            int refId;

            if (timeline == null)
            {
                refId = -1;
            }
            else
            {
                refId = timeline.RefereeId;
            }

            Tournament     tournament = fighter.Fight.Category.Tournament;
            List <Fighter> fighters   = new List <Fighter>();

            switch (active)
            {
            case "Competitions":
                int catId = fighter.Fight.CategoryId;

                if (fightService.GetWithFilter(x => x.CategoryId == catId && x.Fighters.Any(s => s.IsWinner)).Count() == 0 && (User.Identity.Name.Equals(tournament.Organizer)))
                {
                    fighters = fighterService.GetFightersToReplace(fighter).ToList();
                }
                showWinnerItem = false;
                break;

            case "UpcomingFights":
                //showWinnerItem = true;
                break;

            case "FinishedFights":
                showWinnerItem = false;
                break;
            }
            return(PartialView("_Fighter", new FighterViewModel {
                Fighter = fighter, FightersToReplace = fighters, ShowWinnerItem = showWinnerItem, RefereeId = refId
            }));
        }
Exemplo n.º 3
0
        private PageHeader GetPageHeader(Category category)
        {
            List <BreadCrumbItem> list    = new List <BreadCrumbItem>();
            List <Button>         buttons = new List <Button>();

            var descList = new List <string>();

            list.Add(new BreadCrumbItem()
            {
                Controller = "Home", Name = AppResource.StartPage, Action = "Index"
            });
            list.Add(new BreadCrumbItem()
            {
                Controller = "Tournaments", Name = AppResource.Tournaments, Action = "Index"
            });
            list.Add(new BreadCrumbItem()
            {
                Id = category.Tournament.Id, Name = category.Tournament.Name, Controller = "Tournaments", Action = "Details"
            });
            list.Add(new BreadCrumbItem()
            {
                Id         = category.Id,
                Name       = String.Format("{0} [{1}] [{2}]", category.Gender.GetDisplayName(), category.Age, category.Weight),
                Controller = "Categories",
                Action     = "Details",
                Routes     = category.Tournament.Categories.ToDictionary(x => x.Id, y => String.Format("{0} [{1}] [{2}]", y.Gender.GetDisplayName(), y.Age, y.Weight))
            });

            descList.Add(string.Format("<strong>{0}:</strong> <em>{1}</em>", AppResource.Description, category.OneThirdPlace ? AppResource.OneThirdPlace : AppResource.TwoThirdPlaces));

            var finalFight = fightService.GetWithFilter(x => x.CategoryId == category.Id && x.Level.Description.Equals("level_1") && x.Fighters.Any(s => s.IsWinner)).SingleOrDefault();

            if (finalFight != null)
            {
                var winner  = finalFight.Fighters.Where(x => x.IsWinner).Single();
                var winner2 = finalFight.Fighters.Where(x => !x.IsWinner).Single();
                descList.Add(GetWinnerListItem(1, winner));
                descList.Add(GetWinnerListItem(2, winner2));
            }

            if (category.OneThirdPlace)
            {
                var thirdPlaceFight = fightService.GetWithFilter(filter: x => x.CategoryId == category.Id && x.Level.Description.Equals("level_0") && x.Fighters.Any(s => s.IsWinner)).SingleOrDefault();
                if (thirdPlaceFight != null)
                {
                    var winner3 = thirdPlaceFight.Fighters.Where(x => x.IsWinner).Single();
                    descList.Add(GetWinnerListItem(3, winner3));
                }
            }
            else
            {
                var semiFinalFights = fightService.GetWithFilter(filter: x => x.CategoryId == category.Id && x.Level.Description.Equals("level_2") && x.Fighters.Any(s => s.IsWinner));
                foreach (Fight semiFinalFight in semiFinalFights)
                {
                    var winner3 = semiFinalFight.Fighters.Where(x => x.IsWinner).Single();

                    descList.Add(GetWinnerListItem(3, winner3));
                }
            }
            PageHeader pageHeader = new PageHeader()
            {
                BreadCrumbs = list,
                Title       = category.Gender.GetDisplayName(),
                Subtitle    = string.Format("[{0}] [{1}]", category.Age, category.Weight),
                Description = descList
            };

            return(pageHeader);
        }