Example #1
0
        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;
        }
Example #2
0
        public void EditEpisode(object parameter)
        {
            //
            // TODO - validate user inputs
            //
            EpisodeBusiness episodeBusiness = new EpisodeBusiness();

            episodeBusiness.UpdateEpisode(UserEpisode);
            _episodeOperation.Status = EpisodeOperation.OperationStatus.OKAY;

            if (parameter is System.Windows.Window)
            {
                (parameter as System.Windows.Window).Close();
            }
        }