public RestaurantImagesControllerTests() { this.dbContext = MockDbContext.GetContext(); this.configuration = new ConfigurationBuilder() .AddJsonFile("settings.json") .Build(); this.restaurantImagesRepository = new EfDeletableEntityRepository <RestaurantImage>(this.dbContext); this.restaurantRepository = new EfDeletableEntityRepository <Restaurant>(this.dbContext); this.userRepository = new EfDeletableEntityRepository <ApplicationUser>(this.dbContext); this.voteRepository = new EfRepository <Vote>(this.dbContext); this.commentRepository = new EfDeletableEntityRepository <Comment>(this.dbContext); this.voteService = new VoteService(this.voteRepository); this.commentService = new CommentService(this.commentRepository, this.voteService); this.userImageService = new UserImageService(this.userRepository, this.cloudinaryService); this.cloudinaryService = new CloudinaryImageService(this.configuration); this.restaurantImagesService = new RestaurantImageService(this.restaurantImagesRepository, this.cloudinaryService); this.restaurantService = new RestaurantService(this.restaurantRepository, this.restaurantImagesService, this.commentService); this.userService = new UserService(this.restaurantService, this.userImageService, this.userRepository); var httpContext = new DefaultHttpContext(); var tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>()); this.controller = new RestaurantImagesController(this.restaurantImagesService, this.userService, this.restaurantService) { TempData = tempData, }; }
public CategoryImageService( IDeletableEntityRepository <CategoryImage> imageRepository, ICloudinaryImageService cloudinaryImageService) { this.imageRepository = imageRepository; this.cloudinaryImageService = cloudinaryImageService; }
public UserImageService( IDeletableEntityRepository <ApplicationUser> usersRepository, ICloudinaryImageService imageService) { this.usersRepository = usersRepository; this.imageService = imageService; }
public RestaurantImageService( IDeletableEntityRepository <RestaurantImage> restaurantImageRepository, ICloudinaryImageService cloudinaryImageService) { this.imageRepository = restaurantImageRepository; this.cloudinaryImageService = cloudinaryImageService; }
public CategoriesControllerTests() { this.dbContext = MockDbContext.GetContext(); this.configuration = new ConfigurationBuilder() .AddJsonFile("settings.json") .Build(); this.restaurantImagesRepository = new EfDeletableEntityRepository <RestaurantImage>(this.dbContext); this.categoryImageRepository = new EfDeletableEntityRepository <CategoryImage>(this.dbContext); this.restaurantRepository = new EfDeletableEntityRepository <Restaurant>(this.dbContext); this.categoryRepository = new EfDeletableEntityRepository <Category>(this.dbContext); this.favouriteRepository = new EfRepository <FavouriteRestaurant>(this.dbContext); this.voteRepository = new EfRepository <Vote>(this.dbContext); this.commentRepository = new EfDeletableEntityRepository <Comment>(this.dbContext); this.voteService = new VoteService(this.voteRepository); this.commentService = new CommentService(this.commentRepository, this.voteService); this.cloudinaryService = new CloudinaryImageService(this.configuration); this.restaurantImagesService = new RestaurantImageService(this.restaurantImagesRepository, this.cloudinaryService); this.restaurantService = new RestaurantService(this.restaurantRepository, this.restaurantImagesService, this.commentService); this.categoryImageService = new CategoryImageService(this.categoryImageRepository, this.cloudinaryService); this.categoryService = new CategoryService(this.categoryRepository, this.categoryImageService, this.restaurantService); this.favouriteService = new FavouriteService(this.favouriteRepository); var httpContext = new DefaultHttpContext(); var tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>()); this.controller = new CategoriesController(this.categoryService, this.restaurantService, this.favouriteService) { TempData = tempData, }; AutoMapperConfig.RegisterMappings(typeof(ErrorViewModel).Assembly); }
/// <summary> /// Initializes a new instance of the <see cref="UsersSeeder"/> class. /// </summary> /// <param name="imageService">Image service.</param> public UsersSeeder(ICloudinaryImageService imageService) { this.imageService = imageService; }
private static async Task SeedUserAsync(List <ApplicationUser> usersFromDb, UserManager <ApplicationUser> userManager, string email, string username, string password, string role, string imageUrl, ICloudinaryImageService imageService) { var user = usersFromDb.FirstOrDefault(user => user.Email == email || user.UserName == username); if (user == null) { ApplicationUser userToSignIn = new ApplicationUser() { Email = email, UserName = username, EmailConfirmed = true, }; var image = await imageService.UploadUserImageToCloudinaryAsync(imageUrl); userToSignIn.PublicId = image.PublicId; userToSignIn.ImageUrl = image.ImageUrl; var result = await userManager.CreateAsync(userToSignIn, password); var addToRoleResult = await userManager.AddToRoleAsync(userToSignIn, role); if (!result.Succeeded || !addToRoleResult.Succeeded) { throw new Exception(string.Join(Environment.NewLine, result.Errors.Select(e => e.Description))); } } }
/// <summary> /// Initializes a new instance of the <see cref="CategoryImagesSeeder"/> class. /// </summary> /// <param name="imageService">Image service to upload images in cloud.</param> public CategoryImagesSeeder(ICloudinaryImageService imageService) { this.imageService = imageService; }
/// <summary> /// Initializes a new instance of the <see cref="ApplicationDbContextSeeder"/> class. /// </summary> /// <param name="configuration">appsettings.json.</param> public ApplicationDbContextSeeder(IConfiguration configuration) { this.configuration = configuration; this.imageService = new CloudinaryImageService(this.configuration); }
/// <summary> /// Initializes a new instance of the <see cref="RestaurantImagesSeeder"/> class. /// </summary> /// <param name="imageService">Image service to upload images to cloud.</param> public RestaurantImagesSeeder(ICloudinaryImageService imageService) { this.imageService = imageService; }