Exemplo n.º 1
0
        public IList <Bug> SearchAllProjectBugsAttributes(Project project, string searchText)
        {
            searchText = searchText.Trim();

            // if (searchText == null || searchText == "")
            //   return GetBugsByProject(project);

            IList <int> associatedUserIds = new UserRepository().GetAll().FullTextSearch(searchText, true).Select(p => p.Id).ToList();
            IList <int> fullTextSearch    = new BugRepository().GetAll().FullTextSearch(searchText, true).Select(p => p.Id).ToList();

            if (associatedUserIds.Count == 0 && fullTextSearch.Count == 0)
            {
                return(new List <Bug>());
            }

            int      id   = 0;
            DateTime date = DateTime.MinValue;

            try { id = Int32.Parse(searchText); }
            catch (Exception e) { Console.WriteLine(e.Message); }

            try { date = DateTime.Parse(searchText); }
            catch (Exception e) { Console.WriteLine(e.Message); }


            return(new BugRepository().GetAll()
                   .Where(p => associatedUserIds.Contains(p.AssignedUser.Id) ||
                          associatedUserIds.Contains(p.CreatedBy.Id) ||
                          p.Id == id ||
                          (p.DateFound.Year == date.Year && p.DateFound.Month == date.Month && p.DateFound.Day == date.Day) ||
                          (p.LastModified.Year == date.Year && p.LastModified.Month == date.Month && p.LastModified.Day == date.Day) ||
                          fullTextSearch.Contains(p.Id)).Where(p => p.Project.Id == project.Id).ToList());
        }