Exemplo n.º 1
0
        private static void SeedProjects(
            ProjectsDbContext projectsDb,
            out IEnumerable<Project> projetcs)
        {
            var customer = projectsDb.Companies.Skip(1).FirstOrDefault();
            if (customer == null)
            {
                throw new ArgumentNullException(
                    "company",
                    "Accounting module must be seeded first. Make sure the even CompaniesCreated is triggered and at least two companies are seeded.");
            }

            var employees = projectsDb.Set<Employee>().ToList();
            if (employees == null || employees.Count() < 2)
            {
                throw new ArgumentNullException(
                    "employees",
                    "Company module must be seeded first. Make sure the even EmployeesCreated is triggered and at least two employees are seeded.");
            }

            var ivan = employees.First();
            var project = Project.Create(
                "Apartment complex - Sofia",
                new DateTime(2017, 2, 25),
                new DateTime(2017, 10, 25),
                ivan.Id,
                customer.Id);

            projetcs = new List<Project>()
            {
                project
            };

            projectsDb.Set<Project>().AddRange(projetcs);
        }
Exemplo n.º 2
0
 public GenericRepository(ProjectsDbContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }