Beispiel #1
0
 public bool AddQueue(KaraokeQueue queue)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         var que = db.KaraokeQueues.SingleOrDefault(q => q.Id == queue.Id);
         if (que != null)
         {
             que.DatePlayed  = queue.DatePlayed;
             que.IsCompleted = que.IsCompleted;
         }
         else
         {
             db.KaraokeQueues.Add(queue);
         }
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Beispiel #2
0
        public void UpdateSong(int songId, string title, string singer, int genderId, int vocalTrack, string alpha,
                               string listeningUrl, string watchVideo, string composer, int statusId, string cutline)
        {
            using (var db = new SongContext(_connectionStrings))
            {
                var so = db.Songs.SingleOrDefault(sn => sn.Id == songId);
                if (so == null)
                {
                    return;
                }

                so.Artist           = singer;
                so.Title            = title;
                so.Alpha            = alpha;
                so.ListeningUrl     = listeningUrl;
                so.WatchUrl         = watchVideo;
                so.Gender           = (Gender)genderId;
                so.ModifiedDateTime = DateTime.Now;
                so.VocalTrack       = vocalTrack;
                so.Composer         = composer;
                so.Status           = (Status)statusId;
                so.Cutline          = cutline;
                db.SaveChanges();
            }
        }
Beispiel #3
0
 public void UpdateSong(Song s)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         var so = db.Songs.SingleOrDefault(sn => sn.Id == s.Id);
         if (so != null)
         {
             so.Artist           = s.Artist;
             so.Title            = s.Title;
             so.MusicType        = s.MusicType;
             so.Production       = s.Production;
             so.Mode             = s.Mode;
             so.Gender           = s.Gender;
             so.Lyric            = s.Lyric;
             so.Cutline          = s.Cutline;
             so.VideoQuality     = s.VideoQuality;
             so.Language         = s.Language;
             so.Status           = s.Status;
             so.AlbumName        = s.AlbumName;
             so.ModifiedDateTime = DateTime.Now;
             so.Featured         = s.Featured;
             so.VocalTrack       = s.VocalTrack;
             so.Composer         = s.Composer;
             db.SaveChanges();
         }
     }
 }
Beispiel #4
0
 public void AddFavs(FavoriteSong fav)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         db.FavoriteSongs.Add(fav);
         db.SaveChanges();
     }
 }
Beispiel #5
0
 public void ClearQueue(string machineName)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         var queues = from q in db.KaraokeQueues where q.MachineName == machineName select q;
         db.KaraokeQueues.RemoveRange(queues);
         db.SaveChanges();
     }
 }
Beispiel #6
0
 public void DeleteQueue(int queueId)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         var queue = db.KaraokeQueues.SingleOrDefault(q => q.Id == queueId);
         if (queue != null)
         {
             db.KaraokeQueues.Remove(queue);
             db.SaveChanges();
         }
     }
 }
Beispiel #7
0
 public void DeleteFavs(int favId)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         var fav = db.FavoriteSongs.SingleOrDefault(f => f.Id == favId);
         if (fav != null)
         {
             db.FavoriteSongs.Remove(fav);
             db.SaveChanges();
         }
     }
 }
Beispiel #8
0
 public void PlayedCounter(int songid)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         Song s = db.Songs.SingleOrDefault(so => so.Id == songid);
         if (s != null)
         {
             s.PlayedCount += 1;
             db.SaveChanges();
         }
     }
 }
Beispiel #9
0
        public int AddSong(Song s)
        {
            s.ModifiedDateTime = DateTime.Now;
            s.CreateDateTime   = DateTime.Now;
            using (var db = new SongContext(_connectionStrings))
            {
                db.Songs.Add(s);
                db.SaveChanges();
            }

            return(s.Id);
        }
Beispiel #10
0
 public void Delete(int id)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         var so = db.Zings.SingleOrDefault(s => s.Id == id && s.Status != Status.Delete);
         if (so != null)
         {
             so.Status           = Status.Delete;
             so.ModifiedDateTime = DateTime.Now;
             db.SaveChanges();
         }
     }
 }
Beispiel #11
0
 public void UpdateFilePath(int songid, string path)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         var s = db.Songs.SingleOrDefault(p => p.Id == songid);
         if (s == null)
         {
             return;
         }
         s.FilePath         = path;
         s.ModifiedDateTime = DateTime.Now;
         db.SaveChanges();
     }
 }
Beispiel #12
0
 public void DeleteSong(int songid)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         var s = db.Songs.SingleOrDefault(p => p.Id == songid);
         if (s != null)
         {
             s.Status           = Status.Delete;
             s.ModifiedDateTime = DateTime.Now;
         }
         //db.Songs.DeleteOnSubmit(s);
         db.SaveChanges();
     }
 }
Beispiel #13
0
        public void MarkQueueCompleted(int queueId)
        {
            using (var db = new SongContext(_connectionStrings))
            {
                var queue = db.KaraokeQueues.SingleOrDefault(q => q.Id == queueId);
                if (queue != null)
                {
                    queue.IsCompleted      = true;
                    queue.ModifiedDateTime = DateTime.Now;
                    queue.DatePlayed       = DateTime.Now;

                    db.SaveChanges();
                }
            }
        }
Beispiel #14
0
        public User UserLogin(string user, string password, string machineName)
        {
            using (var db = new SongContext(_connectionStrings))
            {
                var usr = db.Users.SingleOrDefault(u => u.UserName == user && u.Password == password);
                if (usr == null)
                {
                    return(null);
                }

                usr.ModifiedDateTime = DateTime.Now;
                usr.LastMachineName  = machineName;
                db.SaveChanges();

                return(usr);
            }
        }
Beispiel #15
0
 public User RegisterUser(string username, string password)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         if (IsUserNameExisted(username))
         {
             throw new Exception("Username is already existed");
         }
         var user = new User
         {
             Password       = password,
             UserName       = username,
             CreateDateTime = DateTime.Now,
             Role           = Role.Admin
         };
         db.Users.Add(user);
         db.SaveChanges();
         return(user);
     }
 }
Beispiel #16
0
 public void Update(int id, string title, string singer, string alpha, string listenUrl, string watchingVideo, int genderId, string composer, int statusId, string cutline)
 {
     using (var db = new SongContext(_connectionStrings))
     {
         var so = db.Zings.SingleOrDefault(s => s.Id == id && s.Status != Status.Delete);
         if (so == null)
         {
             return;
         }
         so.Alpha            = alpha;
         so.ModifiedDateTime = DateTime.Now;
         so.ListeningUrl     = listenUrl;
         so.Artist           = singer;
         so.Title            = title;
         so.WatchVideo       = watchingVideo;
         so.Gender           = (Gender)genderId;
         so.Composer         = composer;
         so.Status           = (Status)statusId;
         so.Cutline          = cutline;
         db.SaveChanges();
     }
 }