static void Main(string[] args) { try { List <Person> people = new List <Person>(); foreach (string line in File.ReadLines(@"C:\Users\wormst\Desktop\data.csv")) { string[] separated = line.Split(';'); Person person = new Person(); person.Gender = separated[0] == "female" ? Gender.Female : Gender.Male; person.Name = separated[1]; person.Surname = separated[2]; person.City = separated[3]; person.Country = separated[4]; string test = separated[5]; person.Birthdate = DateTime.Parse(separated[5]); person.Telephone = separated[6]; person.BloodType = separated[7]; person.Weight = Double.Parse(separated[8]); person.Height = Double.Parse(separated[9]); people.Add(person); } CassandraDbContext dbContext = new CassandraDbContext(); foreach (var item in people) { dbContext.People.Add(item); } } catch (Exception ex) { } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CassandraDbContext dbContext) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=People}/{action=Index}/{id?}"); }); //DbSeeder.Seed(dbContext); }
public BloodAmountsController(CassandraDbContext context) { _context = context; }
public PeopleController(CassandraDbContext context) { this.dbContext = context; }
public CassandraController(CassandraDbContext dbContext) { this.dbContext = dbContext; }