/// <summary> /// Whenever a person is finished being added, we will scroll to that /// person in the grid after updating the RowTimestamp /// </summary> /// <param name="person"></param> public void PersonInsertCompleted(CACCCheckInDb.Person person) { // Look for the person that was just inserted in in the people list. CACCCheckInDb.Person existingPerson = PeopleDataContext.FirstOrDefault(p => p.Id.Equals(person.Id)); existingPerson.RowTimestamp = person.RowTimestamp; _peopleView.MoveCurrentTo(existingPerson); try { if (null != _peopleView.CurrentItem) { PeopleDataGrid.ScrollIntoView(_peopleView.CurrentItem); } } catch (NullReferenceException ex) { logger.Error("ScrollIntoView Exception: ", ex); } }
public PeopleEfProvider(PeopleDataContext dataContext = null, IMappingEngine mappingEngine = null) { DataContext = dataContext ?? new PeopleDataContext(); MappingEngine = mappingEngine ?? MappingEngineInit.Value; DatabaseHelpersRepo = new DatabaseHelpersRepo(DataContext, MappingEngine); }
/// <summary> /// The main entry point of this assembly /// </summary> /// <param name="args">Command line arguments</param> static void Main(string[] args) { try { var connectionString = ConfigurationManager.ConnectionStrings["peopleManagerEntities"].ConnectionString; using (var dataContext = new PeopleDataContext(connectionString)) { dataContext.Database.CreateIfNotExists(); dataContext.People.AddRange(new List <Person> { new Person { FirstName = "Marc", LastName = "Plöchl", Age = 31, Addresses = new List <Address> { new Address { Street = "Hotterweg 20", Zip = 7023, City = "Zemendorf", State = "Austria" }, new Address { Street = "Hauptstrasse 1a", Zip = 7023, City = "Zemendorf", State = "Austria" }, } }, new Person { FirstName = "Angelika", LastName = "Plöchl", Age = 31, Addresses = new List <Address> { new Address { Street = "Hotterweg 20", Zip = 7023, City = "Zemendorf", State = "Austria" }, new Address { Street = "Hauptstrasse 1a", Zip = 7023, City = "Zemendorf", State = "Austria" }, } }, new Person { FirstName = "Alexandra", LastName = "Freiberger", Age = 45, Addresses = new List <Address> { new Address { Street = "Mattersburgerstrasse 30", Zip = 7202, City = "Bad Sauerbrunn", State = "Austria" }, new Address { Street = "Weinberggasse 5b", Zip = 7202, City = "Bad Sauerbrunn", State = "Austria" }, } }, new Person { FirstName = "Andrea", LastName = "Fertl", Age = 50, Addresses = new List <Address> { new Address { Street = "Martinsgasse 4", Zip = 7203, City = "Wiesen", State = "Austria" }, } }, }); dataContext.SaveChanges(); Console.WriteLine("Database created!"); } } catch (Exception ex) { Console.WriteLine($@"An error has occured on creating the database: {ex.ToString()}"); Console.ReadLine(); } }