public List <MediaDTO> ViewMedia()
        {
            int rowCount = tabMediaTableAdapter.MediaView(tabMedias);

            if (rowCount > 0)
            {
                tabMediaTableAdapter.MediaView(tabMedias);
                foreach (DataRow dr in tabMedias.Rows)
                {
                    MediaDTO mediaDTO = new MediaDTO();

                    try
                    {
                        mediaDTO.MediaID     = Int32.Parse(dr["MediaID"].ToString());
                        mediaDTO.Title       = dr["Title"].ToString();
                        mediaDTO.Genere      = dr["GenreName"].ToString();
                        mediaDTO.Language    = dr["LanguageName"].ToString();
                        mediaDTO.Budget      = decimal.Parse(dr["Budget"].ToString());
                        mediaDTO.PublishYear = Int32.Parse(dr["PublishYear"].ToString());
                        mediaDTO.Director    = dr["DirectorName"].ToString();
                    }
                    catch
                    {
                    }

                    mediaDTOs.Add(mediaDTO);
                }
            }
            return(mediaDTOs);
        }
 public bool DeleteMedia(MediaDTO mediaInput)
 {
     if (mediaInput != null)
     {
         return(RecordManager.DeleteRecord(mediaInput.Translate()));
     }
     return(false);
 }
        public MediaDTO ChangeMedia(MediaDTO media)
        {
            string   field;
            object   newValue;
            MediaDTO oldMedia = new MediaDTO(RecordManager.FindByID(media.MediaID));

            if (media.Title != oldMedia.Title)
            {
                field    = "Title";
                newValue = media.Title;
                RecordManager.ChangeRecord(media.Translate(), field, newValue);
            }
            if (media.Genre.GID != oldMedia.Genre.GID)
            {
                field    = "Title";
                newValue = media.Title;
                RecordManager.ChangeRecord(media.Translate(), field, newValue);
            }
            if (media.Title != oldMedia.Title)
            {
                field    = "Title";
                newValue = media.Title;
                RecordManager.ChangeRecord(media.Translate(), field, newValue);
            }
            if (field == "Genre" && newValue is int)
            {
                RecordManager.ChangeRecord(media.Translate(), field, newValue);
                media.Genre.GID = ((int)newValue);
            }
            if (field == "Director" && newValue is int)
            {
                RecordManager.ChangeRecord(media.Translate(), field, newValue);
                media.Director.DID = ((int)newValue);
            }
            if (field == "Language" && newValue is int)
            {
                RecordManager.ChangeRecord(media.Translate(), field, newValue);
                media.Language.LID = ((int)newValue);
            }
            if (field == "Year" && newValue is int)
            {
                RecordManager.ChangeRecord(media.Translate(), field, newValue);
                media.Year = ((int)newValue);
            }
            if (field == "Budget" && newValue is decimal)
            {
                RecordManager.ChangeRecord(media.Translate(), field, (decimal)newValue / 1000000);
                media.SetBudget((decimal)newValue);
            }
            return(media);
        }
        public List <MediaDTO> viewMediaByValue(string value, string column)
        {
            List <MediaDTO> allBooks = new List <MediaDTO>();
            int             rowCount = 0;

            if (column == "Title")
            {
                rowCount = tabMediaTableAdapter.TitleBrowse(tabMedias, value);
            }
            else if (column == "DirectorName")
            {
                rowCount = tabMediaTableAdapter.DirectorBrowse(tabMedias, value);
            }
            else if (column == "Genre")
            {
                rowCount = tabMediaTableAdapter.GenreBrowse(tabMedias, value);
            }
            else
            {
                rowCount = tabMediaTableAdapter.MediaView(tabMedias);
            }
            if (rowCount > 0)
            {
                foreach (DataRow r in tabMedias)
                {
                    MediaDTO book = new MediaDTO();
                    book.MediaID     = int.Parse(r["MediaID"].ToString());
                    book.Title       = r["Title"].ToString();
                    book.PublishYear = int.Parse(r["PublishYear"].ToString());
                    book.Language    = r["LanguageName"].ToString();
                    book.Budget      = decimal.Parse(r["Budget"].ToString());
                    book.Director    = r["DirectorName"].ToString();
                    book.Genere      = r["GenreName"].ToString();
                    allBooks.Add(book);
                }
            }
            return(allBooks);
        }
 public MediaDTO CreateMedia(MediaDTO mediaInput)
 {
     return(new MediaDTO(RecordManager.AddRecord(mediaInput.Translate())));
 }