public async Task AddSuggestion(string videoId, string songId, Guid modeId, Guid userId)
        {
            var video = await m_videoService.GetVideo(videoId);

            if (video == null)
            {
                await m_videoService.PostVideo(new CreateVideoRequest { VideoId = videoId });

                video = await m_videoService.GetVideo(videoId);
            }
            var song = await m_songService.Get(songId);

            if (song == null)
            {
                await m_songService.Post(new CreateSongRequest { SongId = songId });

                song = await m_songService.Get(songId);
            }
            var suggestionRelation = await m_suggestionService.GetSuggestionRelation(new SuggestionRelationRequest { ModeId = modeId, SongId = song.SongId, UserId = userId });

            if (suggestionRelation == null)                                                                                                                                                  // The user does not have this suggestion
            {
                suggestionRelation = await m_suggestionService.GetSuggestionRelation(new SuggestionRelationRequest { ModeId = modeId, SongId = song.SongId, UserId = PartifySystemUserId }); // Partify-System userId

                if (suggestionRelation == null)                                                                                                                                              // this is not suggested by the Partify-System user. (or anybody else)
                {
                    // post to relation and userRelation for the User and Partify-System user
                    await m_suggestionService.PostSuggestion(new CreateSuggestionRequest { ModeId = modeId, Overruled = false, SpotifyId = song.Id, YoutubeId = video.Id });

                    var suggestion = await m_suggestionService.GetSuggestion(song.Id, video.Id, modeId);

                    await m_userSuggestionService.Post(new CreateUserSuggestionRequest { SuggestionId = suggestion.Id, UserId = userId });

                    await m_userSuggestionService.Post(new CreateUserSuggestionRequest { SuggestionId = suggestion.Id, UserId = PartifySystemUserId });

                    return;
                }
                // The suggestion is set by the Partify-System user and we only need to post it to the UserSuggestion table
                var suggestionByPartifySystemUser = await m_suggestionService.GetSuggestion(song.Id, video.Id, modeId);

                await m_userSuggestionService.Post(new CreateUserSuggestionRequest { SuggestionId = suggestionByPartifySystemUser.Id, UserId = userId });

                return;
            }

            // the user have allready added a suggestion for him/herserlf, we should now change the prefered suggestion for that spesific user
            await RemoveSuggestion(suggestionRelation.UserSuggestionId);

            var existingSuggestion = await m_suggestionService.GetSuggestion(song.Id, video.Id, modeId);

            if (existingSuggestion == null)
            {
                await m_suggestionService.PostSuggestion(new CreateSuggestionRequest { ModeId = modeId, Overruled = false, SpotifyId = song.Id, YoutubeId = video.Id });

                existingSuggestion = await m_suggestionService.GetSuggestion(song.Id, video.Id, modeId);
            }

            await m_userSuggestionService.Post(new CreateUserSuggestionRequest { SuggestionId = existingSuggestion.Id, UserId = userId });
        }
예제 #2
0
        public ActionResult Song(int id)
        {
            SongDTO       songDto = songService.Get(id);
            SongViewModel song    = Mapper.Map <SongDTO, SongViewModel>(songDto);

            ViewBag.PerformerName = performerService.Get(song.PerformerId).Name;
            IEnumerable <ChordDTO>       chordDtos = chordService.GetAllBySongId(id);
            IEnumerable <ChordViewModel> chords    = Mapper.Map <IEnumerable <ChordDTO>, IEnumerable <ChordViewModel> >(chordDtos);

            song.Chords = chords;
            return(View(song));
        }
예제 #3
0
        public IHttpActionResult Index(int id)
        {
            var song = _songService.Get(id);

            if (song == null || (!CanEdit(song) && !song.Published))
            {
                return(NotFound()); //not found
            }
            string affiliateUrl = "";
            int    trackId;

            if (int.TryParse(song.TrackId, out trackId))
            {
                affiliateUrl = _musicService.GetTrackAffiliateUrl(trackId);
            }

            var product = _productService.GetProductById(song.AssociatedProductId);
            var model   = new SongModel()
            {
                Description      = song.Description,
                Name             = song.Name,
                RemoteEntityId   = song.RemoteEntityId,
                RemoteSourceName = song.RemoteSourceName,
                TrackId          = song.TrackId,
                Id                  = song.Id,
                PreviewUrl          = string.IsNullOrEmpty(song.RemoteEntityId) ? song.PreviewUrl : _musicService.GetTrackPreviewUrl(int.Parse(song.TrackId)),
                AffiliateUrl        = affiliateUrl,
                AssociatedProductId = song.AssociatedProductId,
                Published           = song.Published,
                Price               = product != null ? product.Price : 0,
                FormattedPrice      = product != null?_priceFormatter.FormatPrice(product.Price, true, _workContext.WorkingCurrency) : ""
            };

            //images for song
            foreach (var picture in song.Pictures)
            {
                model.Pictures.Add(new PictureModel {
                    Id           = picture.Id,
                    EntityId     = song.Id,
                    PictureId    = picture.PictureId,
                    DisplayOrder = picture.DisplayOrder,
                    DateCreated  = picture.DateCreated,
                    DateUpdated  = picture.DateUpdated,
                    PictureUrl   = _pictureService.GetPictureUrl(picture.PictureId, 0, true),
                });
            }
            if (model.Pictures.Count > 0)
            {
                model.MainPictureUrl = model.Pictures[0].PictureUrl;
            }
            else
            {
                model.MainPictureUrl = _pictureService.GetDefaultPictureUrl();
            }

            model.CanEdit   = CanEdit(song);
            model.CanDelete = CanDelete(song);

            //seo
            model.MetaTitle       = model.Name;
            model.MetaKeywords    = model.Name;
            model.MetaDescription = string.IsNullOrWhiteSpace(model.Description) ? model.Name : model.Description;
            return(View(ControllerUtil.MobSocialViewsFolder + "/SongPage/Index.cshtml", model));
        }
        public async Task <IHttpActionResult> Get(string id)
        {
            var result = await _songService.Get(id);

            return(ServiceResult(result));
        }
 public ActionResult <List <SongGetRequest> > Get([FromQuery] SongSearchRequest request)
 {
     return(_songService.Get(request));
 }
예제 #6
0
        public async Task <JsonResult> Get()
        {
            var artists = await _songService.Get();

            return(new JsonResult(artists));
        }