public static void Execute(Game game) { using (var context = new MonopolyDotNetDbContext()) { context.Games.Attach(game); game.BuyProperty(); context.SaveChanges(); } }
public static void Execute(string username, NewGameData newGameData) { using (var context = new MonopolyDotNetDbContext()) { var game = new Game(newGameData, username); context.Games.Add(game); context.SaveChanges(); } }
public static GameStatusViewModel Flatten(Game game) { var vm = new GameStatusViewModel(); var gameStatus = game.GetCurrentGameStatus(); vm.PlayerStatuses.AddRange(gameStatus.Players.Select(player => Convert(player)).OrderBy(x=>x.PlayerNumber)); vm.CanRoll = gameStatus.CanRoll; vm.CanBuyProperty = gameStatus.CanBuyProperty; vm.CanEndTurn = gameStatus.CanEndTurn; vm.PropertySalePrice = CashHelper.FormatAsCash(gameStatus.PropertySalePrice); return vm; }
public ActionResult Roll(Game game) { RollDiceCommand.Execute(game); return this.RedirectToAction<HomeController>(x => x.Index()); }
public ActionResult Index(Game game) { var gameStatus = GameFormatter.Flatten(game); return View(gameStatus); }
public ActionResult BuyProperty(Game game) { BuyPropertyCommand.Execute(game); return this.RedirectToAction<HomeController>(x => x.Index()); }