Exemplo n.º 1
0
        public IActionResult Index()
        {
            var countries = _countriesService.GetAll()
                            .OrderBy(country => country.Name)
                            .Select(c => new CountriesListingModel
            {
                Id      = c.Id,
                Name    = c.Name,
                FlagUrl = c.FlagUrl
            });
            var model = new CountriesIndexModel
            {
                CountriesList = countries
            };

            return(View(model));
        }
Exemplo n.º 2
0
 public ActionResult Index(CountriesIndexModel countriesIndexModel)
 {
     using (tennisDBEntities db = new tennisDBEntities())
     {
         if (countriesIndexModel.CountryToDelete != null)
         {
             country country = db.countries.Find(countriesIndexModel.CountryToDelete);
             if (country != null && country.players.Count == 0)
             {
                 db.countries.Remove(country);
                 db.SaveChanges();
             }
         }
         countriesIndexModel.Countries = db.countries
                                         .Select(country => country)
                                         .Include("players")
                                         .OrderBy(c => c.name).ToList();
     }
     return(View(countriesIndexModel));
 }
Exemplo n.º 3
0
 public ActionResult Index(CountriesIndexModel countriesIndexModel)
 {
     using (tennisContext db = new tennisContext())
     {
         if (countriesIndexModel.CountryToDelete != null)
         {
             Country country = db.Country.Find(countriesIndexModel.CountryToDelete);
             if (country != null && country.Player.Count == 0)
             {
                 db.Country.Remove(country);
                 db.SaveChanges();
             }
         }
         countriesIndexModel.Countries = db.Country
                                         .Select(country => country)
                                         .Include("Player")
                                         .OrderBy(c => c.Name).ToList();
     }
     return(View(countriesIndexModel));
 }