示例#1
0
        public List <MediaModel> getMediaByCriteria(MediaModel criteriaList)
        {
            //search the database using the criteria in the list provided

            MediaList = new List <MediaModel>();

            try
            {
                //get table of data from Data Access Object
                MediaDataTable = _mediaDAO.GetByCriteria(criteriaList.Title, criteriaList.Director, criteriaList.PublishYear);

                //prepare presentation of data
                foreach (MediaDataSet.TabMediaRow row in MediaDataTable.Rows)
                {
                    MediaList.Add(MediaModel.Parse(row));
                    Console.WriteLine(row.ToString() + ": row added successfully");
                }

                //return list
                return(MediaList);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: No Search Conducted" + ex.Message);
                throw ex;
            }
        }
示例#2
0
 //constructor
 public MediaLogic()
 {
     MediaDAO       = new MediaDataAccessObject();
     MediaList      = new List <MediaModel>();
     MediaDataTable = new MediaDataSet.TabMediaDataTable();
     SelectedMedia  = new MediaModel();
 }
示例#3
0
        public List <MediaModel> ConvertMediaTableToList(MediaDataSet.ViewMediaDataTable mediaTable)
        {
            List <MediaModel> models = new List <MediaModel>();

            foreach (MediaDataSet.ViewMediaRow row in mediaTable.Rows)
            {
                MediaModel model = MediaModel.Parse(row);
                models.Add(model);
            }
            return(models);
        }
示例#4
0
        public List <MediaModel> ListMediaBorrowed()
        {
            List <MediaModel> medias = new List <MediaModel>();

            mediaBorrowedTable = mediaDAO.ListMediaBorrowed();

            foreach (MediaDS.ViewMediaBorrowedRow row in mediaBorrowedTable.Rows)
            {
                MediaModel media = MediaModel.Parse(row);
                medias.Add(media);
            }
            return(medias);
        }
示例#5
0
        public List <MediaModel> ListMediaByLanguage(String language)
        {
            List <MediaModel> medias = new List <MediaModel>();

            mediaTable = mediaDAO.ListMediaByLanguage(language);

            foreach (MediaDS.ViewMediaRow row in mediaTable.Rows)
            {
                MediaModel media = MediaModel.Parse(row);
                medias.Add(media);
            }
            return(medias);
        }
示例#6
0
        public List <MediaModel> ListMediaByDirector(String director)
        {
            List <MediaModel> medias = new List <MediaModel>();

            mediaTable = mediaDAO.ListMediaByDirector(director);

            foreach (MediaDS.ViewMediaRow row in mediaTable.Rows)
            {
                MediaModel media = MediaModel.Parse(row);
                medias.Add(media);
            }
            return(medias);
        }
示例#7
0
        public List <MediaModel> ListMediaByBudget(decimal budget)
        {
            List <MediaModel> medias = new List <MediaModel>();

            mediaTable = mediaDAO.ListMediaByBudget(budget);

            foreach (MediaDS.ViewMediaRow row in mediaTable.Rows)
            {
                MediaModel media = MediaModel.Parse(row);
                medias.Add(media);
            }
            return(medias);
        }
示例#8
0
        //search by genre
        public List <MediaModel> ListMediaGenre(string genre)
        {
            List <MediaModel> medias = new List <MediaModel>();

            mediaTable = mediaDAO.ListMediaByGenre(genre);

            foreach (MediaDS.ViewMediaRow row in mediaTable.Rows)
            {
                MediaModel media = MediaModel.Parse(row);
                medias.Add(media);
            }
            return(medias);
        }
示例#9
0
        public List <MediaModel> ListMediaByPublishYear(int publishYear)
        {
            List <MediaModel> allMedia = new List <MediaModel>();

            mediaTable = mediaDAO.ListMediaByPublishYear(publishYear);

            foreach (MediaDS.ViewMediaRow row in mediaTable.Rows)
            {
                MediaModel media = MediaModel.Parse(row);
                allMedia.Add(media);
            }
            return(allMedia);
        }
