Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,6 @@ FakesAssemblies/

# Visual Studio 6 workspace options file
*.opt

#Azure Publish Profile
*.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
}
13 changes: 10 additions & 3 deletions CodeCampSdq5.Api/CodeCampSdq5.Api/CodeCampSdq5.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -192,6 +200,8 @@
<Content Include="Areas\HelpPage\Views\Help\DisplayTemplates\CollectionModelDescription.cshtml" />
<Content Include="Areas\HelpPage\Views\Help\DisplayTemplates\ApiGroup.cshtml" />
<Content Include="Areas\HelpPage\Views\Help\Api.cshtml" />
<None Include="Properties\PublishProfiles\codecampsdq5api - FTP.pubxml" />
<None Include="Properties\PublishProfiles\codecampsdq5api - Web Deploy.pubxml" />
<None Include="Scripts\jquery-1.10.2.intellisense.js" />
<Content Include="Scripts\jquery-1.10.2.js" />
<Content Include="Scripts\jquery-1.10.2.min.js" />
Expand All @@ -213,9 +223,6 @@
<Content Include="Views\Home\Index.cshtml" />
<Content Include="Views\Shared\Error.cshtml" />
<Content Include="Views\Shared\_Layout.cshtml" />
<Content Include="sessions.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CodeCampSdq.Data\CodeCampSdq.Data.csproj">
Expand Down
Original file line number Diff line number Diff line change
@@ -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<JsonData> 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<JsonData>(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;
}
}
}
}
17 changes: 16 additions & 1 deletion CodeCampSdq5.Api/CodeCampSdq5.Api/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
http://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<connectionStrings>
<add name="CodeCampSdqDb"
connectionString="Server=.\sqlexpress;Database=CodeCampSdqDb;Integrated Security=true;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.6" />
<httpRuntime targetFramework="4.6" />
Expand Down Expand Up @@ -56,4 +65,10 @@
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
</configuration>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
1 change: 1 addition & 0 deletions CodeCampSdq5.Api/CodeCampSdq5.Api/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<packages>
<package id="Antlr" version="3.4.1.9004" targetFramework="net46" />
<package id="bootstrap" version="3.0.0" targetFramework="net46" />
<package id="EntityFramework" version="6.1.3" targetFramework="net46" />
<package id="jQuery" version="1.10.2" targetFramework="net46" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net46" />
Expand Down