public bool Update(PlayerModel item) { if (items.Any(x => x.Id == item.Id)) { items[item.Id] = item; return true; } return false; }
public PlayerTestRepository(IBuildRepository builds) { var player = new PlayerModel { Name = "Jupotter" }; player.Build.Add(builds.GetById(0)); player.Build.Add(builds.GetById(1)); Add(player); player = new PlayerModel { Name = "Nilun" }; player.Build.Add(builds.GetById(2)); player.Build.Add(builds.GetById(3)); player.Build.Add(builds.GetById(1)); Add(player); player = new PlayerModel { Name = "Smurfi" }; player.Build.Add(builds.GetById(4)); Add(player); }
public void Add(PlayerModel item) { item.Id = 1 + items.Max(x => (int?)x.Id) ?? 0; items.Add(item); }