public void CreateDatabase() { context = new EmployeeMapContext(configuration); context.Database.EnsureDeleted(); context.Database.Migrate(); controller = new EmployeesController(context); context.Areas.Add(new Area { Name = "Executive Area" }); var area = new Area { Name = "Open Area" }; context.Areas.Add(area); context.Employees.Add(new Employee { FirstName = "Niels", LastName = "Swimberghe", Area = area }); context.Employees.Add(new Employee { FirstName = "Micheal", LastName = "Fly", Area = area }); context.SaveChanges(); }
public void Test_That_Areas_Can_Be_Created() { context.Areas.Add(new Area { Name = "Executive Area" }); context.Areas.Add(new Area { Name = "Open Area" }); context.SaveChanges(); Assert.IsTrue(context.Areas.Any(a => a.Name == "Executive Area"), "Executive Area not found in database"); Assert.IsTrue(context.Areas.Any(a => a.Name == "Open Area"), "Open Area not found in database"); }
public Area Post([FromBody] Area area) { context.Areas.Add(area); context.SaveChanges(); return(area); }
public Employee Post([FromBody] Employee employee) { context.Employees.Add(employee); context.SaveChanges(); return(employee); }