Ejemplo n.º 1
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 {
     }
 }
Ejemplo n.º 2
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 {
     }
 }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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 {
            }
        }
Ejemplo n.º 5
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 {
            }
        }