public void Setup() { ObjectsConverter.Configure(); ExercisesBuilderPL exercisesBuilder = new ExercisesBuilderPL(); exercises = exercisesBuilder.Create().ToDictionary(t => t.GlobalId); }
private void btnCreateDb_Click(object sender, EventArgs e) { var cfg = createNHConfiguration(); try { SchemaExport exp = new SchemaExport(cfg); exp.Execute(true, true, false); //MySql.Data.MySqlClient.MySqlScript script = new MySqlScript(); //script.Connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString); //script.Query = File.ReadAllText("..\\..\\DbScripts\\MySql.sql"); //script.Execute(); var factory = cfg.BuildSessionFactory(); using (var session = factory.OpenSession()) using (var tx = session.BeginTransaction()) { ExercisesBuilderPL builder = new ExercisesBuilderPL(); foreach (var exercise in builder.Create()) { //exercise.Status = PublishStatus.Published; session.Save(exercise); } SuplementsBuilder suplementsBuilder = new SuplementsBuilder(); foreach (var supplement in suplementsBuilder.Create()) { session.Save(supplement); } session.Flush(); Profile profile = new Profile(); profile.UserName = ProfileDTO.AdministratorName; //todo:user better email profile.Email = "*****@*****.**"; profile.Birthday = DateTime.Now.AddYears(-30); profile.Privacy = new ProfilePrivacy(); profile.Privacy.Searchable = false; profile.Settings = new ProfileSettings(); profile.Licence = new BodyArchitect.Model.LicenceInfo(); profile.Licence.AccountType = AccountType.Administrator; profile.CountryId = Country.GetByTwoLetters("PL").GeoId; profile.DataInfo = new DataInfo(); session.Save(profile); Profile deletedProfile = new Profile(); deletedProfile.UserName = "******"; deletedProfile.Email = "*****@*****.**"; deletedProfile.Birthday = DateTime.Now.AddYears(-30); deletedProfile.Privacy = new ProfilePrivacy(); deletedProfile.Privacy.Searchable = false; deletedProfile.IsDeleted = true; deletedProfile.CountryId = Country.GetByTwoLetters("PL").GeoId; deletedProfile.DataInfo = new DataInfo(); deletedProfile.Settings = new ProfileSettings(); deletedProfile.Licence = new BodyArchitect.Model.LicenceInfo(); deletedProfile.Licence.AccountType = AccountType.Administrator; session.Save(deletedProfile); APIKey apiKey = new APIKey(); apiKey.ApiKey = new Guid("14375345-3755-46f7-af3f-0d328e3a2cc0"); apiKey.ApplicationName = "BodyArchitect"; apiKey.EMail = "*****@*****.**"; apiKey.RegisterDateTime = DateTime.UtcNow; apiKey.Platform = PlatformType.Windows; session.Save(apiKey); apiKey = new APIKey(); apiKey.ApiKey = new Guid("A3C9D236-2566-40CF-A430-0802EE439B9C"); apiKey.ApplicationName = "BodyArchitect for WP7"; apiKey.EMail = "*****@*****.**"; apiKey.RegisterDateTime = DateTime.UtcNow; apiKey.Platform = PlatformType.WindowsPhone; session.Save(apiKey); apiKey = new APIKey(); apiKey.ApiKey = new Guid("87AFE52C-9EAC-4BAF-949C-08E919285ADA"); apiKey.ApplicationName = "BodyArchitect for iPhone"; apiKey.EMail = "*****@*****.**"; apiKey.RegisterDateTime = DateTime.UtcNow; apiKey.Platform = PlatformType.iPhone; session.Save(apiKey); var deletedExercise = new Exercise(Guid.NewGuid()); deletedExercise.Name = "(Missing)"; deletedExercise.Shortcut = "__D"; deletedExercise.IsDeleted = true; session.Save(deletedExercise); tx.Commit(); } } catch (Exception) { throw; } //fluentConf.BuildSessionFactory(); }