public void SetTaggedUserInPost(IEnumerable <UserLightModel> users, ContributionModel contribution)
 {
     foreach (var user in users)
     {
         var userTaggModel = new ContributionUserTagModel
         {
             ContributionId = contribution.Id,
             UserId         = user.Id,
             User           = user
         };
         this.contributionUserTagRepository.Add(userTaggModel);
     }
 }
Exemple #2
0
        public void Remove_WithExistingContributionUserTag_DoesNotThrow()
        {
            var postModel = new PostModel
            {
                Id                   = 18,
                Title                = "title",
                Content              = "content",
                Date                 = new DateTime(),
                Author               = new UserLightModel(),
                AssociatedFiles      = new List <ContributionFileLightModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                CorrespondingTeam    = new TeamLightModel(),
                Comments             = new List <CommentModel>()
            };

            PostRepositorySUT.Add(postModel);

            var userModel = new UserModel
            {
                Id                   = 19,
                Email                = "email",
                FirstName            = "name",
                LastName             = "surname",
                Password             = "******",
                UserDescription      = "desc",
                ProfilePicture       = new ProfileImageLightModel(),
                MyContributions      = new List <ContributionLightModel>(),
                UserTeams            = new List <UserTeamMemberModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                AdministratedTeams   = new List <TeamLightModel>()
            };

            UserRepositorySUT.Add(userModel);

            var contributionUserTagModel = new ContributionUserTagModel
            {
                ContributionId = postModel.Id,
                UserId         = userModel.Id,
                Contribution   = new PostLightModel(),
                User           = new UserLightModel()
            };

            RepositorySUT.Add(contributionUserTagModel);
            RepositorySUT.Remove(contributionUserTagModel.UserId, contributionUserTagModel.ContributionId);
            var returnedContributionUserTag = RepositorySUT.GetById(contributionUserTagModel.UserId, contributionUserTagModel.ContributionId);

            Assert.Null(returnedContributionUserTag);

            UserRepositorySUT.Remove(userModel.Id);
            PostRepositorySUT.Remove(postModel.Id);
        }
Exemple #3
0
        public ContributionUserTag MapContributionUserTagModelToContributionUserTag(ContributionUserTagModel model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new ContributionUserTag
            {
                ContributionId = model.ContributionId,
                Contribution = MapContributionLightModelToContribution(model.Contribution),
                User = MapUserLightModelToUser(model.User),
                UserId = model.UserId
            });
        }
Exemple #4
0
        public void GetAll_WithExistingContributionUserTag_DoesNotThrow()
        {
            var postModel1 = new PostModel
            {
                Id                   = 12,
                Title                = "title",
                Content              = "content",
                Date                 = new DateTime(),
                Author               = new UserLightModel(),
                AssociatedFiles      = new List <ContributionFileLightModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                CorrespondingTeam    = new TeamLightModel(),
                Comments             = new List <CommentModel>()
            };

            var userModel1 = new UserModel
            {
                Id                   = 13,
                Email                = "email",
                FirstName            = "name",
                LastName             = "surname",
                Password             = "******",
                UserDescription      = "desc",
                ProfilePicture       = new ProfileImageLightModel(),
                MyContributions      = new List <ContributionLightModel>(),
                UserTeams            = new List <UserTeamMemberModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                AdministratedTeams   = new List <TeamLightModel>()
            };

            var returnedPost1 = PostRepositorySUT.Add(postModel1);
            var returnedUser1 = UserRepositorySUT.Add(userModel1);

            var postModel2 = new PostModel
            {
                Id                   = 14,
                Title                = "title",
                Content              = "content",
                Date                 = new DateTime(),
                Author               = new UserLightModel(),
                AssociatedFiles      = new List <ContributionFileLightModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                CorrespondingTeam    = new TeamLightModel(),
                Comments             = new List <CommentModel>()
            };

            var userModel2 = new UserModel
            {
                Id                   = 15,
                Email                = "email",
                FirstName            = "name",
                LastName             = "surname",
                Password             = "******",
                UserDescription      = "desc",
                ProfilePicture       = new ProfileImageLightModel(),
                MyContributions      = new List <ContributionLightModel>(),
                UserTeams            = new List <UserTeamMemberModel>(),
                ContributionUserTags = new List <ContributionUserTagModel>(),
                AdministratedTeams   = new List <TeamLightModel>()
            };

            var returnedPost2 = PostRepositorySUT.Add(postModel2);
            var returnedUser2 = UserRepositorySUT.Add(userModel2);

            var contributionUserTag1Model = new ContributionUserTagModel
            {
                ContributionId = returnedPost1.Id,
                UserId         = returnedUser1.Id,
                Contribution   = new PostLightModel(),
                User           = new UserLightModel()
            };

            var contributionUserTag2Model = new ContributionUserTagModel
            {
                ContributionId = returnedPost2.Id,
                UserId         = returnedUser2.Id,
                Contribution   = new PostLightModel(),
                User           = new UserLightModel()
            };

            var returnedContributionUserTag1 = RepositorySUT.Add(contributionUserTag1Model);
            var returnedContributionUserTag2 = RepositorySUT.Add(contributionUserTag2Model);
            var allContributionUserTags      = RepositorySUT.GetAll();

            Assert.NotNull(returnedContributionUserTag1);
            Assert.NotNull(returnedContributionUserTag2);
            Assert.NotEmpty(allContributionUserTags);

            RepositorySUT.Remove(returnedContributionUserTag1.UserId, returnedContributionUserTag1.ContributionId);
            RepositorySUT.Remove(returnedContributionUserTag2.UserId, returnedContributionUserTag2.ContributionId);
            PostRepositorySUT.Remove(returnedPost1.Id);
            PostRepositorySUT.Remove(returnedPost2.Id);
            UserRepositorySUT.Remove(returnedUser1.Id);
            UserRepositorySUT.Remove(returnedUser2.Id);
        }