Example #1
0
        public async Task <UserProfileResponseModel> GetAuthenticatedUserProfile(string userId)
        {
            User user = await _userRepository.GetByIdIncludingImage(Guid.Parse(userId));

            ThrowIfUserIsNullOrNotConfirmed(user);
            string imageUrl = _fileUploadUtils.GenerateImageUrl(user.ProfileImage.FileName);

            return(new UserProfileResponseModel()
            {
                Email = user.Email, Name = user.Name, Image = imageUrl
            });
        }
Example #2
0
        public void ShouldConvertUserToUserProfileResponseModel()
        {
            User         user         = new User(Guid.NewGuid(), "name", "*****@*****.**", "password");
            ProfileImage profileImage = new ProfileImage("filename", "filepath");

            user.AddProfileImage(profileImage);
            _fileUploadUtilsMock.GenerateImageUrl(Arg.Any <string>()).Returns("imageurl");

            UserProfileResponseModel responseModel = _converter.ConvertUserToUserProfileResponseModel(user);

            Assert.Equal(user.Name, responseModel.Name);
            Assert.Equal(user.Email, responseModel.Email);
            Assert.Equal("imageurl", responseModel.Image);
        }
Example #3
0
        public ReviewResponseModel ConvertReviewToReviewResponseModel(Review review)
        {
            string reviewImageUrl = _fileUploadUtils.GenerateImageUrl(review.Image.FileName);

            return(new ReviewResponseModel()
            {
                Id = review.Id,
                Image = reviewImageUrl,
                Creator = review.Creator.Name,
                Stars = review.Stars,
                Text = review.Text,
                Title = review.Title
            });
        }