public static List<Bug> ListAllBugs() { BugTrackerEntities db = new BugTrackerEntities(); var bugs = db.Bugs.Where( x => x.Status != "Deleted" && x.Status != "Closed"); return bugs.ToList(); }
public static UserProfile SelectUserById(int userId) { BugTrackerEntities db = new BugTrackerEntities(); UserProfile user = db.UserProfiles.Find(userId); return user; }
public static List<UserProfile> ListAllUserProfiles() { BugTrackerEntities db = new BugTrackerEntities(); List<UserProfile> list = db.UserProfiles.ToList(); return list; }
public static List<Bug> ListBugsByProjectId(int projectId) { BugTrackerEntities db = new BugTrackerEntities(); var bugs = db.Bugs.Where(x => x.Status != "Deleted" && x.Status != "Closed" && x.ProjectId == projectId); return bugs.ToList(); }
public static void AddProject(string projectName, string description) { BugTrackerEntities db = new BugTrackerEntities(); Project pr = new Project { ProjectName = projectName, Description = description }; db.Projects.Add(pr); db.SaveChanges(); }
public static void RemoveUserInfoCard(int userId) { BugTrackerEntities db = new BugTrackerEntities(); InfoCard iCard = db.InfoCards.Find( userId ); db.InfoCards.Remove(iCard); db.SaveChanges(); }
public static Bug GetBugById(int bugId) { BugTrackerEntities db = new BugTrackerEntities(); Bug bug = db.Bugs.Find(bugId); if (bug.Status == "Deleted") { return null; } return bug; }
public static void RemoveBug(int bugId) { BugTrackerEntities db = new BugTrackerEntities(); Bug bug = db.Bugs.Find(bugId); bug.Status = "Deleted"; db.Entry(bug).State = EntityState.Modified; db.SaveChanges(); }
public static void UpdateInfoCardDescription(int iCardId, string description) { BugTrackerEntities db = new BugTrackerEntities(); InfoCard iCard = db.InfoCards.Find(iCardId); iCard.LastActivity = DateTime.Now; iCard.LastAction = description; db.Entry(iCard).State = EntityState.Modified; db.SaveChanges(); }
public static void UpdateBugInfoCard(int userId, int bugId, string action) { BugTrackerEntities db = new BugTrackerEntities(); InfoCard iCard = db.InfoCards.Find(userId); iCard.LastActivity = DateTime.Now; iCard.LastAction = action + " bug #" + bugId; db.Entry(iCard).State = EntityState.Modified; db.SaveChanges(); }
public static void UpdateBug(int bugId, string priority, string status, string description) { BugTrackerEntities db = new BugTrackerEntities(); Bug bug = db.Bugs.Find(bugId); bug.Priority = priority; bug.Status = status; bug.Description = description; db.Entry(bug).State = EntityState.Modified; db.SaveChanges(); }
public static void UpdateUser(int userId, string email, string firstName, string lastName, string phoneNumber) { BugTrackerEntities db = new BugTrackerEntities(); UserProfile user = db.UserProfiles.Find(userId); user.Email = email; user.FirstName = firstName; user.LastName = lastName; user.PhoneNumber = phoneNumber; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); }
public static void RemoveUserFromBugs(int userId) { BugTrackerEntities db = new BugTrackerEntities(); IQueryable<Bug> bugs = db.Bugs.Where(x => x.UserId == userId); foreach (var bug in bugs) { bug.UserId = null; db.Entry(bug).State = EntityState.Modified; } db.SaveChanges(); }
public static void AddUserInfoCard(int userId) { BugTrackerEntities db = new BugTrackerEntities(); InfoCard iCard = new InfoCard { UserProfile = db.UserProfiles.Find(userId), NumberOfBugs = 0, NumberOfProjects = 0, LastActivity = DateTime.Now, LastAction = "Registration of the Tester." }; db.InfoCards.Add(iCard); db.SaveChanges(); }
public static void RemoveProject(int projectId) { BugTrackerEntities db = new BugTrackerEntities(); Project project = db.Projects.Find(projectId); IQueryable<Bug> bugs = db.Bugs.Where(x => x.ProjectId == projectId); foreach (var bug in bugs) { db.Bugs.Remove(bug); } db.Projects.Remove(project); db.SaveChanges(); }
public static bool ProjectExists(int id, string projectName) { BugTrackerEntities db = new BugTrackerEntities(); Project project = db.Projects.FirstOrDefault(x => x.ProjectName == projectName); if (project != null) { return project.ProjectId != id; } else { return false; } }
public static void AddBug(int userId, int projectId, string priority, string status, DateTime discoverDate, string description) { BugTrackerEntities db = new BugTrackerEntities(); UserProfile user = db.UserProfiles.FirstOrDefault(x => x.UserId == userId); Project project = db.Projects.FirstOrDefault(x => x.ProjectId == projectId); db.Bugs.Add(new Bug { UserProfile = user, Project = project, Priority = priority, Status = status, DiscoverDate = discoverDate, Description = description }); db.SaveChanges(); }
public static void AddBugToInfoCard(int userId, int projectId) { BugTrackerEntities db = new BugTrackerEntities(); InfoCard iCard = db.InfoCards.Find(userId); Project project = db.Projects.Find(projectId); if (!iCard.Projects.Contains(project)) { iCard.NumberOfProjects += 1; iCard.Projects.Add(project); } iCard.NumberOfBugs += 1; iCard.LastActivity = DateTime.Now; iCard.LastAction = "Added new bug for project \"" + project.ProjectName + "\""; db.Entry(iCard).State = EntityState.Modified; db.SaveChanges(); }
public static List<Project> SearchProjects(string filter) { if (filter == "") { return ListAllProjects(); } BugTrackerEntities db = new BugTrackerEntities(); return db.Projects.Where(x => x.ProjectName.ToLower().Contains(filter.ToLower())).ToList(); }
public static Project FindProject(int id) { BugTrackerEntities db = new BugTrackerEntities(); return db.Projects.Find(id); }
public static int GetProjectId(string projectName) { BugTrackerEntities db = new BugTrackerEntities(); Project project = db.Projects.FirstOrDefault(x => x.ProjectName == projectName); return (project != null) ? project.ProjectId : 0; }
public static int GetUserId(string userName) { BugTrackerEntities db = new BugTrackerEntities(); UserProfile profile = db.UserProfiles.FirstOrDefault(x => x.UserName == userName); return profile.UserId; }
public static List<Project> ListAllProjects() { BugTrackerEntities db = new BugTrackerEntities(); return db.Projects.ToList(); }
public static bool ProjectExists(string projectName) { BugTrackerEntities db = new BugTrackerEntities(); return db.Projects.Any(x => x.ProjectName == projectName); }
public static bool UserExists(string userName) { BugTrackerEntities db = new BugTrackerEntities(); return db.UserProfiles.Any(x => x.UserName == userName); }
public static void UpdateProject(int projectId, string projectName, string description) { BugTrackerEntities db = new BugTrackerEntities(); Project project = db.Projects.Find(projectId); project.ProjectName = projectName; project.Description = description; db.Entry(project).State = EntityState.Modified; db.SaveChanges(); }