public async Task Add() { if (IsValid()) { if (_update) { if (Film.MediaGenres != null && Film.MediaGenres.Count > 0) { await _genreService.RemoveMediaGenre(Film.MediaGenres); } Film.MediaGenres = new List <MediaGenre>(); Film.MediaGenres.Add(new MediaGenre { Genre = Genres.First(x => x.Nom == Film.Genre.Nom), IdGenre = Genres.First(x => x.Nom == Film.Genre.Nom).Id }); await _filmService.UpdateFilm(Film); NavigationViewModel.Page = NavigationCache.GetPage <Films, FilmsViewModel>(true, NavigationViewModel); } else { Film.MediaGenres = new List <MediaGenre>(); Film.MediaGenres.Add(new MediaGenre { Genre = Genres.First(x => x.Nom == Film.Genre.Nom), IdGenre = Genres.First(x => x.Nom == Film.Genre.Nom).Id }); await _filmService.AddFilm(Film); Film = null; NavigationViewModel.Page = NavigationCache.GetPage <Films, FilmsViewModel>(true, NavigationViewModel); } } }
public async Task Update_ShouldUpdated() { var genre = Genres.First(); var dto = new GenreDto() { Id = genre.Id, Name = "very updated genre name" }; await GenresService.Update(dto.Id, dto); Assert.That(Genres.SingleOrDefault(x => string.Equals(x.Name, dto.Name, StringComparison.CurrentCultureIgnoreCase)), Is.Not.Null); }