Esempio n. 1
0
        public UserDto GetUserByEmailAndPassword(string email, string password, bool includeGroups)
        {
            var user = _userDataProvider.GetUserByEmailAndPassword(email, password);

            if (user == null)
            {
                return(null);
            }

            List <GroupDto> groupDtos = null;

            if (includeGroups && user.UserGroups != null)
            {
                var groups = user.UserGroups.Select(ug => _groupDataProvider.GetGroupById(ug.GroupId)).ToList();
                groupDtos = groups.Select(Mapper.Map <Group, GroupDto>).ToList();
            }

            var userDto = Mapper.Map <User, UserDto>(user);

            userDto.Groups = groupDtos;

            return(userDto);
        }