Beispiel #1
0
        public ActionResult New(CivilizationForm form)
        {
            Debug.WriteLine(string.Format("POST: Civilization Controller: New Civilization - gameID={0}", GameState.GameID));
            var game = GameState.Game;

            DB_civilization civilization = new DB_civilization();

            civilization.game_id = game.Info.id;

            var selectedTraits = form.CivilizationTraits.Where(x => x.IsChecked).ToList();

            if (selectedTraits.Count > 0)
            {
                civilization.civilization_traits_1_id = selectedTraits[0].ID;
            }
            if (selectedTraits.Count > 1)
            {
                civilization.civilization_traits_2_id = selectedTraits[1].ID;
            }
            if (selectedTraits.Count > 2)
            {
                civilization.civilization_traits_3_id = selectedTraits[2].ID;
            }

            civilization.tech_level_id = (form.SelectedTechLevel == -1) ? null : form.SelectedTechLevel;

            civilization.name    = form.Name;
            civilization.colour  = form.Colour;
            civilization.rp      = form.RP;
            civilization.gmnotes = form.GMNotes;
            Database.Session.Save(civilization);

            foreach (var player in form.Players)
            {
                if (player.IsChecked)
                {
                    DB_user_civilizations userCivilization =
                        new DB_user_civilizations(
                            player.ID,
                            civilization.id,
                            game.ID,
                            game.GetPlayer(player.ID).GameUserInfo.id);
                    Database.Session.Save(userCivilization);
                }
            }

            foreach (var civilizationMet in form.MetCivilizations)
            {
                if (civilizationMet.IsChecked)
                {
                    DB_civilization_met dbCivilizationMet = new DB_civilization_met(civilization.id, civilizationMet.ID, game.ID);
                    Database.Session.Save(dbCivilizationMet);
                }
            }

            Database.Session.Flush();
            return(RedirectToRoute("Civilizations"));
        }
 public CivilizationMet(DB_civilization_met dbCivilizationMet)
 {
     Info = dbCivilizationMet;
 }