private void OnSaveEpisode(object parameter) { switch (_operationStatus) { case OperationStatus.ADD: if (_detailedViewEpisode != null) { // // adding episode in persistence // _episodeBusiness.AddEpisode(_detailedViewEpisode); // // add episode to list // _episodes.Add(DetailedViewEpisode); // // seting selected episode as new episode // SelectedEpisode = DetailedViewEpisode; } break; case OperationStatus.EDIT: Episode episodeToUpdate = _episodes.FirstOrDefault(c => c.Id == SelectedEpisode.Id); if (episodeToUpdate != null) { Episode updatedEpisode = DetailedViewEpisode; // // update episode in persistence // _episodeBusiness.UpdateEpisode(updatedEpisode); // //update episode in list // _episodes.Remove(episodeToUpdate); _episodes.Add(updatedEpisode); // // setting selected episode as property // SelectedEpisode = updatedEpisode; } break; default: break; } IsEditingAdding = false; ShowAddEditDeleteButtons = true; _operationStatus = OperationStatus.NONE; }
private void AddEpisode(object parameter) { _episodeOperation.Status = EpisodeOperation.OperationStatus.OKAY; EpisodeRepository episodeRepository = new EpisodeRepository(); List <Episode> episodes = new List <Episode>(episodeRepository.GetAll()); NewEpisode.Id = (episodes.Count() + 1); EpisodeBusiness episodeBusiness = new EpisodeBusiness(); episodeBusiness.AddEpisode(NewEpisode); if (parameter is System.Windows.Window) { (parameter as System.Windows.Window).Close(); } }