// GET: Groups/Edit/5 public async Task <IActionResult> EditAsync(int?id) { if (id == null) { return(NotFound()); } var groups = await _servGroups.EditAsync(id); if (groups == null) { return(NotFound()); } return(View(groups)); }
public async Task EditeAsyncWithDublicateNameShouldThrowArgumentException() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var cloudinary = new Mock <ICloudinaryService>(); var concertGroupsRepository = new EfRepository <ConcertGroup>(dbContext); var groupsRepository = new EfDeletableEntityRepository <Group>(dbContext); var groupGenresRepository = new EfRepository <GroupGenre>(dbContext); var usertGroupsRepository = new EfRepository <UserGroup>(dbContext); var groupService = new GroupsService(concertGroupsRepository, groupsRepository, groupGenresRepository, usertGroupsRepository, cloudinary.Object); var photo = new Mock <IFormFile>(); await groupService.CreateAsync("Sabaton", photo.Object, "description"); var id = await groupService.CreateAsync("Nightwish", photo.Object, "description"); var model = new GroupEditInputModel { Name = "Sabaton", Photo = photo.Object, Description = "description", }; await Assert.ThrowsAsync <ArgumentException>(async() => { await groupService.EditAsync(id, model); }); }
public async Task EditAsyncWithCorrectDataShouldReturnCorrectResult() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var cloudinary = new Mock <ICloudinaryService>(); var concertGroupsRepository = new EfRepository <ConcertGroup>(dbContext); var groupsRepository = new EfDeletableEntityRepository <Group>(dbContext); var groupGenresRepository = new EfRepository <GroupGenre>(dbContext); var usertGroupsRepository = new EfRepository <UserGroup>(dbContext); var groupService = new GroupsService(concertGroupsRepository, groupsRepository, groupGenresRepository, usertGroupsRepository, cloudinary.Object); var photo = new Mock <IFormFile>(); var id = await groupService.CreateAsync("Sabaton", photo.Object, "description"); var model = new GroupEditInputModel { Name = "Sabaton", Photo = photo.Object, Description = "other", }; Assert.True(await groupService.EditAsync(id, model)); }