public GameProcessModel Edit(int id) { var player = _playersRepository.GetAll().ToList(); var gameProcess = _gameProcessRepository.GetAll().First(c => c.Id == id); var gameProcessItems = GetGameProcessItems(gameProcess); var totalInput = gameProcessItems.SelectMany(c => c.Input.Select(i => i.Amount).ToList()).Sum(); var totalOutput = gameProcessItems.Where(c => c.OutPut != null).Select(c => c.OutPut.Amount).Sum(); var subtract = !gameProcess.EndDateTime.HasValue ? DateTime.Subtract(gameProcess.StartDateTime.GetValueOrDefault()) : gameProcess.EndDateTime.Value.Subtract(gameProcess.StartDateTime.GetValueOrDefault()); var vm = new GameProcessModel { Items = gameProcessItems, DirationTime = subtract, PlayerCount = gameProcessItems.Count, TotalInput = totalInput, TotalOutput = totalOutput, Total = (totalInput - totalOutput), Id = id, EditModel = new Action { GameProcessId = id, Amount = 6000 }, Players = player.Select(c => new PlayerItem { Name = c.Name, Id = c.Id.ToString(), ImageUrl = c.ImageUrl }).ToList() }; return(vm); }
private void InitializeModelsAndControllers() { var shovel = new ShovelModel(ShovelsAmount); _shovelController = new ShovelController(shovel); var gold = new GoldWalletModel(GoldGoal); _goldWalletController = new GoldWalletController(gold); for (int i = 0; i < FieldSize * FieldSize; ++i) { var cell = new CellModel(CellDepth, i); _cellControllers.Add(i, new CellController(cell)); } var goldBarsSpawnerModel = new GoldBarsSpawnerModel(); _goldBarsSpawnerController = new GoldBarsSpawnerController(goldBarsSpawnerModel); var gameProcessModel = new GameProcessModel(); _gameProcessController = new GameProcessController(gameProcessModel); }
public GameProcessController(GameProcessModel model) { _model = model; }