BB.BL.PlaylistManager.CreatePlaylistForUser C# (CSharp) Method

CreatePlaylistForUser() public method

public CreatePlaylistForUser ( string name, string description, string key, int maxVotesPerUser, bool active, string imageUrl, User createdBy ) : Playlist
name string
description string
key string
maxVotesPerUser int
active bool
imageUrl string
createdBy BB.BL.Domain.Users.User
return BB.BL.Domain.Playlists.Playlist
        public Playlist CreatePlaylistForUser(string name, string description, string key, int maxVotesPerUser, bool active, string imageUrl, User createdBy)
        {
            if (maxVotesPerUser.Equals(null))
            {
                maxVotesPerUser = -1;
            }
            var playlist = new Playlist
            {
                Name = name,
                Description = description,
                Key = key,
                MaximumVotesPerUser = maxVotesPerUser,
                Active = active,
                ImageUrl = imageUrl,
                CreatedById = createdBy.Id,
                ChatComments = new List<Comment>(),
                Comments = new List<Comment>(),
                PlaylistTracks = new List<PlaylistTrack>()
            };
            return repo.CreatePlaylist(playlist);
        }

Usage Example

        public void Initialize()
        {
           
            playlistManager = new PlaylistManager(new PlaylistRepository(new EFDbContext(ContextEnum.BeatBuddyTest)), new UserRepository(new EFDbContext(ContextEnum.BeatBuddyTest)));
            userManager = new UserManager(new UserRepository(new EFDbContext(ContextEnum.BeatBuddyTest)));
            organisationManager = new OrganisationManager(new OrganisationRepository(new EFDbContext(ContextEnum.BeatBuddyTest)));
            _userWithOrganisation = userManager.CreateUser("*****@*****.**", "matthias", "test", "acidshards", "");
            _userWithoutOrganisation = userManager.CreateUser("*****@*****.**", "heylen", "jos", "acidshards", "");

            playlist = playlistManager.CreatePlaylistForUser("testplaylist", "gekke playlist om te testen", "125", 5, true, "", _userWithOrganisation);
            _userControllerWithAuthenticatedUserWithOrganisation = MyWebApi.Controller<UserController>()
                .WithResolvedDependencyFor<PlaylistManager>(playlistManager)
                .WithResolvedDependencyFor<UserManager>(userManager)
                .WithResolvedDependencyFor<OrganisationManager>(organisationManager)
                .WithAuthenticatedUser(
                 u => u.WithIdentifier("NewId")
                       .WithUsername(_userWithOrganisation.Email)
                       .WithClaim(new System.Security.Claims.Claim(System.Security.Claims.ClaimTypes.Email, _userWithOrganisation.Email))
                       .WithClaim(new System.Security.Claims.Claim("sub", _userWithOrganisation.Email))
                );

            _userControllerWithAuthenticatedUserWithoutOrganisation = MyWebApi.Controller<UserController>()
                .WithResolvedDependencyFor<PlaylistManager>(playlistManager)
                .WithResolvedDependencyFor<UserManager>(userManager)
                .WithResolvedDependencyFor<OrganisationManager>(organisationManager)
                .WithAuthenticatedUser(
                 u => u.WithIdentifier("NewId")
                       .WithUsername(_userWithOrganisation.Email)
                       .WithClaim(new System.Security.Claims.Claim(System.Security.Claims.ClaimTypes.Email, _userWithoutOrganisation.Email))
                       .WithClaim(new System.Security.Claims.Claim("sub", _userWithoutOrganisation.Email))
                );

            Track track = new Track()
            {
                Artist = "Metallica",
                Title = "Master of Puppets (live)",
                CoverArtUrl = "",
                Duration = 800,
                TrackSource = new TrackSource
                {
                    SourceType = SourceType.YouTube,
                    Url = "https://www.youtube.com/watch?v=kV-2Q8QtCY4"
                }
            };
            Track addedtrack = playlistManager.AddTrackToPlaylist(playlist.Id, track);


            organisation = organisationManager.CreateOrganisation("gek organisatie test","",_userWithOrganisation);
        }