Inheritance: System.Data.Linq.DataContext
        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;
            }
        }
        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();
        }
 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;
 }
        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;
        }
        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();
        }
        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();
        }
        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;
        }
        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;
        }
        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);
        }
        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;
        }
        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();
        }
        public static int NumberFoundBugs(int testerId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return (from bug in db.Bugs
                    where bug.TesterId == testerId
                    select bug).Count();
        }
        public static int Insert(Tester tester)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

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

            return tester.TesterId;
        }
        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();
        }
Beispiel #15
0
        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;
        }
        public static IEnumerable <Project> GetAllProjects()
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return(db.Projects);
        }
        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();
        }
Beispiel #18
0
        public static IEnumerable <Tester> GetAllTesters()
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

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

            return(db.Testers.Single(t => t.TesterId == testerId));
        }
        public static Bug GetBugByBugId(int bugId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return db.Bugs.Single(t => t.BugId == bugId);
        }
 public static IEnumerable<Project> GetAllProjects()
 {
     DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();
     return db.Projects;
 }
        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();
        }
        public static int Insert(Bug bug)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

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

            return bug.BugId;
        }
        public static Project GetProjectByProjectId(int projtectId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return db.Projects.Single(t => t.ProjectId == projtectId);
        }
        public static IEnumerable<Tester> GetAllTesters()
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return db.Testers.Where( p => p.Username != "admin");
        }
        public static int Insert(Project project)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

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

            return project.ProjectId;
        }
        public static Tester GetTesterByTesterId(int testerId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return  db.Testers.Single(t => t.TesterId == testerId);
        }
Beispiel #28
0
         public static Bug GetBugByBugId(int bugId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

            return db.Bugs.Single(t => t.BugId == bugId);
        }
        public static Project GetProjectByProjectId(int projtectId)
        {
            DataClassesBugTrackingSystemDataContext db = new DataClassesBugTrackingSystemDataContext();

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