Пример #1
0
        private bool IsValidUser(string userName, string password)
        {
            UserRepository repo = new UserRepository();

            int count = repo.GetAll().Where(p => p.Username == userName && p.Password == password).Count();

            if (count == 1) { return true; }

            return false;
        }
Пример #2
0
        /// <summary>
        /// Checks if a user with the same username already exists
        /// in the database.
        /// </summary>
        /// <param name="username">The user to validate.</param>
        /// <returns></returns>
        public bool UserExists(String username)
        {
            UserRepository repo = new UserRepository();

            User userMatch = repo.GetAll().Where(p => p.Username == username).SingleOrDefault();

            if (userMatch != null)
                return true;

            return false;
        }
Пример #3
0
        protected virtual void EnsureRoles()
        {
            UserRepository repo = new UserRepository();
            ProjectRoleRepository projRoleRepo = new ProjectRoleRepository();

            User user = repo.GetAll().Where(p => p.Username == _identity.Name).Single();

            IList<Role> userRoles = new List<Role>();
            IList<ProjectRole> projRoles = projRoleRepo.GetAll().Where(p => p.User.Id == user.Id).ToList();

            foreach (ProjectRole projRole in projRoles)
            {
                if (!userRoles.Contains(projRole.Role))
                    userRoles.Add(projRole.Role);
            }

            _roles = new string[userRoles.Count()];

            for (int i = 0; i < _roles.Length; i++)
            {
                _roles[i] = userRoles[i].RoleName;
            }
        }
Пример #4
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();
        }
Пример #5
0
        public User GetMyUser()
        {
            UserRepository repo = new UserRepository();

            return (User)repo.GetAll().Where(p => p.Username == CustomPrincipal.Current.Identity.Name).SingleOrDefault();
        }