public ActionResult SetScoreIntervals(ScoreSetting scoreSetting) { if (InputOrder(scoreSetting)) { try { using (var db = new CarpmaContext()) { var currentSetting = db.ScoreSettings.First(); currentSetting.Wood = scoreSetting.Wood; currentSetting.Copper = scoreSetting.Copper; currentSetting.Silver = scoreSetting.Silver; currentSetting.Gold = scoreSetting.Gold; db.SaveChanges(); ViewBag.ValidationStatus = "success"; return View("SetScoreIntervals"); } } catch (Exception) { ViewBag.ValidationStatus = "error"; return View("SetScoreIntervals"); } } else { ViewBag.ValidationStatus = "failure"; return View("SetScoreIntervals"); } }
private bool InputOrder(ScoreSetting scoreSetting) { if (scoreSetting.Wood < scoreSetting.Copper && scoreSetting.Wood < scoreSetting.Silver && scoreSetting.Wood < scoreSetting.Gold && scoreSetting.Copper < scoreSetting.Silver && scoreSetting.Copper < scoreSetting.Gold && scoreSetting.Silver < scoreSetting.Gold) { return true; } else { return false; } }