Inheritance: System.Data.Linq.DataContext
コード例 #1
0
        public static IEnumerable<Project> GetProjects(int page, int pageSize, bool asc, string sortExpression, out int itemsCount)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            int items;
            if(sortExpression == "SortNumber")
            {
                 var projects = db.Projects.Page(page, pageSize, p => p.ProjectId, asc, out items);
                 itemsCount = items;
                 return projects;
            }
            else if (sortExpression == "SortName")
            {
                var projects = db.Projects.Page(page, pageSize, p => p.Name, asc, out items);
                itemsCount = items;
                return projects;
            }
            else if (sortExpression == "SortDescription")
            {
                var projects = db.Projects.Page(page, pageSize, p => p.Description, asc, out items);
                itemsCount = items;
                return projects;
            }
            else
            {
                itemsCount = 0;
                return null;
            }
        }
コード例 #2
0
        public static void Delete(int bugId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            Bug bugToDelete = db.Bugs.Single(t => t.BugId == bugId);
            bugToDelete.Status = Status.Deleted.ToString();
            db.SubmitChanges();
        }
コード例 #3
0
 public static int GetBugsCountByProject(string projectName)
 {
     DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();
     string sqlFindBugsCountByProjectName =
         "SELECT Count(*) FROM Bugs b JOIN Projects p ON (b.ProjectId=p.ProjectId) WHERE p.Name = '" + projectName + "' and b.Status != 'Closed'";
     int bugsCount = db.ExecuteQuery<int>(sqlFindBugsCountByProjectName).First();
     return bugsCount;
 }
コード例 #4
0
        public static IEnumerable<Bug> GetBugs(int page, int pageSize, bool asc, string sortExpression, out int itemsCount)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            int items;
            switch (sortExpression)
            {
                case "SortDescription":
                    var bugs = db.Bugs.Page(page, pageSize, p => p.Description,
                                                            p=> p.Status != Status.Closed.ToString(),
                                                            p => p.Status != Status.Deleted.ToString(),
                                                            asc, out items);
                    itemsCount = items;
                    return bugs;
                case "SortId":
                    bugs = db.Bugs.Page(page, pageSize, p => p.BugId,
                                                        p => p.Status != Status.Closed.ToString(),
                                                        p => p.Status != Status.Deleted.ToString(),
                                                        asc, out items);
                    itemsCount = items;
                    return bugs;
                case "SortPriority":
                    bugs = db.Bugs.Page(page, pageSize, p => p.Priority,
                                                        p => p.Status != Status.Closed.ToString(),
                                                        p => p.Status != Status.Deleted.ToString(),
                                                        asc, out items);
                    itemsCount = items;
                    return bugs;
                case "SortOwner":
                    bugs = db.Bugs.Page(page, pageSize, p => p.Tester.Name,
                                                        p => p.Status != Status.Closed.ToString(),
                                                        p => p.Status != Status.Deleted.ToString(),
                                                        asc, out items);
                    itemsCount = items;
                    return bugs;
                case "SortProject":
                    bugs = db.Bugs.Page(page, pageSize, p => p.Project.Name,
                                                        p => p.Status != Status.Closed.ToString(),
                                                        p => p.Status != Status.Deleted.ToString(),
                                                        asc, out items);
                    itemsCount = items;
                    return bugs;
                case "SortStatus":
                    bugs = db.Bugs.Page(page, pageSize, p => p.Status,
                                                        p => p.Status != Status.Closed.ToString(),
                                                        p => p.Status != Status.Deleted.ToString(),
                                                        asc, out items);
                    itemsCount = items;
                    return bugs;
            }

            itemsCount = 0;
            return null;
        }
コード例 #5
0
        public static void Delete(int testerId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            // all testers bugs must leave without author
            foreach (Bug bug in db.Bugs.Where( p=> p.TesterId == testerId))
            {
                bug.TesterId = null;
            }

            Tester testerToDelete = db.Testers.Single(t => t.TesterId == testerId);
            db.Testers.DeleteOnSubmit(testerToDelete);
            db.SubmitChanges();
        }
コード例 #6
0
        public static void Delete(int projectId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            // delete all project bugs
            foreach (Bug bug in db.Bugs.Where(p => p.ProjectId == projectId))
            {
                db.Bugs.DeleteOnSubmit(bug);
            }

            Project ProjectToDelete = db.Projects.Single(t => t.ProjectId == projectId);
            db.Projects.DeleteOnSubmit(ProjectToDelete);
            db.SubmitChanges();
        }
コード例 #7
0
        public static Project GetProjectByName(string projtectName)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            IQueryable<Project> projects = from p in db.Projects
                          where p.Name == projtectName
                          select p;

            foreach (Project project in projects)
            {
                return project;
            }

            return null;
        }
コード例 #8
0
        public static Tester GetTesterByUsername(string username)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            IQueryable<Tester> testers = from t in db.Testers
                                           where t.Username == username
                                           select t;

            foreach (Tester tester in testers)
            {
                return tester;
            }

            return null;
        }
コード例 #9
0
        public static Project GetProjectByName(string projtectName)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            IQueryable <Project> projects = from p in db.Projects
                                            where p.Name == projtectName
                                            select p;


            foreach (Project project in projects)
            {
                return(project);
            }

            return(null);
        }
