public void Write_file() { // Arrange var io = new ContributionFileIO(); var path = Path.GetTempFileName(); var file = new ContributionFile(new[] { CreateValidRecord(), CreateValidRecord(), CreateValidRecord() }); // Act io.Write(path, file); // Assert Assert.IsTrue(File.Exists(path)); var fi = new FileInfo(path); Assert.IsTrue(fi.Length > 0); var data = File.ReadAllText(path); fi.Delete(); Assert.AreEqual( @"YourFileReference,YourFileDate,ContributionPeriodStartDate,ContributionPeriodEndDate,EmployerID,PayrollID,NameTitle,FamilyName,GivenName,OtherGivenName,NameSuffix,DateOfBirth,Gender,TaxFileNumber,PhoneNumber,MobileNumber,EmailAddress,AddressLine1,AddressLine2,AddressLine3,AddressLine4,Suburb,State,PostCode,Country,EmploymentStartDate,EmploymentEndDate,EmploymentEndReason,FundID,FundName,FundEmployerID,MemberID,EmployerSuperGuaranteeAmount,EmployerAdditionalAmount,MemberSalarySacrificeAmount,MemberAdditionalAmount,OtherContributorType,OtherContributorName,YourContributionReference ,,01-Jan-15,01-Jul-15,,,,Citizen,John,,,01-Jan-90,,,,,,,,,,,,,,,,,ABC123,,,,,,,,,, ,,01-Jan-15,01-Jul-15,,,,Citizen,John,,,01-Jan-90,,,,,,,,,,,,,,,,,ABC123,,,,,,,,,, ,,01-Jan-15,01-Jul-15,,,,Citizen,John,,,01-Jan-90,,,,,,,,,,,,,,,,,ABC123,,,,,,,,,, ", data); }
public void Dollar_amounts_two_decimal_limit_write() { // Arrange var io = new ContributionFileIO(); var stream = new MemoryStream(); var writer = new StreamWriter(stream) { AutoFlush = true }; var file = new ContributionFile(new[] { CreateValidRecord() }); file[0].EmployerSuperGuaranteeAmount = 7890.1234m; file[0].EmployerAdditionalAmount = 1234.5678m; file[0].MemberSalarySacrificeAmount = 9012.3456m; file[0].MemberAdditionalAmount = 3456.789m; // Act io.Write(writer, file); // Assert Assert.IsTrue(writer.BaseStream.Length > 0); stream.Position = 0; var data = new StreamReader(stream).ReadToEnd(); stream.Dispose(); Assert.AreEqual( @"YourFileReference,YourFileDate,ContributionPeriodStartDate,ContributionPeriodEndDate,EmployerID,PayrollID,NameTitle,FamilyName,GivenName,OtherGivenName,NameSuffix,DateOfBirth,Gender,TaxFileNumber,PhoneNumber,MobileNumber,EmailAddress,AddressLine1,AddressLine2,AddressLine3,AddressLine4,Suburb,State,PostCode,Country,EmploymentStartDate,EmploymentEndDate,EmploymentEndReason,FundID,FundName,FundEmployerID,MemberID,EmployerSuperGuaranteeAmount,EmployerAdditionalAmount,MemberSalarySacrificeAmount,MemberAdditionalAmount,OtherContributorType,OtherContributorName,YourContributionReference ,,01-Jan-15,01-Jul-15,,,,Citizen,John,,,01-Jan-90,,,,,,,,,,,,,,,,,ABC123,,,,7890.12,1234.57,9012.35,3456.79,,, ", data); }
public void Write_stream() { // Arrange var io = new ContributionFileIO(); var stream = new MemoryStream(); var writer = new StreamWriter(stream) { AutoFlush = true }; var file = new ContributionFile(new[] { CreateValidRecord(), CreateValidRecord(), CreateValidRecord() }); // Act io.Write(writer, file); // Assert Assert.IsTrue(writer.BaseStream.Length > 0); stream.Position = 0; var data = new StreamReader(stream).ReadToEnd(); stream.Dispose(); Assert.AreEqual( @"YourFileReference,YourFileDate,ContributionPeriodStartDate,ContributionPeriodEndDate,EmployerID,PayrollID,NameTitle,FamilyName,GivenName,OtherGivenName,NameSuffix,DateOfBirth,Gender,TaxFileNumber,PhoneNumber,MobileNumber,EmailAddress,AddressLine1,AddressLine2,AddressLine3,AddressLine4,Suburb,State,PostCode,Country,EmploymentStartDate,EmploymentEndDate,EmploymentEndReason,FundID,FundName,FundEmployerID,MemberID,EmployerSuperGuaranteeAmount,EmployerAdditionalAmount,MemberSalarySacrificeAmount,MemberAdditionalAmount,OtherContributorType,OtherContributorName,YourContributionReference ,,01-Jan-15,01-Jul-15,,,,Citizen,John,,,01-Jan-90,,,,,,,,,,,,,,,,,ABC123,,,,,,,,,, ,,01-Jan-15,01-Jul-15,,,,Citizen,John,,,01-Jan-90,,,,,,,,,,,,,,,,,ABC123,,,,,,,,,, ,,01-Jan-15,01-Jul-15,,,,Citizen,John,,,01-Jan-90,,,,,,,,,,,,,,,,,ABC123,,,,,,,,,, ", data); }
public void Remove(int?id) { using (var dbContext = dbContextFactory.CreateDbContext()) { var entity = new ContributionFile() { Id = id }; dbContext.ContributionFiles.Attach(entity); dbContext.ContributionFiles.Remove(entity); dbContext.SaveChanges(); } }
public void String_data_with_newline_write() { // Arrange var io = new ContributionFileIO(); var stream = new MemoryStream(); var writer = new StreamWriter(stream) { AutoFlush = true }; var file = new ContributionFile(new[] { CreateValidRecord() }); file[0].AddressLine1 = "Address\n Line1"; file[0].AddressLine2 = String.Format("Address{0} Line2", Environment.NewLine); file[0].AddressLine3 = @"Address, Line3"; file[0].AddressLine4 = "Address\n Line4"; file[0].EmployerID = "Employer\nID"; file[0].EmploymentEndReason = "Employment\nEnd\nReason"; file[0].FamilyName = "Family\nName"; file[0].FundEmployerID = "Fund\nEmployer\nID"; file[0].FundID = "Fund\nID"; file[0].FundName = "Fund\nName"; file[0].GivenName = "Given\nName"; file[0].MemberID = "Member\nID"; file[0].MobileNumber = "Mobile\nNumber"; file[0].OtherContributorName = "Other\nContributor\nName"; file[0].OtherGivenName = "Other\nGiven\nName"; file[0].PayrollID = "Payroll\nID"; file[0].PhoneNumber = "Phone\nNumber"; file[0].Suburb = "Suburb\n"; file[0].YourContributionReference = "Your\nContribution\nReference"; file[0].YourFileReference = "Your\nFile\nReference"; // Act io.Write(writer, file); // Assert Assert.IsTrue(writer.BaseStream.Length > 0); stream.Position = 0; var data = new StreamReader(stream).ReadToEnd(); stream.Dispose(); Assert.AreEqual( @"YourFileReference,YourFileDate,ContributionPeriodStartDate,ContributionPeriodEndDate,EmployerID,PayrollID,NameTitle,FamilyName,GivenName,OtherGivenName,NameSuffix,DateOfBirth,Gender,TaxFileNumber,PhoneNumber,MobileNumber,EmailAddress,AddressLine1,AddressLine2,AddressLine3,AddressLine4,Suburb,State,PostCode,Country,EmploymentStartDate,EmploymentEndDate,EmploymentEndReason,FundID,FundName,FundEmployerID,MemberID,EmployerSuperGuaranteeAmount,EmployerAdditionalAmount,MemberSalarySacrificeAmount,MemberAdditionalAmount,OtherContributorType,OtherContributorName,YourContributionReference YourFileReference,,01-Jan-15,01-Jul-15,EmployerID,PayrollID,,FamilyName,GivenName,OtherGivenName,,01-Jan-90,,,PhoneNumber,MobileNumber,,Address Line1,Address Line2,Address Line3,Address Line4,Suburb,,,,,,EmploymentEndReason,FundID,FundName,FundEmployerID,MemberID,,,,,,OtherContributorName,YourContributionReference ", data); }
public ContributionFileModel MapContributionFileToContributionFileModel(ContributionFile contributionFile) { if (contributionFile == null) { return(null); } return(new ContributionFileModel { Id = contributionFile.Id, FileName = contributionFile.FileName, Content = contributionFile.Content, AssociatedContribution = MapContributionToContributionLightModel(contributionFile.AssociatedContribution), FileFormat = contributionFile.FileFormat }); }
public ContributionFileLightModel MapContributionFileToContributionFileLightModel(ContributionFile contributionFile) { if (contributionFile == null) { return(null); } return(new ContributionFileLightModel { Id = contributionFile.Id, FileName = contributionFile.FileName }); }
public void String_data_with_comma_write() { // Arrange var io = new ContributionFileIO(); var stream = new MemoryStream(); var writer = new StreamWriter(stream) { AutoFlush = true }; var file = new ContributionFile(new[] { CreateValidRecord() }); file[0].AddressLine1 = "Address, Line1"; file[0].AddressLine2 = "Address, Line2"; file[0].AddressLine3 = "Address, Line3"; file[0].AddressLine4 = "Address, Line4"; file[0].EmployerID = "Employer,ID"; file[0].EmploymentEndReason = "Employment,End,Reason"; file[0].FamilyName = "Family,Name"; file[0].FundEmployerID = "Fund,Employer,ID"; file[0].FundID = "Fund,ID"; file[0].FundName = "Fund,Name"; file[0].GivenName = "Given,Name"; file[0].MemberID = "Member,ID"; file[0].MobileNumber = "Mobile,Number"; file[0].OtherContributorName = "Other,Contributor,Name"; file[0].OtherGivenName = "Other,Given,Name"; file[0].PayrollID = "Payroll,ID"; file[0].PhoneNumber = "Phone,Number"; file[0].Suburb = "Suburb,"; file[0].YourContributionReference = "Your,Contribution,Reference"; file[0].YourFileReference = "Your,File,Reference"; // Act io.Write(writer, file); // Assert Assert.IsTrue(writer.BaseStream.Length > 0); stream.Position = 0; var data = new StreamReader(stream).ReadToEnd(); stream.Dispose(); Assert.AreEqual( @"YourFileReference,YourFileDate,ContributionPeriodStartDate,ContributionPeriodEndDate,EmployerID,PayrollID,NameTitle,FamilyName,GivenName,OtherGivenName,NameSuffix,DateOfBirth,Gender,TaxFileNumber,PhoneNumber,MobileNumber,EmailAddress,AddressLine1,AddressLine2,AddressLine3,AddressLine4,Suburb,State,PostCode,Country,EmploymentStartDate,EmploymentEndDate,EmploymentEndReason,FundID,FundName,FundEmployerID,MemberID,EmployerSuperGuaranteeAmount,EmployerAdditionalAmount,MemberSalarySacrificeAmount,MemberAdditionalAmount,OtherContributorType,OtherContributorName,YourContributionReference YourFileReference,,01-Jan-15,01-Jul-15,EmployerID,PayrollID,,FamilyName,GivenName,OtherGivenName,,01-Jan-90,,,PhoneNumber,MobileNumber,,Address Line1,Address Line2,Address Line3,Address Line4,Suburb,,,,,,EmploymentEndReason,FundID,FundName,FundEmployerID,MemberID,,,,,,OtherContributorName,YourContributionReference ", data); }
private static void SeedData(TeamsManagerDbContext dbContext) { var defaultAvatarMan = Image.FromFile(@"Images\defaultAvatar.png"); var defaultAvatarWoman = Image.FromFile(@"Images\womanAvatar.png"); var defaultPhoto = Image.FromFile(@"Images\defaultPhoto.png"); ProfileImage imageToUserJames = new ProfileImage { //Id = 1, Content = ConvertImageToByteArray(defaultPhoto), FileName = "Profile James Picture", PictureFormat = SupportedFormatPicture.Png }; ProfileImage imageToUserJane = new ProfileImage { //Id = 2, Content = ConvertImageToByteArray(defaultAvatarWoman), FileName = "Profile Jane Picture", PictureFormat = SupportedFormatPicture.Png }; ProfileImage imageToUserLucas = new ProfileImage { //Id = 3, Content = ConvertImageToByteArray(defaultAvatarMan), FileName = "Profile Lucas Picture", PictureFormat = SupportedFormatPicture.Png }; ProfileImage imageToUserLisa = new ProfileImage { //Id = 4, Content = ConvertImageToByteArray(defaultAvatarWoman), FileName = "Profile Lisa Picture", PictureFormat = SupportedFormatPicture.Png }; ProfileImage imageToUserFleur = new ProfileImage { //Id = 5, Content = ConvertImageToByteArray(defaultAvatarWoman), FileName = "Profile Fleur Picture", PictureFormat = SupportedFormatPicture.Png }; dbContext.ProfileImages.Add(imageToUserJames); dbContext.ProfileImages.Add(imageToUserJane); dbContext.ProfileImages.Add(imageToUserLucas); dbContext.ProfileImages.Add(imageToUserLisa); dbContext.ProfileImages.Add(imageToUserFleur); // User User james = new User { //Id = 1, AdministratedTeams = new List <Team>(), ContributionUserTags = new List <ContributionUserTag>(), Email = "*****@*****.**", FirstName = "James", LastName = "Smith", MyContributions = new List <Contribution>(), Password = hashPassword("james"), Photo = imageToUserJames, UserDescription = "James school account", UserTeams = new List <UserTeamMember>() }; User jane = new User { //Id = 2, AdministratedTeams = new List <Team>(), ContributionUserTags = new List <ContributionUserTag>(), Email = "*****@*****.**", FirstName = "Jane", LastName = "Jones", MyContributions = new List <Contribution>(), Password = hashPassword("jane"), Photo = imageToUserJane, UserDescription = "Jan work account", UserTeams = new List <UserTeamMember>() }; User lucas = new User { //Id = 3, AdministratedTeams = new List <Team>(), ContributionUserTags = new List <ContributionUserTag>(), Email = "*****@*****.**", FirstName = "Lucas", LastName = "Collins", MyContributions = new List <Contribution>(), Password = hashPassword("lucas"), Photo = imageToUserLucas, UserDescription = "Lucas school account", UserTeams = new List <UserTeamMember>() }; User lisa = new User { //Id = 4, AdministratedTeams = new List <Team>(), ContributionUserTags = new List <ContributionUserTag>(), Email = "*****@*****.**", FirstName = "Lisa", LastName = "Evans", MyContributions = new List <Contribution>(), Password = hashPassword("lisa"), Photo = imageToUserLisa, UserDescription = "Lisa teach account", UserTeams = new List <UserTeamMember>() }; User fleur = new User { //Id = 5, AdministratedTeams = new List <Team>(), ContributionUserTags = new List <ContributionUserTag>(), Email = "*****@*****.**", FirstName = "Fleur", LastName = "Smith", MyContributions = new List <Contribution>(), Password = hashPassword("fleur"), Photo = imageToUserFleur, UserDescription = "Fleur school account", UserTeams = new List <UserTeamMember>() }; dbContext.Users.Add(james); dbContext.Users.Add(jane); dbContext.Users.Add(lucas); dbContext.Users.Add(lisa); dbContext.Users.Add(fleur); Team teamIFJ = new Team { //Id = 1, Admin = james, Description = "Team for formal language and compilators (IFJ) project.", Name = "IFJ team", Posts = new List <Post>(), TeamMembers = new List <UserTeamMember>() }; Team teamIAL = new Team { //Id = 2, Admin = jane, Description = "Team for algorithm (IAL) projects.", Name = "IAL team", Posts = new List <Post>(), TeamMembers = new List <UserTeamMember>() }; Team teamWork = new Team { //Id = 3, Admin = lucas, Description = "Team for work project.", Name = "Work team", Posts = new List <Post>(), TeamMembers = new List <UserTeamMember>() }; dbContext.Teams.Add(teamIFJ); dbContext.Teams.Add(teamIAL); dbContext.Teams.Add(teamWork); UserTeamMember jamesToIFJ = new UserTeamMember { Team = teamIFJ, TeamId = teamIFJ.Id, User = james, UserId = james.Id }; UserTeamMember janeToIFJ = new UserTeamMember { Team = teamIFJ, TeamId = teamIFJ.Id, User = jane, UserId = jane.Id }; UserTeamMember fleurToIFJ = new UserTeamMember { Team = teamIFJ, TeamId = teamIFJ.Id, User = fleur, UserId = fleur.Id }; UserTeamMember lisaToIFJ = new UserTeamMember { Team = teamIFJ, TeamId = teamIFJ.Id, User = lisa, UserId = lisa.Id }; UserTeamMember lucasToIFJ = new UserTeamMember { Team = teamIFJ, TeamId = teamIFJ.Id, User = lucas, UserId = lucas.Id }; UserTeamMember janeToIAL = new UserTeamMember { Team = teamIAL, TeamId = teamIAL.Id, User = jane, UserId = jane.Id }; UserTeamMember lisaToIAL = new UserTeamMember { Team = teamIAL, TeamId = teamIAL.Id, User = lisa, UserId = lisa.Id }; UserTeamMember lucasToWork = new UserTeamMember { Team = teamWork, TeamId = teamWork.Id, User = lucas, UserId = lucas.Id }; UserTeamMember lisaToWork = new UserTeamMember { Team = teamWork, TeamId = teamWork.Id, User = lisa, UserId = lisa.Id }; UserTeamMember jamesToWork = new UserTeamMember { Team = teamWork, TeamId = teamWork.Id, User = james, UserId = james.Id }; dbContext.UserTeamMembers.Add(jamesToIFJ); dbContext.UserTeamMembers.Add(janeToIFJ); dbContext.UserTeamMembers.Add(fleurToIFJ); dbContext.UserTeamMembers.Add(lisaToIFJ); dbContext.UserTeamMembers.Add(lucasToIFJ); dbContext.UserTeamMembers.Add(janeToIAL); dbContext.UserTeamMembers.Add(lisaToIAL); dbContext.UserTeamMembers.Add(lucasToWork); dbContext.UserTeamMembers.Add(lisaToWork); dbContext.UserTeamMembers.Add(jamesToWork); Post janePostInIFJ = new Post { //Id = 1, AssociatedFiles = new List <ContributionFile>(), Author = jane, Comments = new List <Comment>(), Content = "I am looking forward to work together!", ContributionUserTags = new List <ContributionUserTag>(), CorrespondingTeam = teamIFJ, Date = new DateTime(2019, 1, 1), Title = "Hello There!" }; Post lucasPostInIFJ = new Post { //Id = 2, AssociatedFiles = new List <ContributionFile>(), Author = lucas, Comments = new List <Comment>(), Content = "Download documentation on private web.", ContributionUserTags = new List <ContributionUserTag>(), CorrespondingTeam = teamIFJ, Date = new DateTime(2019, 2, 1), Title = "Project has been released!" }; Post lisaPostInIAL = new Post { //Id = 3, AssociatedFiles = new List <ContributionFile>(), Author = lisa, Comments = new List <Comment>(), Content = "How are you? I wish we had the recursive tree issue.", ContributionUserTags = new List <ContributionUserTag>(), CorrespondingTeam = teamIAL, Date = new DateTime(2019, 1, 2), Title = "Hello Jane!" }; Post lucasPostInWork = new Post { //Id = 4, AssociatedFiles = new List <ContributionFile>(), Author = lucas, Comments = new List <Comment>(), Content = "Am i last who is waiting for salary?", ContributionUserTags = new List <ContributionUserTag>(), CorrespondingTeam = teamWork, Date = new DateTime(2019, 2, 2), Title = "Salary!" }; Post jamesPostInWork = new Post { //Id = 5, AssociatedFiles = new List <ContributionFile>(), Author = james, Comments = new List <Comment>(), Content = "I am really sorry. I am ill, i cant go to work.", ContributionUserTags = new List <ContributionUserTag>(), CorrespondingTeam = teamWork, Date = new DateTime(2019, 1, 3), Title = "My absence" }; dbContext.Posts.Add(janePostInIFJ); dbContext.Posts.Add(lucasPostInIFJ); dbContext.Posts.Add(lisaPostInIAL); dbContext.Posts.Add(lucasPostInWork); dbContext.Posts.Add(jamesPostInWork); Comment fluerCommentJanePost = new Comment { //Id = 6, AssociatedFiles = new List <ContributionFile>(), Author = fleur, Content = "Hi! :)", ContributionUserTags = new List <ContributionUserTag>(), Date = new DateTime(2019, 1, 2), ParentContribution = janePostInIFJ }; Comment jamesCommentJanePost = new Comment { //Id = 7, AssociatedFiles = new List <ContributionFile>(), Author = james, Content = "Hello!", ContributionUserTags = new List <ContributionUserTag>(), Date = new DateTime(2019, 1, 2), ParentContribution = janePostInIFJ }; Comment lisaCommentJanePost = new Comment { //Id = 8, AssociatedFiles = new List <ContributionFile>(), Author = lisa, Content = "Greetings!", ContributionUserTags = new List <ContributionUserTag>(), Date = new DateTime(2019, 1, 2), ParentContribution = janePostInIFJ }; Comment lucasCommentJanePost = new Comment { //Id = 9, AssociatedFiles = new List <ContributionFile>(), Author = lucas, Content = "Hi!", ContributionUserTags = new List <ContributionUserTag>(), Date = new DateTime(2019, 1, 2), ParentContribution = janePostInIFJ }; Comment lisaCommentLucasPost1 = new Comment { //Id = 10, AssociatedFiles = new List <ContributionFile>(), Author = lisa, Content = "OK", ContributionUserTags = new List <ContributionUserTag>(), Date = new DateTime(2019, 2, 2), ParentContribution = lucasPostInIFJ }; Comment lisaCommentLisaPost = new Comment { //Id = 11, AssociatedFiles = new List <ContributionFile>(), Author = lisa, Content = "<3", ContributionUserTags = new List <ContributionUserTag>(), Date = new DateTime(2019, 1, 2), ParentContribution = lisaPostInIAL }; Comment janeCommentLisaPost = new Comment { //Id = 12, AssociatedFiles = new List <ContributionFile>(), Author = jane, Content = "Me too!", ContributionUserTags = new List <ContributionUserTag>(), Date = new DateTime(2019, 3, 2), ParentContribution = lisaPostInIAL }; Comment lucasCommentJamesPost = new Comment { //Id = 13, AssociatedFiles = new List <ContributionFile>(), Author = lucas, Content = ":(", ContributionUserTags = new List <ContributionUserTag>(), Date = new DateTime(2019, 3, 3), ParentContribution = jamesPostInWork }; Comment lisaCommentLucasPost2 = new Comment { //Id = 14, AssociatedFiles = new List <ContributionFile>(), Author = lisa, Content = "I already have salary.", ContributionUserTags = new List <ContributionUserTag>(), Date = new DateTime(2019, 3, 3), ParentContribution = lucasPostInWork }; Comment jamesCommentLucasPost = new Comment { //Id = 15, AssociatedFiles = new List <ContributionFile>(), Author = james, Content = "I will check it.", ContributionUserTags = new List <ContributionUserTag>(), Date = new DateTime(2019, 3, 4), ParentContribution = lucasPostInWork }; dbContext.Comments.Add(fluerCommentJanePost); dbContext.Comments.Add(jamesCommentJanePost); dbContext.Comments.Add(lisaCommentJanePost); dbContext.Comments.Add(lucasCommentJanePost); dbContext.Comments.Add(lisaCommentLucasPost1); dbContext.Comments.Add(lisaCommentLisaPost); dbContext.Comments.Add(janeCommentLisaPost); dbContext.Comments.Add(lucasCommentJamesPost); dbContext.Comments.Add(lisaCommentLucasPost2); dbContext.Comments.Add(jamesCommentLucasPost); ContributionFile lucasTaskFile = new ContributionFile { //Id = 1, AssociatedContribution = lucasPostInIFJ, Content = new byte[300], FileFormat = SupportedFormatFile.Rar, FileName = "IFJ Basic language" }; ContributionFile janeHelloFile = new ContributionFile { //Id = 2, AssociatedContribution = janePostInIFJ, Content = new byte[300], FileFormat = SupportedFormatFile.Zip, FileName = "IFJ Best practices" }; ContributionFile jamesHelloFile = new ContributionFile { //Id = 3, AssociatedContribution = janePostInIFJ, Content = new byte[300], FileFormat = SupportedFormatFile.Rar, FileName = "IFJ mistakes from last years" }; dbContext.ContributionFiles.Add(lucasTaskFile); dbContext.ContributionFiles.Add(janeHelloFile); dbContext.ContributionFiles.Add(jamesHelloFile); ContributionUserTag janeTagedJames = new ContributionUserTag { UserId = james.Id, User = james, Contribution = janePostInIFJ, ContributionId = janePostInIFJ.Id }; ContributionUserTag lucasTagedFleur = new ContributionUserTag { UserId = fleur.Id, User = fleur, Contribution = lucasPostInIFJ, ContributionId = lucasPostInIFJ.Id }; ContributionUserTag jamesTagedJane = new ContributionUserTag { UserId = jane.Id, User = jane, Contribution = jamesCommentJanePost, ContributionId = jamesCommentJanePost.Id }; ContributionUserTag jamesTagedLucas = new ContributionUserTag { UserId = lucas.Id, User = lucas, Contribution = jamesCommentLucasPost, ContributionId = jamesCommentLucasPost.Id }; ContributionUserTag janeTagedLisa = new ContributionUserTag { UserId = lisa.Id, User = lisa, Contribution = janeCommentLisaPost, ContributionId = janeCommentLisaPost.Id }; dbContext.ContributionUserTags.Add(janeTagedJames); dbContext.ContributionUserTags.Add(lucasTagedFleur); dbContext.ContributionUserTags.Add(jamesTagedJane); dbContext.ContributionUserTags.Add(jamesTagedLucas); dbContext.ContributionUserTags.Add(janeTagedLisa); dbContext.SaveChanges(); }