public IList<ProjectRole> GetAll()
 {
     using (var ctx = new WcfEntityContext())
     {
         return ctx.ProjectRole.Include("User").Include("Project").Include("Role").ToList();
     }
 }
        public Bug Update(Bug bug)
        {
            bug.LastModified = DateTime.Now;

            using (var ctx = new WcfEntityContext())
            {
                var oldBug = ctx.Bugs.Include("CreatedBy").Include("Project").Include("AssignedUser")
                    .Where(h => h.Id == bug.Id).SingleOrDefault();

                var userCreated = ctx.Users.Where(n => n.Id == bug.CreatedBy.Id).SingleOrDefault();
                var assignedProject = ctx.Projects.Where(c => c.Id == bug.Project.Id).SingleOrDefault();

                if (bug.AssignedUser != null)
                {
                    var userAssigned = ctx.Users.Where(u => u.Id == bug.AssignedUser.Id).SingleOrDefault();
                    oldBug.AssignedUser = userAssigned;
                }

                oldBug.CreatedBy = userCreated;
                oldBug.Project = assignedProject;

                ctx.Bugs.ApplyCurrentValues(bug);

                ctx.SaveChanges();

                return bug;
            }
        }
 public IList<UserProjectSignup> GetAll()
 {
     using (var ctx = new WcfEntityContext())
     {
         return ctx.UserProjectSignup.Include("User").Include("Project").Include("Role").ToList();
     }
 }
        public Bug Create(Bug bug)
        {
            bug.DateFound    = DateTime.Now;
            bug.LastModified = DateTime.Now;

            using (var ctx = new WcfEntityContext())
            {
                var project      = ctx.Projects.Where(x => x.Id == bug.Project.Id)     .SingleOrDefault();
                var createdBy    = ctx.Users.Where   (u => u.Id == bug.CreatedBy.Id)   .SingleOrDefault();

                if (bug.AssignedUser != null)
                {
                    var assignedUser = ctx.Users.Where(p => p.Id == bug.AssignedUser.Id).SingleOrDefault();
                    bug.AssignedUser = assignedUser;
                }

                bug.CreatedBy    = createdBy;
                bug.Project      = project;

                ctx.Bugs.AddObject(bug);
                ctx.SaveChanges();

                return bug;
            }
        }
        public BugActionLog Update(BugActionLog log)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachModify("BugActionLogs", log);

                return log;
            }
        }
        public ProjectRole Update(ProjectRole projRole)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachModify("ProjectRoles", projRole);

                return projRole;
            }
        }
        public IList<Project> GetAll()
        {
            using (var ctx = new WcfEntityContext())
            {
                IList<Project> projects = ctx.Projects.ToList();

                return projects;
            }
        }
        public UserProjectSignup Update(UserProjectSignup projRole)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachModify("UserProjectSignups", projRole);

                return projRole;
            }
        }
        public IList<Role> GetAll()
        {
            using (var ctx = new WcfEntityContext())
            {
                IList<Role> roles = ctx.Roles.ToList();

                return roles;
            }
        }
        public Role Create(Role role)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.Roles.AddObject(role);
                ctx.SaveChanges();

                return role;
            }
        }
        public Project Update(Project project)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachModify("Projects", project);
                ctx.SaveChanges();

                return project;
            }
        }
        public void Delete(User user)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachTo("Users", user);
                ctx.Users.DeleteObject(user);

                ctx.SaveChanges();
            }
        }
        public Project Create(Project project)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.Projects.AddObject(project);
                ctx.SaveChanges();

                return project;
            }
        }
        public Role Update(Role role)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachModify("Roles", role);
                ctx.SaveChanges();

                return role;
            }
        }
        public void Delete(Role role)
        {
            using (var ctx = new WcfEntityContext())
            {
                Role myrole = ctx.Roles.Where(p => p.Id == role.Id).FirstOrDefault();
                ctx.Roles.Attach(myrole);
                ctx.Roles.DeleteObject(myrole);

                ctx.SaveChanges();
            }
        }
        public void Delete(BugActionLog log)
        {
            using (var ctx = new WcfEntityContext())
            {
                BugActionLog logEntity = ctx.BugActionLogs.Where(p => p.Id == log.Id).FirstOrDefault();
                ctx.BugActionLogs.Attach(logEntity);
                ctx.BugActionLogs.DeleteObject(logEntity);

                ctx.SaveChanges();
            }
        }
        public ProjectRole Create(ProjectRole projRole)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.ProjectRole.AddObject(projRole);

                ctx.SaveChanges();

                return projRole;
            }
        }
        public void Delete(Bug bug)
        {
            using (var ctx = new WcfEntityContext())
            {
                Bug mybug = ctx.Bugs.Where(p => p.Id == bug.Id).FirstOrDefault();
                ctx.Bugs.Attach(mybug);
                ctx.Bugs.DeleteObject(mybug);

                ctx.SaveChanges();
            }
        }
        public UserProjectSignup Create(UserProjectSignup projSignup)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.UserProjectSignup.AddObject(projSignup);

                ctx.SaveChanges();

                return projSignup;
            }
        }
        public User Update(User user)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachModify("Users", user);

                ctx.SaveChanges();

                return user;
            }
        }
        public User Create(User user)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.Users.AddObject(user);

                ctx.SaveChanges();

                return user;
            }
        }
        public void Delete(UserProjectSignup projRole)
        {
            using (var ctx = new WcfEntityContext())
            {
                var entityToDelete = ctx.UserProjectSignup.Where(p => p.ProjectId == projRole.ProjectId
                                                           && p.UserId == projRole.UserId
                                                           && p.RoleId == projRole.RoleId).SingleOrDefault();

                ctx.UserProjectSignup.DeleteObject(entityToDelete);
                ctx.SaveChanges();
            }
        }
        public void Delete(Project project)
        {
            using (var ctx = new WcfEntityContext())
            {
                var proj = Context.Projects.Where(p => p.Id == project.Id).SingleOrDefault();

                ctx.AttachTo("Projects", proj);
                ctx.Projects.DeleteObject(proj);

                ctx.SaveChanges();
            }
        }
        public BugActionLog Create(BugActionLog log)
        {
            log.Date = DateTime.Now;

            using (var ctx = new WcfEntityContext())
            {
                log.Action = ctx.Actions.Where(p => p.Id == log.Action.Id).SingleOrDefault();
                log.Project = ctx.Projects.Where(p => log.Project.Id == p.Id).SingleOrDefault();

                ctx.BugActionLogs.AddObject(log);

                ctx.SaveChanges();

                return log;
            }
        }
Exemple #25
0
 public Repository()
 {
     Context = new WcfEntityContext();
 }