Example #1
0
        public IActionResult Save(League model)
        {
            if (!ModelState.IsValid)
            {
                var leagueInput = new LeagueInputVM
                {
                    Name        = model.Name,
                    CountryId   = model.CountryId,
                    NameCountry = model.Name
                };
                return(View("Create", leagueInput));
            }

            IEnumerable <League> leagues = _dataLeague.GetByDetails();

            foreach (var item in leagues)
            {
                if (item.Name == model.Name)
                {
                    return(RedirectToAction("Error", "Home"));
                }
            }
            _dataLeague.Add(model);
            return(RedirectToAction(nameof(Index), new { id = model.CountryId }));
        }
Example #2
0
        public IActionResult Create(int id)
        {
            var country = _dataCountry.Get(id);

            LeagueInputVM league = new LeagueInputVM
            {
                CountryId   = country.Id,
                NameCountry = country.Name
            };

            return(View(league));
        }