public int Complete() { return(_context.SaveChanges()); }
public UoWTests() { context = new CoursesDBContext(); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Course course1 = new Course { Id = 1, Name = "TYPESCRIPT: THE BIG PICTURE", Description = "Learn Typescript", SalesTimes = 1000, Authors = new List <Author> { new Author { Id = 1, Name = "Simon Allardice", Language = "English" } } }; Course course2 = new Course { Id = 2, Name = "Angular Up and Running", Description = "Learn Angular", SalesTimes = 2000, Authors = new List <Author> { new Author { Id = 2, Name = "John Papa", Language = "English" } } }; context.AddRange(course1, course2); context.SaveChanges(); //var course1Found = context.Courses.Where(c => c.Id == 1).First(); //course1Found.Authors.Add(new Author { // Id = 1, // Name = "Simon Allardice" //}); //var course2Found = context.Courses.Where(c => c.Id == 2).First(); //course2Found.Authors.Add(new Author //{ // Id = 2, // Name = "John Papa" //}); //context.SaveChanges(); coursesRepo = new CourseRepository(context); authorsRepo = new AuthorRepository(context); unitOfWork = new UnitOfWorkCourses(context, coursesRepo, authorsRepo); }