示例#10
0
        public List <MediaModel> searchmedaibyMediaID(int MediaID)
        {
            List <MediaModel> medias = new List <MediaModel>();

            mediaTable = mediaDAO.searchmediabyMediaID(MediaID);;

            foreach (MediaDS.ViewMediaRow row in mediaTable.Rows)
            {
                MediaModel media = MediaModel.Parse(row);
                medias.Add(media);
            }
            return(medias);
        }
示例#11
0
        public static MediaModel Parse(MediaDataSet.ViewMediaRow row)
        {
            MediaModel model = new MediaModel();

            model.MediaID      = row.MediaID;
            model.Title        = row.Title;
            model.PublishYear  = row.PublishYear;
            model.GenreName    = row.GenreName;
            model.DirectorName = row.DirectorName;
            model.LanguageName = row.LanguageName;
            model.Budget       = row.Budget;

            return(model);
        }
示例#12
0
        /// <summary>
        /// get data view table from "ViewMediaAvailable"
        /// </summary>
        /// <param name="mediaRow"></param>
        /// <returns></returns>
        public static MediaModel Parse(MediaDS.ViewMediaAvailableRow mediaRow)
        {
            if (mediaRow == null)
            {
                return(null);
            }
            MediaModel media = new MediaModel();

            media.MediaID          = mediaRow.MediaID;
            media.MediaTitle       = mediaRow.Title;
            media.MediaPublishYear = mediaRow.PublishYear;
            media.MediaBudget      = mediaRow.Budget;
            media.MediaDirector    = mediaRow.DirectorName;
            media.MediaGenre       = mediaRow.GenreName;
            media.MediaLanguage    = mediaRow.LanguageName;
            return(media);
        }
示例#13
0
        /// <summary>
        /// Get List of Media by publish year
        /// </summary>
        /// <param name="publishYear"></param>
        /// <returns></returns>
        public List <MediaModel> ListMediaByPublishYear(int publishYear)
        {
            try
            {
                List <MediaModel> medias = new List <MediaModel>();
                mediaTable = mediaDAO.ListMediaByPublishYear(publishYear);

                foreach (MediaDS.ViewMediaRow row in mediaTable.Rows)
                {
                    MediaModel media = MediaModel.Parse(row);
                    medias.Add(media);
                }
                return(medias);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#14
0
        public List <MediaModel> ListMediaAvailbable()
        {
            try
            {
                List <MediaModel> medias = new List <MediaModel>();
                mediaAvailableTable = mediaDAO.ListMediaAvailbable();

                foreach (MediaDS.ViewMediaAvailableRow row in mediaAvailableTable.Rows)
                {
                    MediaModel media = MediaModel.Parse(row);
                    medias.Add(media);
                }
                return(medias);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#15
0
        public List <MediaModel> ListMediaByTitle(String title)
        {
            try
            {
                List <MediaModel> medias = new List <MediaModel>();
                mediaTable = mediaDAO.ListMediaByTitle(title);

                foreach (MediaDS.ViewMediaRow row in mediaTable.Rows)
                {
                    MediaModel media = MediaModel.Parse(row);
                    medias.Add(media);
                }
                return(medias);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#16
0
        public static MediaModel ParseBasic(MediaDataSet.TabMediaRow row)
        {
            if (row == null)
            {
                return(null);
            }

            MediaModel mm = new MediaModel();

            mm.Title       = row.Title;
            mm.Genre       = row.Genre.ToString();
            mm.Director    = row.Director.ToString();
            mm.Language    = row.Language.ToString();
            mm.PublishYear = row.PublishYear;
            mm.Budget      = row.Budget;
            mm.MediaID     = row.MediaID;

            return(mm);
        }
示例#17
0
        public List <MediaModel> getAllMedia()
        {
            MediaList = new List <MediaModel>();

            try
            {
                //get table data from DAO
                MediaDataTable = _mediaDAO.GetMediaAll();

                //prepare presentation of data
                foreach (MediaDataSet.TabMediaRow row in MediaDataTable.Rows)
                {
                    MediaList.Add(MediaModel.Parse(row));
                }

                //return list
                return(MediaList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }