diff --git a/.gitignore b/.gitignore index 57a1574..cbf45a3 100644 --- a/.gitignore +++ b/.gitignore @@ -194,3 +194,6 @@ FakesAssemblies/ # Visual Studio 6 workspace options file *.opt + +#Azure Publish Profile +*.pubxml \ No newline at end of file diff --git a/CodeCampSdq5.Api/CodeCampSdq5.Api/App_Start/WebApiConfig.cs b/CodeCampSdq5.Api/CodeCampSdq5.Api/App_Start/WebApiConfig.cs index 3e1b80f..ca4828d 100644 --- a/CodeCampSdq5.Api/CodeCampSdq5.Api/App_Start/WebApiConfig.cs +++ b/CodeCampSdq5.Api/CodeCampSdq5.Api/App_Start/WebApiConfig.cs @@ -21,7 +21,7 @@ public static void Register(HttpConfiguration config) routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); - config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html")); + config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); } } } diff --git a/CodeCampSdq5.Api/CodeCampSdq5.Api/CodeCampSdq5.Api.csproj b/CodeCampSdq5.Api/CodeCampSdq5.Api/CodeCampSdq5.Api.csproj index 3def15a..a3c2d01 100644 --- a/CodeCampSdq5.Api/CodeCampSdq5.Api/CodeCampSdq5.Api.csproj +++ b/CodeCampSdq5.Api/CodeCampSdq5.Api/CodeCampSdq5.Api.csproj @@ -44,6 +44,14 @@ 4 + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll + True + + + ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll + True + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll True @@ -192,6 +200,8 @@ + + @@ -213,9 +223,6 @@ - - PreserveNewest - diff --git a/CodeCampSdq5.Api/CodeCampSdq5.Api/Controllers/CodeCampSdqController.cs b/CodeCampSdq5.Api/CodeCampSdq5.Api/Controllers/CodeCampSdqController.cs index 73edabc..8d43141 100644 --- a/CodeCampSdq5.Api/CodeCampSdq5.Api/Controllers/CodeCampSdqController.cs +++ b/CodeCampSdq5.Api/CodeCampSdq5.Api/Controllers/CodeCampSdqController.cs @@ -1,29 +1,28 @@ -using System.IO; +using System.Data.Entity; +using System.Threading.Tasks; using System.Web.Http; using CodeCampSdq.Data.Dto; -using Newtonsoft.Json; +using CodeCampSdq.Data.Storage; namespace CodeCampSdq5.Api.Controllers { public class CodeCampSdqController : ApiController { - public JsonData GetData() + public async Task GetData() { - var rawData = string.Empty; - - var jsonFileName = System.Web.Hosting.HostingEnvironment.MapPath(@"~/sessions.json"); - - if (File.Exists(jsonFileName)) - rawData = File.ReadAllText(jsonFileName); - - if (string.IsNullOrWhiteSpace(rawData)) return null; - - var result = JsonConvert.DeserializeObject(rawData, new JsonSerializerSettings() + using (var context = new CodeCampSdqContext()) { - NullValueHandling = NullValueHandling.Ignore - }); + var result = new JsonData + { + Sessions = await context.Sessions.ToListAsync(), + Speakers = await context.Speakers.ToListAsync() + }; + + result.Speakers.ForEach(x => x.Sessions = null); + result.Sessions.ForEach(x => x.Speaker = null); - return result; + return result; + } } } } diff --git a/CodeCampSdq5.Api/CodeCampSdq5.Api/Web.config b/CodeCampSdq5.Api/CodeCampSdq5.Api/Web.config index 7e1b855..f73a2ce 100644 --- a/CodeCampSdq5.Api/CodeCampSdq5.Api/Web.config +++ b/CodeCampSdq5.Api/CodeCampSdq5.Api/Web.config @@ -4,12 +4,21 @@ http://go.microsoft.com/fwlink/?LinkId=301879 --> + + +
+ + + + @@ -56,4 +65,10 @@ - + + + + + + + \ No newline at end of file diff --git a/CodeCampSdq5.Api/CodeCampSdq5.Api/packages.config b/CodeCampSdq5.Api/CodeCampSdq5.Api/packages.config index 62cd4ea..bd75f21 100644 --- a/CodeCampSdq5.Api/CodeCampSdq5.Api/packages.config +++ b/CodeCampSdq5.Api/CodeCampSdq5.Api/packages.config @@ -2,6 +2,7 @@ +