private void ImportFirstUser(FriendshipsFriendshipFirstUser user, List <string> existingDbUsernames) { var newUser = new User() { Username = user.Username, FirstName = user.FirstName, LastName = user.LastName, RegistrationDate = user.RegisteredOn, }; var currentUsername = newUser.Username; if (!existingDbUsernames.Contains(currentUsername)) { foreach (var image in user.Images) { var newImage = new Image() { FileExtension = image.FileExtension, ImageUrl = image.ImageUrl, }; newUser.Images.Add(newImage); } db.Users.Add(newUser); existingDbUsernames.Add(currentUsername); //db.SaveChanges(); } }
private static void AddImagesToProfile(UserProfile profile, FriendshipsFriendshipFirstUser firstUser, FriendshipsFriendshipSecondUser secondUser) { dynamic images; if (firstUser == null) { images = secondUser.Images; } else { images = firstUser.Images; } for (int i = 0; i < images.Length; i++) { profile.Images.Add(new Image { FileExtension = images[i].FileExtension, Url = images[i].ImageUrl }); } }