/// <summary> /// Method for seeding the user's images /// </summary> /// <param name="seededUserIds">the seeded users ids</param> private static void SeedUserImages(int[] seededUserIds) { try { string FILE_PATH = ImagesUtil.FILE_PATH; byte[] readDefaultAvatar = File.ReadAllBytes($"{FILE_PATH}/Users/defaultAvatar.jpg"); byte[] readDefaultBg = File.ReadAllBytes($"{FILE_PATH}/Users/defaultBg.jpg"); foreach (var userId in seededUserIds) { ImagesUtil.WriteImageToPath(readDefaultAvatar, $"{FILE_PATH}/Users/{userId}", "/avatar.jpg"); ImagesUtil.WriteImageToPath(readDefaultBg, $"{FILE_PATH}/Users/{userId}", "/background.jpg"); } } catch (Exception e) { Console.WriteLine("Default avatar not found"); } }
/// <summary> /// Method for seeding the posts' images /// </summary> /// <param name="seededPostIds">the seeded posts ids</param> private static void SeedPostImages(int[] seededPostIds) { List <int> postIdIndexesWithImages = new List <int> { 2, 4, 5, 7, 8, 11, 12, 15, 16, 17, 20, 21, 23, 24 }; string FILE_PATH = ImagesUtil.FILE_PATH; byte[] readDefaultPostImage = File.ReadAllBytes($"{FILE_PATH}/Posts/defaultPostImage.jpg"); foreach (var postIdIndexesWithImage in postIdIndexesWithImages) { try { ImagesUtil.WriteImageToPath(readDefaultPostImage, $"{FILE_PATH}/Posts", $"/{seededPostIds[postIdIndexesWithImage]}.jpg"); } catch (Exception e) { Console.WriteLine("Default image could not be written"); } } }