コード例 #1
0
        /// <summary>
        /// Imports a new artist from remote api if it doesn't exist in our database
        /// </summary>
        public IHttpActionResult RemoteArtist(string remoteEntityId)
        {
            if (!string.IsNullOrEmpty(remoteEntityId))
            {
                var artists = _artistPageService.GetArtistPagesByRemoteEntityId(new string[] { remoteEntityId });
                if (artists.Count == 0)
                {
                    //we need to create a new artist now
                    var remoteArtist = _artistPageApiService.GetRemoteArtist(remoteEntityId);
                    if (remoteArtist == null)
                    {
                        return(NotFound());
                    }

                    var artist = SaveRemoteArtistToDB(remoteArtist);
                    return(RedirectToRoute("ArtistPageUrl", new { SeName = artist.GetPermalink() }));
                }
                else
                {
                    //the page already exists in our database. No need to create duplicate entries. Rather redirect them to the actual artist page
                    return(RedirectToRoute("ArtistPageUrl", new { SeName = artists[0].GetPermalink() }));
                }
            }
            //totally unknown path
            return(NotFound());
        }
コード例 #2
0
        /// <summary>
        /// Imports a new artist from remote api if it doesn't exist in our database
        /// </summary>
        public ActionResult RemoteArtist(string RemoteEntityId)
        {
            if (!string.IsNullOrEmpty(RemoteEntityId))
            {
                var artists = _artistPageService.GetArtistPagesByRemoteEntityId(new string[] { RemoteEntityId });
                if (artists.Count == 0)
                {
                    //we need to create a new artist now
                    var remoteArtist = _artistPageApiService.GetRemoteArtist(RemoteEntityId);
                    if (remoteArtist == null)
                    {
                        return(InvokeHttp404());
                    }

                    var artist = SaveRemoteArtistToDB(remoteArtist);
                    return(RedirectToRoute("ArtistPageUrl", new { SeName = artist.GetSeName(_workContext.WorkingLanguage.Id, true, false) }));
                }
                else
                {
                    //the page already exists in our database. No need to create duplicate entries. Rather redirect them to the actual artist page
                    return(RedirectToRoute("ArtistPageUrl", new { SeName = artists[0].GetSeName(_workContext.WorkingLanguage.Id, true, false) }));
                }
            }
            //totally unknown path
            return(InvokeHttp404());
        }