public ActionResult Create()
        {
            var model = new CupLeagueViewModel();
            this.PopulateStaticData(model);

            return View(model);
        }
        public ActionResult Create()
        {
            var model = new CupLeagueViewModel();

            this.PopulateStaticData(model);

            return(View(model));
        }
        public ActionResult Create(CupLeagueViewModel model)
        {
            if (ModelState.IsValid)
            {
                var cupLeague = new CupLeague(cupService.Get(model.CupId), competitionService.GetLeague(model.LeagueId));

                cupLeagueService.Insert(cupLeague);
                cupLeagueService.Commit();
                SuccessMessage(FormMessages.SaveSuccess);
                return(RedirectToAction("Index"));
            }

            this.PopulateStaticData(model);

            return(View(model));
        }
        public ActionResult Create(CupLeagueViewModel model)
        {
            if (ModelState.IsValid)
            {
                var cupLeague = new CupLeague(cupService.Get(model.CupId), competitionService.GetLeague(model.LeagueId));

                cupLeagueService.Insert(cupLeague);
                cupLeagueService.Commit();
                SuccessMessage(FormMessages.SaveSuccess);
                return RedirectToAction("Index");
            }

            this.PopulateStaticData(model);

            return View(model);
        }
 private void PopulateStaticData(CupLeagueViewModel model)
 {
     model.Cups    = cupService.Get(orderBy: q => q.OrderBy(t => t.CupName)).ToSelectList(x => x.ToString(), x => x.Id.ToString(), model.CupId.ToString());
     model.Leagues = competitionService.GetLeaguesForCurrentSeason().ToSelectList(x => x.Season.ToString() + " " + x.ToString(), x => x.Id.ToString(), model.LeagueId.ToString());
 }
 private void PopulateStaticData(CupLeagueViewModel model)
 {
     model.Cups = cupService.Get(orderBy: q => q.OrderBy(t => t.CupName)).ToSelectList(x => x.ToString(), x => x.Id.ToString(), model.CupId.ToString());
     model.Leagues = competitionService.GetLeaguesForCurrentSeason().ToSelectList(x => x.Season.ToString() + " " + x.ToString(), x => x.Id.ToString(), model.LeagueId.ToString());
 }