/// <summary> /// Удалить выбранный джампер /// </summary> public void RemoveJumper() { if (CanRemoveJumper is false) { return; } if (HasChangesValidation() is false) { return; } RemoveJumperFromDb(); SelectedJumper = Jumpers.Last(); EditableEpisodeTime = ConvertToEpisodeTime(SelectedEpisodeOption, SelectedJumper); TempEpisodeSnapshot = JsonConvert.SerializeObject(EditableEpisode); TempEpisodeOptionSnapshot = JsonConvert.SerializeObject(SelectedEpisodeOption); NotifyOfPropertyChange(() => Jumpers); NotifyOfPropertyChange(() => SelectedEpisodeOption); NotifyOfPropertyChange(() => CanRemoveJumper); NotifyOfPropertyChange(() => EpisodeDuration); NotifyEditingButtons(); }
/// <summary> /// Добавить новый джампер /// </summary> public void AddJumper() { if (CanAddJumper is false) { return; } if (HasChangesValidation() is false) { return; } var count = Jumpers.Count + 1; var optionId = SelectedEpisodeOption.EpisodeOptionId; var jumper = new Jumper { EpisodeOptionId = optionId, Number = count }; Jumpers.Add(jumper); SelectedEpisodeOption.Jumpers.Add(Jumpers.Last()); AddJumperToDb(jumper); SelectedJumper = Jumpers.Last(); EditableEpisodeTime = ConvertToEpisodeTime(SelectedEpisodeOption, SelectedJumper); TempEpisodeOptionSnapshot = JsonConvert.SerializeObject(SelectedEpisodeOption); NotifyOfPropertyChange(() => Jumpers); NotifyOfPropertyChange(() => SelectedEpisodeOption); NotifyOfPropertyChange(() => CanRemoveJumper); NotifyOfPropertyChange(() => EpisodeDuration); NotifyEditingButtons(); }
/// <summary> /// Добавить новый джампер в БД /// </summary> /// <param name="jumper">добавляемый джампер</param> private void AddJumperToDb(Jumper jumper) { using (var ctx = new CVDbContext(AppDataPath)) { ctx.EpisodeOptions .First(eo => eo.EpisodeOptionId == SelectedEpisodeOption .EpisodeOptionId).Duration = CalculatingDuration(); ctx.Jumpers.Add(jumper); ctx.SaveChanges(); Jumpers.Last().JumperId = ctx.Jumpers.ToList().Last().JumperId; NotifyOfPropertyChange(() => Jumpers); } }
/// <summary> /// Добавить джампер /// </summary> public void AddJumper() { var startTime = Jumpers.Count == 0 ? new TimeSpan() : Jumpers.Last().EndTime + new TimeSpan(1000); var jumper = new Jumper { JumperMode = JumperModes.First(), Number = Jumpers.Count + 1, StartTime = startTime, EndTime = startTime + new TimeSpan(1000), Film = EEVM.ESVM.SelectedFilm, Season = EEVM.ESVM.SelectedSeason, Episode = EEVM.CurrentEpisode, AddressInfo = EEVM.SelectedAddressInfo }; InsertEntityToDb(jumper); Jumpers = new BindableCollection <Jumper>(CurrentAddressInfo.Jumpers); SelectedJumper = Jumpers.LastOrDefault(); }