public ActionResult CalculateStrategyForPlayer(int strategyType, string playerName) { if (strategyType.IsDefault()) { return(Json(Outcomes.Failure().WithMessage("You cannot go into battle without a proper strategy!"), JsonRequestBehavior.AllowGet)); } var db = new ZelusDbContext(); var player = db.Players.FirstOrDefault(p => string.Compare(p.SwgohGgName, playerName, StringComparison.OrdinalIgnoreCase) == 0); if (player.IsNull()) { return(Json(Outcomes.Failure().WithMessage("We cannot find a pawn-Err ..ahem, loyal soldier with that name."), JsonRequestBehavior.AllowGet)); } var type = (StrategyType)strategyType; var strategy = GetStrategyFromType(type); var planner = new PlanningService(); var planOutcome = planner.Execute(strategy, db, player); return(Json(planOutcome, JsonRequestBehavior.AllowGet)); }