diff --git a/Web Services And Cloud/MovieInfoApp/MovieInfo.Tests/ActorTests.cs b/Web Services And Cloud/MovieInfoApp/MovieInfo.Tests/ActorTests.cs index a7d108f..070f098 100644 --- a/Web Services And Cloud/MovieInfoApp/MovieInfo.Tests/ActorTests.cs +++ b/Web Services And Cloud/MovieInfoApp/MovieInfo.Tests/ActorTests.cs @@ -13,7 +13,7 @@ public class ActorTests private static ActorModel actorInfo; private static CreditsModel credits; private static string creditsId; - private static SeriesInfo seriesInfo; + private static SeriesInfoModel seriesInfo; private static List episodes; private static List seasons; diff --git a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/.bin/git.cmd b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/.bin/git.cmd new file mode 100644 index 0000000..85ddefe --- /dev/null +++ b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/.bin/git.cmd @@ -0,0 +1,3 @@ +@echo off +SET PATH=%~dp0;%PATH% +"%~dp0node" "%~dp0..\..\packages\NoGit.0.0.8\node_modules\nogit\bin\git.js" %* \ No newline at end of file diff --git a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/.bin/node.cmd b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/.bin/node.cmd new file mode 100644 index 0000000..5b6b155 --- /dev/null +++ b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/.bin/node.cmd @@ -0,0 +1,3 @@ +@echo off +SET PATH=%PATH%;%~dp0 +"%~dp0..\..\packages\Node.js.0.10.28\node.exe" %* \ No newline at end of file diff --git a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/ActorInfo.cs b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/ActorInfo.cs new file mode 100644 index 0000000..acc465e --- /dev/null +++ b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/ActorInfo.cs @@ -0,0 +1,45 @@ +namespace MovieInfoApp +{ + using System; + using System.Linq; + using System.Net.Http; + using System.Threading.Tasks; + + using Models; + using Newtonsoft.Json; + + public class ActorInfo + { + private static ActorInfo retrieve; + + private ActorInfo(HttpClient client, string endpoint) + { + this.PrepareEndpoint(client, endpoint); + } + + public static async Task GetActorInfoByName(HttpClient client,string actorName) + { + string responseData; + string escapedName = Uri.EscapeUriString(actorName); + + client.BaseAddress = client.BaseAddress.AddParameter("query", escapedName); + + Task response = client.GetStringAsync(""); + responseData = await response; + + var actors = JsonConvert.DeserializeObject(responseData); + + return actors.Results.FirstOrDefault(); + } + + private Uri PrepareEndpoint(HttpClient client, string endpoint) + { + UriBuilder targetUrl = new UriBuilder(client.BaseAddress); + targetUrl.Path = endpoint; + + client.BaseAddress = targetUrl.Uri; + + return targetUrl.Uri; + } + } +} diff --git a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/ActorSearchResults.cs b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/ActorSearchResultsModel.cs similarity index 83% rename from Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/ActorSearchResults.cs rename to Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/ActorSearchResultsModel.cs index d702e83..59dc49c 100644 --- a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/ActorSearchResults.cs +++ b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/ActorSearchResultsModel.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; using System.Collections.Generic; - public class ActorSearchResults + public class ActorSearchResultsModel { [JsonProperty("results")] public List Results { get; set; } diff --git a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/CreditsSearchResults.cs b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/CreditsSearchResultsModel.cs similarity index 82% rename from Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/CreditsSearchResults.cs rename to Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/CreditsSearchResultsModel.cs index cda9361..0f485a4 100644 --- a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/CreditsSearchResults.cs +++ b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/CreditsSearchResultsModel.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Newtonsoft.Json; - public class CreditsSearchResults + public class CreditsSearchResultsModel { [JsonProperty("cast")] public List Credits { get; set; } diff --git a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/SeriesInfo.cs b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/SeriesInfoModel.cs similarity index 90% rename from Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/SeriesInfo.cs rename to Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/SeriesInfoModel.cs index 935ef34..2bf8273 100644 --- a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/SeriesInfo.cs +++ b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/SeriesInfoModel.cs @@ -4,7 +4,7 @@ using Newtonsoft.Json; - public class SeriesInfo + public class SeriesInfoModel { [JsonProperty("episodes")] public List Episodes { get; set; } diff --git a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/SeriesSearchResults.cs b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/SeriesSearchResults.cs index 0357064..eb716c7 100644 --- a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/SeriesSearchResults.cs +++ b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/SeriesSearchResults.cs @@ -5,6 +5,6 @@ public class SeriesSearchResults { [JsonProperty("media")] - public SeriesInfo SeriesInfo { get; set; } + public SeriesInfoModel SeriesInfo { get; set; } } } diff --git a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/MovieDb.cs b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/MovieDb.cs index 69cc607..6040bef 100644 --- a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/MovieDb.cs +++ b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/MovieDb.cs @@ -10,14 +10,53 @@ using Models; using System.Threading.Tasks; - public static class MovieDb + public class MovieDb { - private static readonly Uri BaseUrl = new Uri("https://api.themoviedb.org/"); + //private static readonly Uri BaseUrl = new Uri("https://api.themoviedb.org/"); private static readonly string PeopleEndpoint = "3/search/person"; private static readonly string TVCreditsEndpointFormat = "3/person/{0}/tv_credits"; private static readonly string CreditDetailsEndpointFormat = "3/credit/{0}"; private const string ApiKey = "8e44e41d1573ab3d390b11fc6d35d95e"; + private Uri baseUrl; + private HttpClient client; + private static MovieDb instance; + private MovieDb() + { + + } + + public static MovieDb Instance + { + get + { + if(instance == null) + { + instance = new MovieDb(); + } + + return instance; + } + } + + public Uri BaseUrl + { + get { return this.baseUrl; } + set { this.baseUrl = value; } + } + + public HttpClient Client + { + get { return this.client; } + set { this.client = value; } + } + + public void Connect(HttpClient client, Uri baseUrl, string apiKey) + { + this.Client = client; + this.BaseUrl = baseUrl.AddParameter("api_key",apiKey); + client.BaseAddress = this.BaseUrl; + } public static async Task GetActorInfoByName(string name) { @@ -36,7 +75,7 @@ public static async Task GetActorInfoByName(string name) Task response = client.GetStringAsync(""); responseData = await response; - var actors = JsonConvert.DeserializeObject(responseData); + var actors = JsonConvert.DeserializeObject(responseData); return actors.Results.FirstOrDefault(); } @@ -55,12 +94,12 @@ public static async Task> GetTVCreditsByActorId(int actorId) Task response = client.GetStringAsync(""); responseData = await response; - var credits = JsonConvert.DeserializeObject(responseData); + var credits = JsonConvert.DeserializeObject(responseData); return credits.Credits; } - public static async Task GetTVSeriesDetailsByCreditsId(string creditsId) + public static async Task GetTVSeriesDetailsByCreditsId(string creditsId) { string responseData; diff --git a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/MovieInfoApp.csproj b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/MovieInfoApp.csproj index ab775af..a42496d 100644 --- a/Web Services And Cloud/MovieInfoApp/MovieInfoApp/MovieInfoApp.csproj +++ b/Web Services And Cloud/MovieInfoApp/MovieInfoApp/MovieInfoApp.csproj @@ -49,13 +49,14 @@ + - + - + - + @@ -63,8 +64,13 @@ + + + + +