Пример #1
0
 /// <summary>
 /// Remove album from table
 /// </summary>
 /// <param name="id"></param>
 public static void RemoveAlbum(int id)
 {
     try {
         using (var db = new MediaPlayerContext()) {
             AlbumMapper albumMapper = db.AlbumMapper.Single(x => x.Id == id);
             db.AlbumMapper.Remove(albumMapper);
             db.SaveChanges();
         }
     } catch {
     }
 }
Пример #2
0
 /// <summary>
 /// Remove entry
 /// </summary>
 /// <param name="id"></param>
 public static void RemoveMediaData(int id)
 {
     try {
         using (var db = new MediaPlayerContext()) {
             MediaDataMapper mediaDataMapper = db.MediaDataMapper.Single(x => x.Id == id);
             db.MediaDataMapper.Remove(mediaDataMapper);
             db.SaveChanges();
         }
     } catch {
     }
 }
Пример #3
0
 /// <summary>
 /// Update last used time
 /// </summary>
 /// <param name="id"></param>
 public static void UpdateLastUsed(int id)
 {
     try {
         using (var db = new MediaPlayerContext()) {
             AlbumMapper albumMapper = db.AlbumMapper.Single(x => x.Id == id);
             albumMapper.LastUsed = DateTime.Now;
             db.SaveChanges();
         }
     } catch {
     }
 }
Пример #4
0
 /// <summary>
 /// Remove slideshow
 /// </summary>
 /// <param name="id"></param>
 public static void RemoveSlideShow(int id)
 {
     try {
         using (var db = new MediaPlayerContext()) {
             SlideShowMapper slideShowMapper = db.SlideShowMapper.Single(x => x.Id == id);
             db.SlideShowMapper.Remove(slideShowMapper);
             db.SaveChanges();
         }
     } catch {
     }
 }
Пример #5
0
 /// <summary>
 /// Update name of album
 /// </summary>
 /// <param name="id"></param>
 /// <param name="name"></param>
 public static void UpdateName(int id, string name)
 {
     try {
         using (var db = new MediaPlayerContext()) {
             // Get data and update field
             AlbumMapper albumMapper = db.AlbumMapper.Single(x => x.Id == id);
             albumMapper.Name     = name;
             albumMapper.LastUsed = DateTime.Now;
             db.SaveChanges();
         }
     } catch {
     }
 }
Пример #6
0
 /// <summary>
 /// Remove slideshow from album
 /// </summary>
 /// <param name="id"></param>
 /// <param name="slideShowId"></param>
 public static void RemoveSlideShow(int id, int slideShowId)
 {
     try {
         using (var db = new MediaPlayerContext()) {
             // Get data and update field
             SlideShowMapper slideShowMapper = db.SlideShowMapper.Single(x => x.Id == slideShowId);
             AlbumMapper     albumMapper     = db.AlbumMapper.Single(x => x.Id == id);
             albumMapper.SlideShowMappers.Remove(slideShowMapper);
             albumMapper.LastUsed = DateTime.Now;
             db.SaveChanges();
         }
     } catch {
     }
 }
Пример #7
0
 /// <summary>
 /// Update name of slideshow
 /// </summary>
 /// <param name="id"></param>
 /// <param name="name"></param>
 public static void UpdateName(int id, string name)
 {
     try {
         SlideShowMapper slideShowMapper;
         using (var db = new MediaPlayerContext()) {
             // Get data and update field
             slideShowMapper      = db.SlideShowMapper.Single(x => x.Id == id);
             slideShowMapper.Name = name;
             db.SaveChanges();
         }
         AlbumQuery.UpdateLastUsed(slideShowMapper.AlbumMapper.Id);
     } catch {
     }
 }
Пример #8
0
 /// <summary>
 /// Remove mediadata
 /// </summary>
 /// <param name="id"></param>
 /// <param name="mediaDataId"></param>
 public static void RemoveMediaData(int id, int mediaDataId)
 {
     try {
         int albumId = 0;
         using (var db = new MediaPlayerContext()) {
             // Get data and update field
             MediaDataMapper mediaDataMapper = db.MediaDataMapper.Single(x => x.Id == mediaDataId);
             SlideShowMapper slideShowMapper = db.SlideShowMapper.Single(x => x.Id == id);
             slideShowMapper.MediaDataMappers.Remove(mediaDataMapper);
             albumId = slideShowMapper.AlbumMapper.Id;
             db.SaveChanges();
         }
         AlbumQuery.UpdateLastUsed(albumId);
     } catch {
     }
 }
