public void Changed(ChangeArgs args) { if (args.Type == ChangeType.PlayerSelected || args.Type == ChangeType.PlayerChanged) { var playerArgs = (SoccerPlayerArgs)args; Player = new SoccerPlayerViewModel(playerArgs.PlayerValues, Collections, _changesManager); } }
public SoccerPlayerDetailsViewModel(SoccerPlayer player, CollectionFactory collections, IChangeManager changesManager) { Collections = collections; _changesManager = changesManager; _playerModel = player; Player = new SoccerPlayerViewModel(player); }
public SoccerPlayerViewModel(SoccerPlayerViewModel viewModel, CollectionFactory collections, IChangeManager changeManager) { if (viewModel == null) { return; } var playerModel = new SoccerPlayer(viewModel); Id = viewModel.Id; TeamId = viewModel.TeamId; Name = new EditableCellViewModel(viewModel.Name.Value, changeManager, ColumnName.PlayerName, playerModel); DateTime birthDate = new DateTime(); if (viewModel.BirthDate.Value is DateTime) { birthDate = (DateTime)viewModel.BirthDate.Value; } else { birthDate = DateTime.Parse((string)viewModel.BirthDate.Value); } BirthDate = new EditableCellViewModel(birthDate.ToShortDateString(), changeManager, ColumnName.BirthDate, playerModel); Age = new CellViewModel(DateTime.Now.Year - birthDate.Year); IsCaptain = new EditableCellViewModel(viewModel.IsCaptain.Value, changeManager, ColumnName.IsCaptain, playerModel); Position = new ComboBoxCellViewModel(collections.PositionRoles.Find(pr => pr == (PositionRole)viewModel.Position.Value), collections.PositionRoles, changeManager, playerModel, ColumnName.Position); Group = viewModel.Group; Nationality = new ComboBoxCellViewModel(collections.NationViewModels.Find(n => n.Id == (viewModel.Nationality.Value as ComboBoxItemViewModel).Id), collections.NationViewModels, changeManager, playerModel, ColumnName.Nationality); Rating = new EditableCellViewModel(viewModel.Rating.Value, changeManager, ColumnName.Rating, playerModel); RotationTeam = new CellViewModel(viewModel.RotationTeam.Value); IsNewPlayer = new CellViewModel(false); IsLineup = viewModel.IsLineup; IsEnabled = true; }