コード例 #10
0
        public static IEnumerable<Tester> GetTesters(int page, int pageSize, bool asc, string sortExpression, out int itemsCount)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            int items;
            switch (sortExpression)
            {
                case "SortNumber":
                    var testers = db.Testers.Page(page, pageSize, p => p.TesterId, p => p.Username != "admin", asc, out items);
                    itemsCount = items;
                    return testers;
                case "SortName":
                    testers = db.Testers.Page(page, pageSize, p => p.Name, p => p.Username != "admin", asc, out items);
                    itemsCount = items;
                    return testers;
                case "SortSurname":
                    testers = db.Testers.Page(page, pageSize, p => p.Surname, p => p.Username != "admin", asc, out items);
                    itemsCount = items;
                    return testers;
            }

            itemsCount = 0;
            return null;
        }
コード例 #11
0
        public static void Update(Project project)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            Project projectToUpdate = db.Projects.Single(t => t.ProjectId == project.ProjectId);

            projectToUpdate.Name = project.Name;
            projectToUpdate.Description = project.Description;
            db.SubmitChanges();
        }
コード例 #12
0
        public static int NumberFoundBugs(int testerId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return (from bug in db.Bugs
                    where bug.TesterId == testerId
                    select bug).Count();
        }
コード例 #13
0
        public static int Insert(Tester tester)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            db.Testers.InsertOnSubmit(tester);
            db.SubmitChanges();

            return tester.TesterId;
        }
コード例 #14
0
        public static void Update(Bug bug)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            Bug bugToUpdate = db.Bugs.Single(t => t.BugId == bug.BugId);

            bugToUpdate.Description = bug.Description;
            bugToUpdate.Priority = bug.Priority;
            bugToUpdate.Status = bug.Status;
            db.SubmitChanges();
        }
コード例 #15
0
ファイル: BugsDBManager.cs プロジェクト: tretterd/QA-Academy
        public static IEnumerable<Bug> GetBugsByProjectId(int projectId, int page, int pageSize, bool asc, string sortExpression, bool showClosed, out int itemsCount)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            int items;
            switch (sortExpression)
            {
                case "SortId":
                    if (showClosed)
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.BugId,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                    else
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.BugId,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Closed.ToString(),
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                case "SortOwner":
                    if (showClosed)
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.TesterId,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                    else
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.TesterId,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Closed.ToString(),
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                case "SortPriority":
                    if (showClosed)
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.Priority,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                    else
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.Priority,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Closed.ToString(),
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                case "SortDate":
                    if (showClosed)
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.CreationDate,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                    else
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.CreationDate,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Closed.ToString(),
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                case "SortDescription":
                    if (showClosed)
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.Description,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                    else
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.Description,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Closed.ToString(),
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                case "SortProject":
                    if (showClosed)
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.Project.Name,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                    else
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.Project.Name,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Closed.ToString(),
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                case "SortStatus":
                    if (showClosed)
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.Status,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
                    else
                    {
                        var bugs = db.Bugs.Page(page, pageSize, p => p.Status,
                                                                p => p.ProjectId == projectId,
                                                                p => p.Status != Status.Closed.ToString(),
                                                                p => p.Status != Status.Deleted.ToString(),
                                                                asc, out items);
                        itemsCount = items;
                        return bugs;
                    }
            }

            itemsCount = 0;
            return null;
        }
コード例 #16
0
        public static IEnumerable <Project> GetAllProjects()
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return(db.Projects);
        }
コード例 #17
0
        public static int NumberParticipatingProjects(int testerId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return  (from bug in db.Bugs
                     where bug.TesterId == testerId
                     select bug.ProjectId).Distinct().Count();
        }
コード例 #18
0
        public static IEnumerable <Tester> GetAllTesters()
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return(db.Testers.Where(p => p.Username != "admin"));
        }
コード例 #19
0
        public static Tester GetTesterByTesterId(int testerId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return(db.Testers.Single(t => t.TesterId == testerId));
        }
コード例 #20
0
        public static Bug GetBugByBugId(int bugId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return db.Bugs.Single(t => t.BugId == bugId);
        }
コード例 #21
0
 public static IEnumerable<Project> GetAllProjects()
 {
     DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();
     return db.Projects;
 }
コード例 #22
0
        public static void Update(Tester tester)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            Tester testerToUpdate = db.Testers.Single(t => t.TesterId == tester.TesterId);

            testerToUpdate.Password = tester.Password;
            testerToUpdate.Name = tester.Name;
            testerToUpdate.Surname = tester.Surname;
            testerToUpdate.Phone = tester.Phone;
            testerToUpdate.Email = tester.Email;
            testerToUpdate.LastAction = tester.LastAction;
            db.SubmitChanges();
        }
コード例 #23
0
        public static int Insert(Bug bug)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            db.Bugs.InsertOnSubmit(bug);
            db.SubmitChanges();

            return bug.BugId;
        }
コード例 #24
0
        public static Project GetProjectByProjectId(int projtectId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return db.Projects.Single(t => t.ProjectId == projtectId);
        }
コード例 #25
0
        public static IEnumerable<Tester> GetAllTesters()
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return db.Testers.Where( p => p.Username != "admin");
        }
コード例 #26
0
        public static int Insert(Project project)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            db.Projects.InsertOnSubmit(project);
            db.SubmitChanges();

            return project.ProjectId;
        }
コード例 #27
0
        public static Tester GetTesterByTesterId(int testerId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return  db.Testers.Single(t => t.TesterId == testerId);
        }
コード例 #28
0
ファイル: BugsDBManager.cs プロジェクト: tretterd/QA-Academy
         public static Bug GetBugByBugId(int bugId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return db.Bugs.Single(t => t.BugId == bugId);
        }
コード例 #29
0
        public static Project GetProjectByProjectId(int projtectId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return(db.Projects.Single(t => t.ProjectId == projtectId));
        }