예제 #1
0
        public bool AddSong(string url, int profileId)
        {
            DBSong     dbSong     = new DBSong();
            DbActivity dbActivity = new DbActivity();

            using (IDbTransaction tran = DbConnection.GetInstance().BeginTransaction())
            {
                try
                {
                    Song song = dbSong.FindSongByURL(url);
                    if (song != null)
                    {
                        return(false);
                    }

                    int activityId = dbActivity.CreateActivity(profileId);
                    if (activityId > 0 && dbSong.AddSong(GetVideoTitle(url), GetVideoDuration(url), url, activityId) > 0)
                    {
                        tran.Commit();
                        return(true);
                    }
                    else
                    {
                        tran.Rollback();
                        return(false);
                    }
                }
                catch (Exception)
                {
                    tran.Rollback();
                    return(false);
                }
            }
        }
예제 #2
0
 public ChatController()
 {
     dbChat            = new DbChat();
     dbActivity        = new DbActivity();
     profileController = new ProfileController();
     groupController   = new GroupController();
 }
예제 #3
0
 public SongTests()
 {
     dbActivity     = new DbActivity();
     songController = new SongController();
     dbConnection   = DbConnection.GetInstance();
     dbSong         = new DBSong();
 }
예제 #4
0
        /// <summary>
        /// Creates an activity object from id
        /// </summary>
        /// <param name="id">id of activity</param>
        public Activity(int id)
        {
            var dr = DbActivity.GetActivity(id);

            ActivityText = (string)dr["ActivityText"];
            Timestamp    = (DateTime)dr["Timestamp"];
            UserId       = (int)dr["User"];
        }
예제 #5
0
        /// <summary>
        /// returns all activities for user
        /// </summary>
        /// <param name="user">id of user</param>
        /// <returns></returns>
        public static List <Activity> UserActivities(int user)
        {
            var list = new List <Activity>();
            var tb   = DbActivity.UserActivity(user);

            foreach (DataRow row in tb.Rows)
            {
                list.Add(new Activity(row));
            }
            return(list);
        }
예제 #6
0
 public SongTests()
 {
     dbActivity     = new DbActivity();
     songController = new SongController();
     dbSong         = new DBSong();
 }
예제 #7
0
 public PlayListController()
 {
     dbPlayList = new DbPlayList();
     dbActivity = new DbActivity();
 }
예제 #8
0
 /// <summary>
 /// adds an activity for this user
 /// </summary>
 /// <param name="text">text of activity</param>
 public void AddActivity(string text)
 {
     DbActivity.InsertActivity(text, Id);
 }
예제 #9
0
 /// <summary>
 /// adds a new activity to the database
 /// </summary>
 /// <param name="text">activity text</param>
 /// <param name="userId">id of user</param>
 public static void AddActivity(string text, int userId)
 {
     DbActivity.InsertActivity(text, userId);
 }
예제 #10
0
 public GroupController()
 {
     dbGroup           = new DbGroup();
     dbActivity        = new DbActivity();
     profileController = new ProfileController();
 }
예제 #11
0
 public PlayListController()
 {
     dbPlayList = new DbPlayList();
     con        = DbConnection.GetInstance();
     dbActivity = new DbActivity();
 }
예제 #12
0
 public MessageController()
 {
     dbMessage  = new DbMessage();
     dbActivity = new DbActivity();
 }
예제 #13
0
 public PlayListTests()
 {
     playListController = new PlayListController();
     songController     = new SongController();
     dbActivity         = new DbActivity();
 }