public void AddConsultant(Consultant Consultant) { try { db.Consultants.Add(Consultant); db.SaveChanges(); } catch (Exception e) { throw new Exception(e.Message); } }
private ConsultantContext GetContextWithData() { var options = new DbContextOptionsBuilder <ConsultantContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new ConsultantContext(options); context.Consultants.Add(new Consultant("Louis", "Broucke", "Junior .NET Developer", "Mechelen", "*****@*****.**", "0478529462", new DateTime(1991, 09, 14))); context.Consultants.Add(new Consultant("Koen", "Hublet", "Operations Manager", "Gent", "*****@*****.**", "0478529462", new DateTime(1991, 09, 14))); context.Consultants.Add(new Consultant("Nele", "Goovaerts", "HR Manager", "Mechelen", "*****@*****.**", "0478529462", new DateTime(1991, 09, 14))); context.Consultants.Add(new Consultant("Seppe", "Van Brabant", "Sales Manager", "Antwerpen", "*****@*****.**", "0478529462", new DateTime(1991, 09, 14))); context.Consultants.Add(new Consultant("Noortje", "Vanbutsele", "Sales Manager", "Leuven", "*****@*****.**", "0478529462", new DateTime(1991, 09, 14))); context.SaveChanges(); return(context); }
public void AddConsultant(Consultant consultant) { context.Consultants.Add(consultant); context.SaveChanges(); }