public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Song song = db.Songs.Find(id); if (song == null) { return(HttpNotFound()); } //Set the song's properties SongDetailsViewModel songvm = new SongDetailsViewModel(); songvm.SongName = song.SongName; songvm.ContentID = song.ContentID; songvm.RegularPrice = song.RegularPrice; songvm.DiscountPrice = song.DiscountPrice; songvm.Featured = song.Featured; foreach (Artist artist in song.Artists) { songvm.Artists.Add(artist); } songvm.Album = song.Album; foreach (Genre genre in song.Genres) { songvm.Genres.Add(genre); } return(View(songvm)); }
public SongDetails(int songId) { InitializeComponent(); BindingContext = model = new SongDetailsViewModel() { _songId = songId }; }
public IActionResult DeleteSong(int id) { SongDetailsViewModel song = this.songService.GetSong(id); if (song == null) { return(RedirectToAction(RedirectConstants.IndexSuffix)); } return(this.View(song)); }
public IActionResult Details(int songId) { if (songId <= 0) { return(this.Redirect("/")); } string userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; SongDetailsViewModel viewModel = this.songsService.GetDetails(songId, userId); return(this.View(viewModel)); }
public ActionResult SongDetails(int songId) { if (Services.WorkContext.CurrentUser.UserName == "admin") { var song = _songService.GetSong(songId); var pollChoiceRecordId = song.PollChoiceRecord_Id; var poll = _pollService.GetPollFromChoiceId(pollChoiceRecordId); var songVotes = _pollService.GetSongVotes(poll.Id, pollChoiceRecordId); var songResult = _pollService.GetSongResult(pollChoiceRecordId); var userVotes = new List <SongVoteEntry>(); var songTitleAndAuthor = song.SongTitle + " (" + song.SongAuthor + ")"; foreach (var vote in songVotes) { // var results = new Dictionary<DateTime, int>(); var songVotesEnteredByUser = _pollService.GetUserVotesForSong(poll.Id, vote.Username, pollChoiceRecordId); var userFullName = "x"; if (vote.Username == "Anonymous") { userFullName = "Anonymous"; } else { // get user fullname from vote record via artist service userFullName = _artistUserService.GetFullName(vote.Username); } var entry = new SongVoteEntry { UserFullName = userFullName, NumberOfVotesByUser = songVotesEnteredByUser.ToList() }; userVotes.Add(entry); } var model = new SongDetailsViewModel { VotesByUser = userVotes, SongTitleAndAuthor = songTitleAndAuthor }; return(View(model)); } else { Services.Notifier.Information(T("Please log in as Admin user in order to access this method.")); return(Redirect("~/Endpoint")); } }
public SongDetailsViewModel GetDetails(int songId, string userId) { List <string> userGroups = this.context.Groups .Where(g => g.OwnerId == userId && g.IsDeleted == false) .Select(g => g.Name).ToList(); SongDetailsViewModel viewModel = this.context.Songs .Where(s => s.Id == songId) .Select(s => new SongDetailsViewModel { Id = s.Id, Name = s.Name, EmbededLyrics = s.Metadata.FirstOrDefault(m => m.Type == GlobalConstants.Lyrics && m.SongId == songId).Value, VideoId = s.Metadata.FirstOrDefault(m => m.Type == GlobalConstants.YouTubeVideo && m.SongId == songId).Value, UserGroups = new MultiSelectList(userGroups), }).FirstOrDefault(); return(viewModel); }
public ActionResult Details(SongDetailsViewModel model, int id) { //TODO: Add logic that only allows users with this song in their library to rate/comment if (model.Stars != null) { //Set the Rating's properties string username = User.Identity.GetUserName(); AppUser currentuser = db.Users.FirstOrDefault(u => u.UserName == username); Rating rating = new Rating(); rating.Customer = currentuser; rating.Stars = Convert.ToInt32(model.Stars); //TODO: round this maybe? if (model.Comment != null) { rating.Comment = model.Comment; } rating.Content = model.Item; db.Ratings.Add(rating); db.SaveChanges(); } return(RedirectToAction("Index")); }