public ActionResult Shooter() { string connstring = RouteConfig.connectString; NpgsqlConnection connection = new NpgsqlConnection(connstring); connection.Open(); NpgsqlCommand command = new NpgsqlCommand("SELECT * FROM shooters.shooter", connection); NpgsqlDataReader dataReader = command.ExecuteReader(); NpgsqlDataAdapter da = new NpgsqlDataAdapter(); DataTable dt = new DataTable(); //for (int i = 0; dataReader.Read(); i++){} while (dataReader.Read()) { } dt.Load(dataReader); da.SelectCommand = command; da.Fill(dt); List <actor> _list = TableUtils.CreateListFromTable <actor>(dt); connection.Close(); var model = new Shooters() { }; model.Actors = _list; return(View(model)); // return View(); }
public ActionResult Shooter(string first, string last) { string query = "SELECT * FROM shooters.shooter"; List <actor> _actors = TableUtils.queryToTable <actor>(query); Shooters _shooters = new Shooters(); _shooters.Actors = _actors; return(View(_shooters)); }
// Removes shooter by id public bool RemoveShooter(long id) { for (int i = 0; i < Shooters.Count; i++) { if (Shooters[i].Id == id) { Shooters.RemoveAt(i); return(true); } } return(false); }
public void Initialize() { _personDataStore = ServiceLocator.Current.GetInstance <IPersonDataStore>(); _shooterDataStore = ServiceLocator.Current.GetInstance <IShooterDataStore>(); _shooterNumberService = ServiceLocator.Current.GetInstance <IShooterNumberService>(); _shooterDataWriter = ServiceLocator.Current.GetInstance <ISsvShooterDataWriterService>(); _collectionShooterDataStore = ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>(); _shooterCollectionDataStore = ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>(); _serviceDeskConfiguration = ServiceLocator.Current.GetInstance <ServiceDeskConfiguration>(); MessengerInstance.Register <PersonSelectedMessage>(this, x => { UpdateCommandCanExecuteOnSelectedPersonChanged(); LoadShooters(x.PersonId); }); MessengerInstance.Register <SetSelectedPersonMessage>(this, x => { SelectedPerson = FilteredPersons.FirstOrDefault(person => person.PersonId == x.PersonId); }); MessengerInstance.Register <SetSelectedShooterMessage>(this, x => { SelectedShooter = Shooters.FirstOrDefault(s => s.Shooter.ShooterId == x.ShooterId); if (SelectedShooter == null) { SelectedShooter = Shooters.FirstOrDefault(); } }); MessengerInstance.Register <RefreshDataFromRepositoriesMessage>(this, x => { UiPerson selectedPerson = SelectedPerson; ShooterViewModel selectedShooter = SelectedShooter; LoadPersons(); if (selectedPerson != null) { MessengerInstance.Send(new SetSelectedPersonMessage(selectedPerson.PersonId)); } if (selectedShooter != null) { MessengerInstance.Send(new SetSelectedShooterMessage(selectedShooter.Shooter.ShooterId)); } }); }
// Ad shooter to observable collection public void AddShooter(Shooter shooter) { Shooters.Add(shooter); }