/*[PrincipalPermission(SecurityAction.Demand, Role = "ADMIN")]*/
        public void DeleteBug(Bug bug)
        {
            BugRepository repo = new BugRepository();
            repo.Delete(bug);

            BugActionLogger.LogEvent(bug.Project, GetMyUser(), BugActionLogger.Delete_Action, bug);
        }
        public Bug AddBug(Bug bug)
        {
            bug.DateFound = DateTime.Now;
            bug.LastModified = DateTime.Now;

            var savedbug = new BugRepository().Create(bug);

            BugActionLogger.LogEvent(bug.Project, GetMyUser(), BugActionLogger.Create_Action, savedbug);

            return savedbug;
        }
        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();
        }
        public Bug SaveBug(Bug bug)
        {
            bug.LastModified = DateTime.Now;

            BugRepository bugRepo = new BugRepository();

            var savedbug = bugRepo.Update(bug);

            BugActionLogger.LogEvent(bug.Project, GetMyUser(), BugActionLogger.Update_Action, savedbug);

            return bug;
        }
        public List<Bug> GetBugsByProject(Project project)
        {
            BugRepository bugRepo = new BugRepository();

            List<Bug> bugList = bugRepo.GetAll().Where(x => x.Project.Id == project.Id).ToList();

            return bugList;
        }
        public List<Bug> GetAllBugs()
        {
            BugRepository repo = new BugRepository();
            List<Bug> bugList = repo.GetAll().ToList();

            return bugList;
        }