Exemple #1
0
        /// <summary>
        /// retrieve a list of all widgets using the repository
        /// </summary>
        /// <returns>all widgets</returns>
        private List <Episode> GetAllEpisodes()
        {
            List <Episode> episodes = null;

            FileIoStatus = FileIoMessage.None;

            try
            {
                using (EpisodeRepository eRepository = new EpisodeRepository())
                {
                    episodes = eRepository.GetAll() as List <Episode>;
                };

                if (episodes != null)
                {
                    FileIoStatus = FileIoMessage.Complete;
                }
                else
                {
                    FileIoStatus = FileIoMessage.NoRecordsFound;
                }
            }
            catch (Exception)
            {
                FileIoStatus = FileIoMessage.FileAccessError;
            }

            return(episodes);
        }
Exemple #2
0
        /// <summary>
        /// retrieve a widget using the repository
        /// </summary>
        /// <returns>widget</returns>
        private Episode GetEpisode(int id)
        {
            Episode episode = null;

            FileIoStatus = FileIoMessage.None;

            try
            {
                using (EpisodeRepository eRepository = new EpisodeRepository())
                {
                    episode = eRepository.GetById(id);
                };

                if (episode != null)
                {
                    FileIoStatus = FileIoMessage.Complete;
                }
                else
                {
                    FileIoStatus = FileIoMessage.RecordNotFound;
                }
            }
            catch (Exception)
            {
                FileIoStatus = FileIoMessage.FileAccessError;
            }

            return(episode);
        }
Exemple #3
0
        /// <summary>
        /// add a new widget
        /// </summary>
        /// <param name="widget">widget to add</param>
        public void AddEpisode(Episode episode)
        {
            try
            {
                if (episode != null)
                {
                    using (EpisodeRepository eRepository = new EpisodeRepository())
                    {
                        eRepository.Add(episode);
                    };

                    FileIoStatus = FileIoMessage.Complete;
                }
            }
            catch (Exception)
            {
                FileIoStatus = FileIoMessage.FileAccessError;
            }
        }
Exemple #4
0
        /// <summary>
        /// retrieve a widget by id
        /// </summary>
        /// <param name="id">widget id</param>
        public void DeleteEpisode(int id)
        {
            try
            {
                if (GetEpisode(id) != null)
                {
                    using (EpisodeRepository eRepository = new EpisodeRepository())
                    {
                        eRepository.Delete(id);
                    }

                    FileIoStatus = FileIoMessage.Complete;
                }
                else
                {
                    FileIoStatus = FileIoMessage.RecordNotFound;
                }
            }
            catch (Exception)
            {
                FileIoStatus = FileIoMessage.FileAccessError;
            }
        }
Exemple #5
0
        /// <summary>
        /// update a widget
        /// </summary>
        /// <param name="updatedWidget">updated widget</param>
        public void UpdateEpisode(Episode updatedEpisode)
        {
            try
            {
                if (GetEpisode(updatedEpisode.Id) != null)
                {
                    using (EpisodeRepository repo = new EpisodeRepository())
                    {
                        repo.Update(updatedEpisode);
                    }

                    FileIoStatus = FileIoMessage.Complete;
                }
                else
                {
                    FileIoStatus = FileIoMessage.RecordNotFound;
                }
            }
            catch (Exception)
            {
                FileIoStatus = FileIoMessage.FileAccessError;
            }
        }