public ActionResult View(string key) { if (User != null) { user = userManager.ReadUser(User.Identity.Name); } var playlist = playlistManager.ReadPlaylistByKey(key); var votesUser = playlistManager.ReadVotesForUser(user); var organisation = organisationManager.ReadOrganisationForPlaylist(playlist.Id); var playlistOwners = new List<User>(); if (organisation != null) { playlistOwners = userManager.ReadCoOrganiserFromOrganisation(organisation).ToList(); playlistOwners.Add(userManager.ReadOrganiserFromOrganisation(organisation)); } else { if (playlist.CreatedById != null) { playlistOwners.Add(userManager.ReadUser((long)playlist.CreatedById)); } } ViewBag.Organisation = organisationManager.ReadOrganisationForPlaylist(playlist.Id); ViewBag.CurrentUser = user; ViewBag.Organisers = playlistOwners; ViewBag.VotesUser = votesUser; ViewBag.PlaylistId = playlist.Id; ViewBag.PlaylistKey = playlist.Key; ViewBag.HistoryCount = playlist.PlaylistTracks.Count(t => t.PlayedAt != null); playlist.PlaylistTracks = playlist.PlaylistTracks.Where(t => t.PlayedAt == null).ToList(); return View(playlist); }
public UserRole CreateUserRole(User user, Organisation organisation, Role role) { UserRole userRole = new UserRole() { User = user, Organisation = organisation, Role = role }; return repo.CreateUserRole(userRole); }
public Organisation CreateOrganisation(string name, string bannerUrl, User organisator) { Organisation organisation = new Organisation { Name = name, BannerUrl = bannerUrl, DashboardBlocks = new List<DashboardBlock>(), Playlists = new List<Playlist>(), }; return organisationsRepository.CreateOrganisation(organisation, organisator); }
public User CreateUser(string email, string lastname, string firstname, string nickname, string imageUrl) { User user = new User { Email = email, LastName = lastname, FirstName = firstname, Nickname = nickname, ImageUrl = imageUrl }; return repo.CreateUser(user); }
public void DeleteUser(User user) { var userRoles = context.UserRole.Where(ur => ur.User.Id == user.Id); context.UserRole.RemoveRange(userRoles); var votes = context.Votes.Where(v => v.User.Id == user.Id); context.Votes.RemoveRange(votes); context.User.Remove(user); context.SaveChanges(); }
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))); user = userManager.CreateUser("*****@*****.**", "matthias", "test", "acidshards", ""); playlist = playlistManager.CreatePlaylistForUser("testplaylist", "gekke playlist om te testen", "125", 5, true, "", user); trackProvider = new YouTubeTrackProvider(); albumArtProvider = new BingAlbumArtProvider(); playlistControllerWithAuthenticatedUser = MyWebApi.Controller<PlaylistController>() .WithResolvedDependencyFor<IPlaylistManager>(playlistManager) .WithResolvedDependencyFor<IUserManager>(userManager) .WithResolvedDependencyFor<ITrackProvider>(trackProvider) .WithResolvedDependencyFor<IAlbumArtProvider>(albumArtProvider) .WithAuthenticatedUser( u => u.WithIdentifier("NewId") .WithUsername(user.Email) .WithClaim(new System.Security.Claims.Claim(System.Security.Claims.ClaimTypes.Email, user.Email)) .WithClaim(new System.Security.Claims.Claim("sub", user.Email)) ); Track metallicaTrack = 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", TrackId = "kV-2Q8QtCY4" } }; Track nickelbackTrack = new Track() { Artist = "Nickelback", Title = "How You Remind Me", CoverArtUrl = "", Duration = 400, TrackSource = new TrackSource { SourceType = SourceType.YouTube, Url = "https://www.youtube.com/watch?v=1cQh1ccqu8M", TrackId = "1cQh1ccqu8M" } }; _addedMetallicaTrack = playlistManager.AddTrackToPlaylist(playlist.Id, metallicaTrack); _addedNickelbackTrack = playlistManager.AddTrackToPlaylist(playlist.Id, nickelbackTrack); }
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); }
public Organisation CreateOrganisation(Organisation organisation, User user) { organisation = context.Organisations.Add(organisation); context.SaveChanges(); var user1 = context.User.Find(user.Id); var organisation1 = context.Organisations.Find(organisation.Id); UserRole userRole = new UserRole { Organisation = organisation1, User = user1, Role = Role.Organiser }; context.UserRole.Add(userRole); context.SaveChanges(); return organisation; }
// GET: Organisations/Details/5 public ActionResult Details(long id, int? page) { Organisation organisation = organisationManager.ReadOrganisation(id); if (organisation != null) { User organiser = userManager.ReadOrganiserFromOrganisation(organisation); IEnumerable<User> coOrganisers = userManager.ReadCoOrganiserFromOrganisation(organisation); OrganisationViewWithPlaylist organisationView = new OrganisationViewWithPlaylist() { Id = id, BannerUrl = organisation.BannerUrl, Name = organisation.Name, Organiser = organiser, CoOrganiser = coOrganisers }; var playlists = organisation.Playlists; int pageSize = 3; if (User != null) user = userManager.ReadUser(User.Identity.Name); UserRole userRole = userManager.ReadUserRoleForUserAndOrganisation(user.Id, id); if (userRole == null) ViewBag.Following = "None"; else if (userRole.Role == Role.Follower) ViewBag.Following = "Following"; else if (userRole.Role == Role.Co_Organiser) ViewBag.Following = "Co-Organiser"; else if (userRole.Role == Role.Organiser) ViewBag.Following = "Organiser"; int pageNumber = (page ?? 1); organisationView.Playlists = playlists.ToPagedList(pageNumber, pageSize); ViewBag.Id = id; ViewBag.TotalMinutesOfPlaytime = organisationManager.ReadTotalTimeOfPlaylistsInMinutes(id); ViewBag.TotalVotesOnPlaylists = organisationManager.ReadTotalVotesForOrganisation(id); return View("Details", organisationView); } else return View("Error"); }
public void Initialize() { userManager = new UserManager(new UserRepository(new EFDbContext(ContextEnum.BeatBuddyTest))); organisationManager = new OrganisationManager(new OrganisationRepository(new EFDbContext(ContextEnum.BeatBuddyTest))); user = userManager.CreateUser("*****@*****.**", "matthias", "test", "acidshards", ""); _organisationControllerWithAuthenticatedUser = MyWebApi.Controller<OrganisationsController>() .WithResolvedDependencyFor<IUserManager>(userManager) .WithResolvedDependencyFor<IOrganisationManager>(organisationManager) .WithAuthenticatedUser( u => u.WithIdentifier("NewId") .WithUsername(user.Email) .WithClaim(new System.Security.Claims.Claim(System.Security.Claims.ClaimTypes.Email, user.Email)) .WithClaim(new System.Security.Claims.Claim("sub", user.Email)) ); organisation = organisationManager.CreateOrganisation("testorganisatie", "", user); }
public Playlist CreatePlaylistForOrganisation(string name, string description, string key, int maxVotesPerUser, bool active, string imageUrl, User createdBy, long organisationId) { if (maxVotesPerUser.Equals(null)){ maxVotesPerUser = -1; } Playlist 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, organisationId); }
public User UpdateUser(User user) { context.Entry(user).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return user; }
public IEnumerable<Vote> ReadVotesUser(User user) { return context.Votes.Where(v => v.User == user); }
public User UpdateUser(User user) { return repo.UpdateUser(user); }
public ActionResult Create(OrganisationViewModel organisation, HttpPostedFileBase bannerImage) { try { string bannerPath = null; if (User != null) { user = userManager.ReadUser(User.Identity.Name); } var organisationNameAlreadyInUse = organisationManager.ReadOrganisation(organisation.Name); if (organisationNameAlreadyInUse != null) { ModelState.AddModelError("Name", "The name value is already in use"); return View(organisation); } if (String.IsNullOrWhiteSpace(organisation.Name)) { ModelState.AddModelError("Name", "The name value can not be empty"); return View(organisation); } if (bannerImage != null && bannerImage.ContentLength > 0) { var bannerFileName = Path.GetFileName(bannerImage.FileName); bannerPath = FileHelper.NextAvailableFilename(Path.Combine(Server.MapPath(ConfigurationManager.AppSettings["OrganisationsImgPath"]), bannerFileName)); bannerImage.SaveAs(bannerPath); bannerPath = Path.GetFileName(bannerPath); } Organisation org = organisationManager.CreateOrganisation(organisation.Name, bannerPath, user); return RedirectToAction("Details/" + org.Id); } catch { return RedirectToAction("Create"); } }
public User CreateUser(User user) { user = context.User.Add(user); context.SaveChanges(); return user; }
public IEnumerable<Vote> ReadVotesForUser(User user) { return repo.ReadVotesUser(user); }