Example #1
0
 public void AddDeveloperToProject(string userId, int projectId)
 {
     // add a
     if (!this.IsProjectDeveloper(userId, projectId))
     {
         var pu = new ProjectUser {
             ProjectId = projectId, UserId = userId
         };
         db.ProjectUsers.Add(pu);
         db.SaveChanges();
     }
 }
Example #2
0
        static ApplicationDbContext db = new ApplicationDbContext();                // the database

        // Add() for adding projects to the database
        public static bool AddProject(string name, string userId)
        {
            Project project = new Project()
            {
                Name = name
            };

            db.Projects.Add(project);
            db.SaveChanges();
            ProjectUser projectUser = new ProjectUser()
            {
                ProjectId = project.Id, UserId = userId
            };

            db.ProjectUsers.Add(projectUser);
            db.SaveChanges();
            return(true);
        }