Exemple #1
0
        /// <summary>
        /// Converts regular User objects into FilteredUser objects. This will remove all sensitive information from them.
        /// </summary>
        /// <param name="users"></param>
        /// <returns></returns>
        private List <FilteredUser> FilterSensitiveInformation(List <User> users)
        {
            List <FilteredUser> filteredUsers = new List <FilteredUser>(users.Count);

            users.ForEach(x => filteredUsers.Add(FilteredUser.FromUser(x)));
            return(filteredUsers);
        }
Exemple #2
0
 private void ClearOldVoteIfNotMultipleChoice(Question question, FilteredUser user)
 {
     if (question.AllowMultipleVotes == false)
     {
         var oldVotes = user.Votes.Where(v => question.Responses.Any(r => r.Id == v.ResponseId)).ToList();
         oldVotes.ForEach(o => Context.Votes.Remove(o));
     }
 }
Exemple #3
0
        private FilteredUser ConvertFrom_Entity_To_FilteredUser(UserEf entity, FilteredUser model)
        {
            var instance = model ?? new FilteredUser();

            instance.Id       = entity.Id;
            instance.Email    = entity.Email;
            instance.FullName = $"{entity.Name} {entity.LastName}";

            return(instance);
        }
Exemple #4
0
        /// <summary>
        /// Gets the non-sensitive information of the user with the given id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private FilteredUser GetUserInformation(int id)
        {
            var user = context.Users.FirstOrDefault(u => u.Id == id);

            if (user != null)
            {
                return(FilteredUser.FromUser(user));
            }
            else
            {
                throw new UserIdDoesNotExistException();
            }
        }
Exemple #5
0
        private void ClearOldVotesWithMatchingResponseId(FilteredUser user, int responseId)
        {
            var oldVotes = user.Votes.Where(v => v.ResponseId == responseId).ToList();

            oldVotes.ForEach(o => Context.Votes.Remove(o));
        }
Exemple #6
0
        private FilteredUser FetchUserVotes(FilteredUser user)
        {
            var detailedUser = Context.Users.Include(u => u.Votes).ThenInclude(v => v.Response).First(u => user.Id == u.Id);

            return(detailedUser);
        }