public ActionResult New(RnDResearchForm form) { Debug.WriteLine($"POST: Civilization RnD Research Controller: New"); DB_users user = Auth.User; var game = GameState.Game; var dbResearch = game.GameStatistics.Research .Where(x => x.id == form.SelectedResearchID.Value) .FirstOrDefault(); var dbBuildAtStruct = game.GetCivilization(form.CivilizationID.Value).Assets.CompletedInfrastructure .Where(x => x.CivilizationInfo.id == form.SelectedBuildAtInfrastructureID) .FirstOrDefault(); if (dbResearch == null || dbBuildAtStruct == null) { return(RedirectToRoute("ViewCivilization", new { civilizationID = form.CivilizationID.Value })); } DB_civilization_rnd_research research = new DB_civilization_rnd_research(); research.game_id = game.ID; research.civilization_id = form.CivilizationID.Value; research.research_id = dbResearch.id; research.civ_struct_id = dbBuildAtStruct.CivilizationInfo.id; research.build_percentage = form.BuildPercentage; Database.Session.Save(research); Database.Session.Flush(); return(RedirectToRoute("ViewCivilization", new { civilizationID = form.CivilizationID.Value })); }
public ActionResult Edit(RnDResearchForm form) { Debug.WriteLine($"POST: Civilization RND Research Controller: Edit"); DB_users user = Auth.User; var game = GameState.Game; DB_civilization_rnd_research research = FindRNDCivilizationResearch(form.ID).Info; if (research.game_id != game.ID) { return(RedirectToRoute("game", new { gameID = game.Info.id })); } var dbResearch = game.GameStatistics.Research .Where(x => x.id == form.SelectedResearchID.Value) .FirstOrDefault(); var dbBuildAtStruct = game.GetCivilization(form.CivilizationID.Value).Assets.CompletedInfrastructure .Where(x => x.CivilizationInfo.id == form.SelectedBuildAtInfrastructureID) .FirstOrDefault(); if (dbResearch == null || dbBuildAtStruct == null) { return(RedirectToRoute("ViewCivilization", new { civilizationID = form.CivilizationID.Value })); } if (RequireGMAdminAttribute.IsGMOrAdmin()) { research.civilization_id = form.CivilizationID.Value; research.research_id = dbResearch.id; research.civ_struct_id = dbBuildAtStruct.CivilizationInfo.id; } Database.Session.Update(research); Database.Session.Flush(); return(RedirectToRoute("ViewCivilization", new { civilizationID = form.CivilizationID.Value })); }
public RnDResearch(DB_civilization_rnd_research info, Civilization owner) { Info = info; Owner = owner; }