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();
        }
예제 #2
0
        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");
        }
예제 #3
0
 public Area Post([FromBody] Area area)
 {
     context.Areas.Add(area);
     context.SaveChanges();
     return(area);
 }
예제 #4
0
 public Employee Post([FromBody] Employee employee)
 {
     context.Employees.Add(employee);
     context.SaveChanges();
     return(employee);
 }