public ActionResult CreateMech()
        {
            int userId = WebSecurity.GetUserId(User.Identity.Name);
            Gamer gamer = gamerRepository.Gamers.FirstOrDefault(x => x.type == "human" && x.UserId == userId);
            Game game = Session["Game"] as Game;
            if (game == null) {
                game = new Game();
                game.selectedCountry = countryRepository.Countries.FirstOrDefault(x => x.ridgamer == gamer.rid && x.UserId == userId);
            }
            if (game.selectedCountry == null){
                game.selectedCountry = countryRepository.Countries.FirstOrDefault(x => x.ridgamer == gamer.rid && x.UserId == userId);
            }

            Country country = game.selectedCountry;
            Gamer owner = gamerRepository.Gamers.FirstOrDefault(x => x.rid == country.ridgamer && x.UserId == userId);

            Boolean our = false;
            if (gamer.rid == owner.rid) { our = true; }

            Factory factory = new Factory
            {
                designes = designRepository.Designs.Where(x => x.UserId == userId && x.ridgamer == gamer.rid).ToList(),
                qnt = 0,
                ours = our

            };
            return View(factory);
        }
 public ActionResult Report()
 {
     int userId = WebSecurity.GetUserId(User.Identity.Name);
     Journal journal = new Journal(eventRepository, userId);
     Game game = Session["Game"] as Game;
     if (game == null) {
         game = new Game();
         Gamer gamer = gamerRepository.Gamers.FirstOrDefault(x => x.type == "human" && x.UserId == userId);
         game.selectedCountry = countryRepository.Countries.FirstOrDefault(x => x.ridgamer == gamer.rid && x.UserId == userId);
     }
     Country country = game.selectedCountry;
     Entities entities = new Entities();
     List<Ev> events = entities.GetReportForCountry(userId, country.rid).ToList();
     return View(events);
 }
        public ActionResult CountryInfo()
        {
            logger.Info("CountryController: CountryInfo");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            int userId = WebSecurity.GetUserId(User.Identity.Name);
            Gamer gamer = gamerRepository.Gamers.FirstOrDefault(x => x.type == "human" && x.UserId == userId);

            Game game = Session["Game"] as Game;
            if (game == null) {
                game = new Game();
                game.selectedCountry = countryRepository.Countries.Where(x => x.ridgamer == gamer.rid && x.UserId == userId).FirstOrDefault();
            }
            Country country = game.selectedCountry;
            if (country == null)
            {
                country = countryRepository.Countries.Where(x => x.ridgamer == gamer.rid && x.UserId == userId).FirstOrDefault();
            }

            return View(country);
        }
        public ActionResult ChangeCountry(string[] cod)
        {
            logger.Info("Map: ChangeCountry");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            int userId = WebSecurity.GetUserId(User.Identity.Name);
            Game game = Session["Game"] as Game;
            if (game == null) {
                game = new Game();
                Gamer gamer = gamerRepository.Gamers.FirstOrDefault(x => x.type=="human" && x.UserId == userId);
                game.selectedCountry = countryRepository.Countries.FirstOrDefault(x => x.ridgamer == gamer.rid && x.UserId == userId);
            }

            Country country = countryRepository.Countries.FirstOrDefault(x => x.cod.Trim() == cod[0].Trim() && x.UserId == userId);
            if (country != null)
            {
                game.selectedCountry = country;
            }
            Session["Game"] = game;

            return RedirectToAction("Index", "Game");
        }