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

            DB_civilization_traits civilizationTrait = new DB_civilization_traits();

            civilizationTrait.game_id                    = game.Info.id;
            civilizationTrait.name                       = form.Name;
            civilizationTrait.description                = form.Description;
            civilizationTrait.influence_bonus            = form.InfluenceBonus;
            civilizationTrait.trade_bonus                = form.TradeBonus;
            civilizationTrait.apply_military             = form.ApplyMilitary;
            civilizationTrait.apply_units                = form.ApplyUnits;
            civilizationTrait.apply_ships                = form.ApplyShips;
            civilizationTrait.apply_infrastructure       = form.ApplyInfrastructure;
            civilizationTrait.science_bonus              = form.ScienceBonus;
            civilizationTrait.colonial_development_bonus = form.ColonialDevelopmentBonus;
            civilizationTrait.ship_construction_bonus    = form.ShipConstructionBonus;
            civilizationTrait.unit_training_bonus        = form.UnitTrainingBonus;
            Database.Session.Save(civilizationTrait);

            Database.Session.Flush();
            return(RedirectToRoute("Statistics"));
        }
Exemplo n.º 2
0
        private DB_civilization_traits RetrieveCivilizationTrait(string name)
        {
            var game = GameState.Game;

            var civilizationTrait = Database.Session.Query <DB_civilization_traits>()
                                    .Where(x => x.game_id == null || x.game_id == game.ID)
                                    .Where(x => x.name == name)
                                    .FirstOrDefault();

            if (civilizationTrait == null)
            {
                civilizationTrait         = new DB_civilization_traits();
                civilizationTrait.game_id = game.ID;
                civilizationTrait.name    = name;
                Database.Session.Save(civilizationTrait);
            }

            return(civilizationTrait);
        }