private async void OnMoviesWatchedExecute() { if (SelectedMember != null) { SubscriptionsViewModel.Clear(); SubscriptionViewModel subscriptionViewModel; foreach (var subscription in SelectedMember.Subscriptions) { subscriptionViewModel = new SubscriptionViewModel(); Movie movie = null; try { movie = await _movieRepository.GetByIdAsync(subscription.MovieId); } //TODO: A second operation started on this context before a previous operation completed. // This is usually caused by different threads using the same instance of DbContext. catch (Exception) { } // TODO:Bug - add double watch date withou movie if (movie == null) { continue; } subscriptionViewModel.Id = subscription.Id; subscriptionViewModel.Movie = movie; subscriptionViewModel.Member = SelectedMember.Model; subscriptionViewModel.WatchedDate = subscription.WatchedDate; subscriptionViewModel.SelectedMovieDetailsCommand = new DelegateCommand <string>(OnSelectedMovieDetailsExecute); SubscriptionsViewModel.Add(subscriptionViewModel); } } }
private async void OnMembersWatchedExecute() { if (SelectedMovie != null) { SubscriptionsViewModel.Clear(); SubscriptionViewModel subscriptionViewModel; foreach (var subscription in SelectedMovie.Subscriptions) { subscriptionViewModel = new SubscriptionViewModel(); var member = await _memberRepository.GetByIdAsync(subscription.MemberId); subscriptionViewModel.Id = subscription.Id; subscriptionViewModel.Movie = SelectedMovie.Model; subscriptionViewModel.Member = member; subscriptionViewModel.WatchedDate = subscription.WatchedDate; subscriptionViewModel.SelectedMemberDetailsCommand = new DelegateCommand <string>(OnSelectedMemberDetailsExecute); SubscriptionsViewModel.Add(subscriptionViewModel); } } }