Exemple #1
0
        public Project Add(Project entity)
        {
            var Project = db.Projects.Add(entity).Entity;

            db.SaveChanges();
            return(Project);
        }
        public static void Initialize(ProjectAPIContext context)
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            // Look for any Products
            if (context.Projects.Any())
            {
                return;   // DB has been seeded
            }

            List <Project> pros = new List <Project>
            {
                new Project {
                    Id = 1, Name = "DBDEXAM", DepartmentNumber = 1
                },
                new Project {
                    Id = 2, Name = "SYSEXAM", DepartmentNumber = 1
                },
                new Project {
                    Id = 3, Name = "CA1", DepartmentNumber = 2
                },
                new Project {
                    Id = 4, Name = "CA2", DepartmentNumber = 2
                }
            };

            context.Projects.AddRange(pros);
            context.SaveChanges();
        }
 public bool SaveChanges()
 {
     return(_context.SaveChanges() >= 0);
 }