Пример #9
0
        /// <summary>
        /// Add new entry
        /// </summary>
        /// <param name="mediaDataMapper"></param>
        /// <returns></returns>
        public static int NewMediaData(MediaDataMapper mediaDataMapper)
        {
            int id = -1;

            try {
                using (var db = new MediaPlayerContext()) {
                    // Get id (max+1) and add to table
                    id = db.MediaDataMapper.Select(x => x.Id).DefaultIfEmpty(0).Max() + 1;
                    mediaDataMapper.Id = id;
                    db.MediaDataMapper.Add(mediaDataMapper);
                    db.SaveChanges();
                }
            } catch {
            }
            return(id);
        }
Пример #10
0
        /// <summary>
        /// Add slideshow to table
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static int NewSlideShow(string name)
        {
            SlideShowMapper slideShowMapper = new SlideShowMapper(name);
            int             id = -1;

            try {
                using (var db = new MediaPlayerContext()) {
                    // Get id (max+1) and add to table
                    id = db.SlideShowMapper.Select(x => x.Id).DefaultIfEmpty(0).Max() + 1;
                    slideShowMapper.Id = id;
                    db.SlideShowMapper.Add(slideShowMapper);
                    db.SaveChanges();
                }
            } catch {
            }
            return(id);
        }
Пример #11
0
        /// <summary>
        /// Add album to table
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static int NewAlbum(string name, out DateTime lastUsed)
        {
            // create new entity
            AlbumMapper albumMapper = new AlbumMapper(name);
            int         id          = 0;

            try {
                using (var db = new MediaPlayerContext()) {
                    // Get new id (max)+1 and set parameteres
                    id                   = db.AlbumMapper.Select(x => x.Id).DefaultIfEmpty(0).Max() + 1;
                    albumMapper.Id       = id;
                    lastUsed             = DateTime.Now;
                    albumMapper.LastUsed = lastUsed;
                    db.AlbumMapper.Add(albumMapper);
                    db.SaveChanges();
                }
            } catch {
                lastUsed = DateTime.MinValue;
            }
            return(id);
        }
Пример #12
0
        /// <summary>
        /// Returns the key information of the last used album
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        public static void GetLastUsed(ref int id, ref string name)
        {
            AlbumMapper albumMapper;

            try {
                using (var db = new MediaPlayerContext()) {
                    // Order by last used, and set to current time (as it is being used now)
                    albumMapper          = db.AlbumMapper.OrderBy(x => x.LastUsed).FirstOrDefault();
                    albumMapper.LastUsed = DateTime.Now;
                    db.SaveChanges();
                }
                if (albumMapper != null)
                {
                    id   = albumMapper.Id;
                    name = albumMapper.Name;
                    return;
                }
            } catch {
            }
            id   = -1;
            name = string.Empty;
        }
Пример #13
0
        /// <summary>
        /// Change order field
        /// </summary>
        /// <param name="id"></param>
        /// <param name="order"></param>
        public static void UpdateOrder(int id, int order)
        {
            int albumId = 0;

            try {
                using (var db = new MediaPlayerContext()) {
                    // Get data and update field
                    MediaDataMapper mediaDataMapper = db.MediaDataMapper.Single(x => x.Id == id);
                    mediaDataMapper.Order = order;
                    SlideShowMapper slideShowMapper = mediaDataMapper.SlideShowMapper;
                    if (slideShowMapper != null)
                    {
                        albumId = slideShowMapper.AlbumMapper.Id;
                    }
                    db.SaveChanges();
                }
                if (albumId >= 0)
                {
                    AlbumQuery.UpdateLastUsed(albumId);
                }
            } catch {
            }
        }
Пример #14
0
        /// <summary>
        /// Update thumbnail image
        /// </summary>
        /// <param name="id"></param>
        /// <param name="thumbNailImage"></param>
        public static void UpdateThumbNail(int id, byte[] thumbNailImage)
        {
            int albumId = -1;

            try {
                using (var db = new MediaPlayerContext()) {
                    // Get data and update field
                    MediaDataMapper mediaDataMapper = db.MediaDataMapper.Single(x => x.Id == id);
                    mediaDataMapper.ThumbNailImage = thumbNailImage;
                    SlideShowMapper slideShowMapper = mediaDataMapper.SlideShowMapper;
                    if (slideShowMapper != null)
                    {
                        albumId = slideShowMapper.AlbumMapper.Id;
                    }
                    db.SaveChanges();
                }
                if (albumId >= 0)
                {
                    AlbumQuery.UpdateLastUsed(albumId);
                }
            } catch {
            }
        }