Exemplo n.º 1
0
 /// <summary>
 /// map user DTO from his/her user points
 /// </summary>
 ///
 /// <param name="usrInfo">
 /// user score data
 /// </param>
 ///
 /// <returns>
 /// mapped user object
 /// </returns>
 public static UserDTO Map(UserPlaylistInfo usrInfo, FbCookieInfo cookieInfo)
 {
     if (usrInfo ==  null)
     {
         return null;
     }
     var userDto = Mapper.Map<UserPlaylistInfo, UserDTO>(usrInfo);
     userDto.role = null;
     userDto.IsPageAdmin = false;
     return userDto;
 }
Exemplo n.º 2
0
        protected void RewardUser(Playlist playlist,
            UserPlaylistInfo.Operation operation)
        {
            var currentUserInfo = GetUserInfo(playlist, CurrentUser);
            if (currentUserInfo == null)
            {
                return;
            }

            currentUserInfo.UpdateUserScore(operation);
            Repository.SaveOrUpdate(currentUserInfo);
        }
Exemplo n.º 3
0
 public virtual void AddUserInfo(UserPlaylistInfo userInfo)
 {
     if (!UserInfo.Contains(userInfo))
     {
         userInfo.Playlist = this;
         UserInfo.Add(userInfo);
         //and adding the reference to the playlist on the other side as well
         userInfo.User.PlaylistsInfo.Add(userInfo);
     }
 }
Exemplo n.º 4
0
 public virtual UserPlaylistInfo GetUserInfo(FbUser user)
 {
     var usrPlylistInfo = UserInfo.FirstOrDefault(info => info.User == user);
     if (usrPlylistInfo == null && !IsOwner(user.Id)) //admins don't need this connection to the playlist
     {
         usrPlylistInfo = new UserPlaylistInfo
             {
                 NumOfSongsUsed = 0,
                 User = user,
                 Points = 0,
                 LastEntrance = DateTime.Now
             };
         AddUserInfo(usrPlylistInfo);
     }
     return usrPlylistInfo;
 }
Exemplo n.º 5
0
        private void RewardUser(FbUser user,UserPlaylistInfo.Operation options, bool isAdmin = false)
        {
            if (isAdmin || user == null)
            {
                return;
            }

            var userInfo = GetUserInfo(user);
            if (userInfo != null)
            {
                userInfo.UpdateUserScore(options);
            }
        }
Exemplo n.º 6
0
 public virtual void RemoveUserInfo(UserPlaylistInfo userInfo)
 {
     if (!UserInfo.Contains(userInfo))
     {
         userInfo.Playlist = null;
         UserInfo.Add(userInfo);
         userInfo.User.PlaylistsInfo.Remove(userInfo);
     }
 }