/// <summary> /// Удалить выбранную озвучку из списка текущего м/ф /// </summary> private void RemoveVoiceOverFromCartoonList() { var cartoonVoiceOver = CartoonVoiceOvers .First(cvo => cvo.CartoonVoiceOverId == SelectedVoiceOverId); CartoonVoiceOvers.Remove(cartoonVoiceOver); NotifyOfPropertyChange(() => EpisodeVoiceOvers); }
/// <summary> /// Копировать выбранную глобальную озвучку в текущий м/ф /// </summary> public void MoveToCartoonVoiceOvers() { if (CanMoveToCartoonVoiceOvers is false) { return; } if (SelectedVoiceOverId == 0) { throw new Exception("Id выбраной озвучки м/ф равен 0"); } if (CartoonVoiceOvers.Any(cvo => cvo.CartoonVoiceOverId == SelectedVoiceOverId)) { SelectedCartoonVoiceOver = CartoonVoiceOvers .First(cvo => cvo.CartoonVoiceOverId == SelectedVoiceOverId); return; } using (var ctx = new CVDbContext(AppDataPath)) { var cartoon = ctx.Cartoons .Include(c => c.CartoonVoiceOvers) .Single(c => c.CartoonId == IdList.CartoonId); ctx.VoiceOvers .Include(vo => vo.Cartoons) .Single(vo => vo.CartoonVoiceOverId == SelectedVoiceOverId) .Cartoons.Add(cartoon); ctx.SaveChanges(); } var voiceOver = GlobalVoiceOvers.First(vo => vo.CartoonVoiceOverId == SelectedVoiceOverId); CartoonVoiceOvers.Add(voiceOver); NotifyOfPropertyChange(() => EpisodeVoiceOvers); SelectedCartoonVoiceOver = voiceOver; NotifyOfPropertyChange(() => SelectedCartoonVoiceOver); }