public async Task <int> AddAs(nation nation) { WcDbContext.nations.Add(nation); var n = await WcDbContext.SaveChangesAsync(); return(n); }
public IActionResult ProcessEvent(int Id, int popChange, int capChange, int stabChange, int resChange) { nation currentNation = _db.Nations.FirstOrDefault(i => i.Id == Id); currentNation.population += popChange; currentNation.capital += capChange; currentNation.resources += resChange; currentNation.stability += stabChange; _db.SaveChanges(); return(Json(currentNation)); }
public IActionResult Create(nation newNation) { newNation.population = 10000000; newNation.capital = 50; newNation.resources = 50; newNation.stability = 50; if (newNation.government == "Democracy") { newNation.stability -= 25; newNation.resources += 10; newNation.capital += 10; } else if (newNation.government == "Theology") { newNation.stability += 15; newNation.capital -= 10; } else if (newNation.government == "Junta") { newNation.stability += 30; newNation.resources -= 15; newNation.capital -= 15; } if (newNation.economy == "Banking") { newNation.resources -= 10; newNation.capital += 25; } else if (newNation.economy == "Exports") { newNation.resources += 25; } else if (newNation.economy == "Viking") { newNation.stability += 5; newNation.capital -= 10; } else if (newNation.economy == "Tourism") { newNation.capital += 15; newNation.resources -= 10; } else { newNation.capital -= 25; newNation.resources += 5; } if (newNation.geography == "deserts") { newNation.capital -= 5; newNation.resources += 10; } else if (newNation.geography == "caves") { newNation.capital -= 5; newNation.resources -= 5; } _db.Nations.Add(newNation); var eventList = _db.Events.ToList(); foreach (Event listEvent in eventList) { EventNation newEventNation = new EventNation { EventId = listEvent.Id, NationId = newNation.Id }; _db.NationEvents.Add(newEventNation); } _db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Details(int Id) { nation ntn = _db.Nations.FirstOrDefault(i => i.Id == Id); return(View(ntn)); }