public void Setup()
        {
            var options = new DbContextOptionsBuilder <ShiftContext>()
                          .UseInMemoryDatabase(databaseName: "ShifttDatabase")
                          .Options;

            // Insert seed data into the database using one instance of the context
            shiftContext = new ShiftContext(options);
            shiftContext.Shifts.Add(new Shift {
                id = 1, employeeSlots = 6, shiftDate = DateTime.Now, workingEmployees = new List <User>()
                {
                    new User(1, "Dave", 1), new User(2, "Steve", 1)
                }
            });
            shiftContext.Shifts.Add(new Shift {
                id = 2, employeeSlots = 6, shiftDate = DateTime.Now, workingEmployees = new List <User>()
                {
                    new User(1, "Dave", 2), new User(2, "Steve", 2), new User(3, "Lisa", 2)
                }
            });
            shiftContext.Shifts.Add(new Shift {
                id = 3, employeeSlots = 6, shiftDate = DateTime.Now, workingEmployees = new List <User>()
            });
            shiftContext.SaveChanges();

            shiftManager = new ShiftManager(shiftContext);

            shiftController = new ShiftController(shiftManager);
        }
Example #2
0
 public int SaveChanges()
 {
     //Sempre retorna um "int" (nĂºmero de linhas afetadas)
     return(Db.SaveChanges());
 }
Example #3
0
 public bool Commit()
 {
     return(_context.SaveChanges() > 0);
 }