public static void Initialize(IServiceProvider serviceProvider) { using (var context = new Assgn10Context( serviceProvider.GetRequiredService <DbContextOptions <Assgn10Context> >())) { // Look for any movies. if (context.People.Any()) { return; // DB has been seeded } context.People.AddRange( new Entity.Assgn10Person { FirstName = "George", LastName = "Tree", BirthDate = DateTime.Parse("1989-1-11"), City = "Ames", State = "Iowa", SetOfAccomplishments = "Planting Award", }, new Entity.Assgn10Person { FirstName = "Paul", LastName = "Steel", BirthDate = DateTime.Parse("1995-4-02"), City = "Adel", State = "Iowa", SetOfAccomplishments = "Welding Award", } ); context.SaveChanges(); } }
public PersonCreateCommandModel Create(PersonCreateCommandModel cmd) { var model = new Assgn10Person { FirstName = cmd.FirstName, LastName = cmd.LastName, BirthDate = cmd.BirthDate, City = cmd.City, State = cmd.State, IsDeleted = false, }; _assgn10Context.People.Add(model); _assgn10Context.SaveChanges(); return(cmd); }
public void CreatePeople(int id, UpdatePeopleCommand command) { var person = _assgn10Context.People.Find(id); if (person == null) { throw new Exception("Unable to find Person"); } person.FirstName = command.FirstName; person.LastName = command.LastName; person.BirthDate = command.BirthDate; person.City = command.City; person.State = command.State; person.SetOfAccomplishments = command.SetOfAccomplishments; _assgn10Context.SaveChanges(); }