protected override void Seed(TransportSchedule.Schedule.Repo.Context context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. DataRepository <Route> routes = new RouteRepository(); DataRepository <Station> stations = new StationRepository(); List <User> users = WorkinhWithUserMethods.GetUsers(); foreach (var item in stations.Items) { context.Stations.AddOrUpdate(c => c.Id, item); } foreach (var item in routes.Items) { foreach (var station in item.Stations) { station.Station = context.Stations.SingleOrDefault(x => x.Id == station.StationID); } context.Routes.AddOrUpdate(c => c.Name, item); } foreach (var item in users) { foreach (var station in item.FavouriteStations) { station.Station = context.Stations.SingleOrDefault(x => x.Id == station.StationID); station.User = item; } context.Users.AddOrUpdate(c => c.UserId, item); } context.SaveChanges(); }
protected override void Seed(Context context) { DataRepository <Route> routes = new RouteRepository(); DataRepository <Station> stations = new StationRepository(); List <User> users = WorkinhWithUserMethods.GetUsers(); foreach (var item in stations.Items) { context.Stations.Add(item); } foreach (var item in routes.Items) { context.Routes.Add(item); } foreach (var item in users) { context.Users.Add(item); } context.SaveChanges(); }
private void Button_Register_End(object sender, RoutedEventArgs e) { if (RegisterLogin.Text != "" && RegisterPassword.Password != "" && RegisterEmail.Text != "") { var temp = WorkinhWithUserMethods.RegistrationNewUser(RegisterLogin.Text, RegisterPassword.Password, RegisterEmail.Text); if (temp == true) { MainWindow w = new MainWindow(WorkinhWithUserMethods.Authorization(RegisterLogin.Text, RegisterPassword.Password)); w.Show(); Close(); } else { MessageBox.Show("This user is already existing", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { TextOutput.Text = "FILL THE GAPS"; } }
private void Button_ClickEnter(object sender, RoutedEventArgs e) { if (LoginBox.Text == "" || PasswordBox.Password == "") { MessageBox.Show("FILL THE GAPS", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); TextOutput.Text = "FILL THE GAPS"; } else { if (WorkinhWithUserMethods.Authorization(LoginBox.Text, PasswordBox.Password) != null) { MainWindow w = new MainWindow(WorkinhWithUserMethods.Authorization(LoginBox.Text, PasswordBox.Password)); w.Show(); Close(); } else { TextOutput.Text = "ERROR!"; LoginBox.Text = ""; PasswordBox.Password = ""; } } }