Skip to content

Commit dd17ee4

Browse files
FabianGosebrinkFabianGosebrink
authored andcommitted
updated to RC1
1 parent de908db commit dd17ee4

File tree

10 files changed

+114
-121
lines changed

10 files changed

+114
-121
lines changed

SampleWebApiMVC6.sln

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.24720.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F7E300EF-0B6D-46B2-8570-B1FA8A43FC11}"
77
EndProject
@@ -10,23 +10,23 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1010
global.json = global.json
1111
EndProjectSection
1212
EndProject
13-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleWebApiMVC6", "src\SampleWebApiMVC6\SampleWebApiMVC6.xproj", "{7E499032-B503-4410-A9A2-4B05D7E82B18}"
13+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleWebApiMVC6", "src\SampleWebApiMVC6\SampleWebApiMVC6.xproj", "{34EBD18E-514B-4226-9069-3F3B0517B359}"
1414
EndProject
1515
Global
1616
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1717
Debug|Any CPU = Debug|Any CPU
1818
Release|Any CPU = Release|Any CPU
1919
EndGlobalSection
2020
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21-
{7E499032-B503-4410-A9A2-4B05D7E82B18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22-
{7E499032-B503-4410-A9A2-4B05D7E82B18}.Debug|Any CPU.Build.0 = Debug|Any CPU
23-
{7E499032-B503-4410-A9A2-4B05D7E82B18}.Release|Any CPU.ActiveCfg = Release|Any CPU
24-
{7E499032-B503-4410-A9A2-4B05D7E82B18}.Release|Any CPU.Build.0 = Release|Any CPU
21+
{34EBD18E-514B-4226-9069-3F3B0517B359}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{34EBD18E-514B-4226-9069-3F3B0517B359}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{34EBD18E-514B-4226-9069-3F3B0517B359}.Release|Any CPU.ActiveCfg = Release|Any CPU
24+
{34EBD18E-514B-4226-9069-3F3B0517B359}.Release|Any CPU.Build.0 = Release|Any CPU
2525
EndGlobalSection
2626
GlobalSection(SolutionProperties) = preSolution
2727
HideSolutionNode = FALSE
2828
EndGlobalSection
2929
GlobalSection(NestedProjects) = preSolution
30-
{7E499032-B503-4410-A9A2-4B05D7E82B18} = {F7E300EF-0B6D-46B2-8570-B1FA8A43FC11}
30+
{34EBD18E-514B-4226-9069-3F3B0517B359} = {F7E300EF-0B6D-46B2-8570-B1FA8A43FC11}
3131
EndGlobalSection
3232
EndGlobal

global.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"projects": [ "src", "test" ],
33
"sdk": {
4-
"version": "1.0.0-beta8",
5-
"runtime": "clr",
6-
"architecture": "x86"
4+
"version": "1.0.0-rc1-update1"
75
}
86
}

src/SampleWebApiMVC6/Controllers/HouseController.cs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
using System.Linq;
1+
using System;
2+
using System.Linq;
23
using Microsoft.AspNet.Mvc;
34
using SampleWebApiMVC6.Models;
45
using SampleWebApiMVC6.Services;
56

67
namespace SampleWebApiMVC6.Controllers
78
{
89
[Route("api/[controller]")]
9-
public class HouseController : Controller
10+
public class HouseController
1011
{
1112
private readonly IHouseMapper _houseMapper;
1213

@@ -18,58 +19,48 @@ public HouseController(IHouseMapper houseMapper)
1819
[HttpGet]
1920
public IActionResult Get()
2021
{
21-
return Json(Singleton.Instance.Houses.Select(x => _houseMapper.MapToDto(x)));
22+
return new JsonResult(Singleton.Instance.Houses.Select(x => _houseMapper.MapToDto(x)));
2223
}
2324

2425
[HttpGet("{id:int}", Name = "GetSingleHouse")]
2526
public IActionResult GetSingle(int id)
2627
{
2728
HouseEntity houseEntity = Singleton.Instance.Houses.FirstOrDefault(x => x.Id == id);
2829

29-
if(houseEntity == null)
30+
if (houseEntity == null)
3031
{
3132
return new HttpNotFoundResult();
3233
}
3334

34-
return Json(_houseMapper.MapToDto(houseEntity));
35+
return new JsonResult(_houseMapper.MapToDto(houseEntity));
3536
}
3637

3738
[HttpPost]
3839
public IActionResult Create([FromBody] HouseDto houseDto)
3940
{
40-
if(houseDto == null)
41+
if (houseDto == null)
4142
{
42-
return HttpBadRequest();
43-
}
44-
45-
if(!ModelState.IsValid)
46-
{
47-
return new BadRequestObjectResult(ModelState);
43+
return new BadRequestResult();
4844
}
4945

5046
HouseEntity houseEntity = _houseMapper.MapToEntity(houseDto);
5147

5248
Singleton.Instance.Houses.Add(houseEntity);
5349

54-
return CreatedAtRoute("GetSingleHouse", new { id = houseEntity.Id }, _houseMapper.MapToDto(houseEntity));
50+
return new CreatedAtRouteResult("GetSingleHouse", new { id = houseEntity.Id }, _houseMapper.MapToDto(houseEntity));
5551
}
5652

5753
[HttpPut("{id:int}")]
5854
public IActionResult Update(int id, [FromBody] HouseDto houseDto)
5955
{
60-
if(houseDto == null)
61-
{
62-
return HttpBadRequest();
63-
}
64-
65-
if(!ModelState.IsValid)
56+
if (houseDto == null)
6657
{
67-
return new BadRequestObjectResult(ModelState);
58+
return new BadRequestResult();
6859
}
6960

7061
HouseEntity houseEntityToUpdate = Singleton.Instance.Houses.FirstOrDefault(x => x.Id == id);
7162

72-
if(houseEntityToUpdate == null)
63+
if (houseEntityToUpdate == null)
7364
{
7465
return new HttpNotFoundResult();
7566
}
@@ -80,15 +71,15 @@ public IActionResult Update(int id, [FromBody] HouseDto houseDto)
8071

8172
//Update to Database --> Is singleton in this case....
8273

83-
return new ObjectResult(_houseMapper.MapToDto(houseEntityToUpdate));
74+
return new JsonResult(_houseMapper.MapToDto(houseEntityToUpdate));
8475
}
8576

8677
[HttpDelete("{id:int}")]
8778
public IActionResult Delete(int id)
8879
{
8980
HouseEntity houseEntityToDelete = Singleton.Instance.Houses.FirstOrDefault(x => x.Id == id);
9081

91-
if(houseEntityToDelete == null)
82+
if (houseEntityToDelete == null)
9283
{
9384
return new HttpNotFoundResult();
9485
}

src/SampleWebApiMVC6/Project_Readme.html

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,10 @@
128128
<body>
129129

130130
<div id="header">
131-
<h1>Welcome to ASP.NET 5 Preview</h1>
131+
<h1>Welcome to ASP.NET 5</h1>
132132
<span>
133133
We've made some big updates in this release, so it’s <b>important</b> that you spend
134134
a few minutes to learn what’s new.
135-
<br /><br />
136-
ASP.NET 5 has been rearchitected to make it <b>lean</b> and <b>composable</b>. It's fully
137-
<b>open source</b> and available on <a href="http://go.microsoft.com/fwlink/?LinkID=517854">GitHub</a>.
138-
<br />
139-
Your new project automatically takes advantage of modern client-side utilities
140-
like <a href="http://go.microsoft.com/fwlink/?LinkId=518004">Bower</a> and <a href="http://go.microsoft.com/fwlink/?LinkId=518005">npm</a>
141-
(to add client-side libraries) and <a href="http://go.microsoft.com/fwlink/?LinkId=518007">Gulp</a> (for client-side build and automation tasks).
142-
143-
<br /><br />
144-
We hope you enjoy the new capabilities in ASP.NET 5 and Visual Studio 2015.
145-
<br />
146-
The ASP.NET Team
147135
</span>
148136
<p>You've created a new ASP.NET 5 project. <a href="http://go.microsoft.com/fwlink/?LinkId=518016">Learn what's new</a></p>
149137
</div>
@@ -153,44 +141,41 @@ <h1>Welcome to ASP.NET 5 Preview</h1>
153141
<h2>This application consists of:</h2>
154142
<ul>
155143
<li>Sample pages using ASP.NET MVC 6</li>
156-
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518007">Gulp</a> and <a href="http://go.microsoft.com/fwlink/?LinkId=518004">Bower</a> for managing client-side resources</li>
144+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518007">Gulp</a> and <a href="http://go.microsoft.com/fwlink/?LinkId=518004">Bower</a> for managing client-side libraries</li>
157145
<li>Theming using <a href="http://go.microsoft.com/fwlink/?LinkID=398939">Bootstrap</a></li>
158146
</ul>
159147
</div>
160-
161148
<div class="section">
162-
<h2>New concepts</h2>
149+
<h2>How to</h2>
163150
<ul>
164-
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518008">The 'wwwroot' explained</a></li>
165-
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518012">Configuration in ASP.NET 5</a></li>
166-
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518013">Dependency Injection</a></li>
167-
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518014">Razor TagHelpers</a></li>
168-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517849">Manage client packages using Gulp</a></li>
169-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517850">Develop on different platforms</a></li>
151+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a></li>
152+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699562">Add an appsetting in config and access it in app.</a></li>
153+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a></li>
154+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a></li>
155+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a></li>
156+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699318">Add client packages using Bower.</a></li>
157+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a></li>
170158
</ul>
171159
</div>
172-
173160
<div class="section">
174-
<h2>Customize app</h2>
161+
<h2>Overview</h2>
175162
<ul>
176-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398600">Add Controllers and Views</a></li>
177-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398602">Add Data using EntityFramework</a></li>
178-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398603">Add Authentication using Identity</a></li>
179-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398606">Add real time support using SignalR</a></li>
180-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398604">Add Class library</a></li>
181-
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518009">Add Web APIs with MVC 6</a></li>
182-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517848">Add client packages using Bower</a></li>
163+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET 5</a></li>
164+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET 5 such as Startup and middleware.</a></li>
165+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a></li>
166+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=398603">Security</a></li>
167+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a></li>
168+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a></li>
169+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a></li>
183170
</ul>
184171
</div>
185-
186172
<div class="section last">
187-
<h2>Deploy</h2>
173+
<h2>Run & Deploy</h2>
188174
<ul>
189-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517851">Run your app locally</a></li>
190-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517852">Run your app on ASP.NET Core 5</a></li>
175+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a></li>
176+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517852">Run your app on .NET Core</a></li>
191177
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517853">Run commands in your project.json</a></li>
192-
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Sites</a></li>
193-
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518019">Publish to the file system</a></li>
178+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a></li>
194179
</ul>
195180
</div>
196181

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:12345/",
7+
"sslPort": 0
8+
}
9+
},
210
"profiles": {
311
"IIS Express": {
4-
"commandName" : "IISExpress",
12+
"commandName": "IISExpress",
513
"launchBrowser": true,
614
"launchUrl": "api/house",
7-
"environmentVariables" : {
8-
"ASPNET_ENV": "Development"
15+
"environmentVariables": {
16+
"Hosting:Environment": "Development"
17+
}
18+
},
19+
"web": {
20+
"commandName": "web",
21+
"environmentVariables": {
22+
"Hosting:Environment": "Development"
923
}
1024
}
1125
}
12-
}
26+
}

src/SampleWebApiMVC6/SampleWebApiMVC6.xproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
</PropertyGroup>
77
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
88
<PropertyGroup Label="Globals">
9-
<ProjectGuid>7e499032-b503-4410-a9a2-4b05d7e82b18</ProjectGuid>
9+
<ProjectGuid>34ebd18e-514b-4226-9069-3f3b0517b359</ProjectGuid>
1010
<RootNamespace>SampleWebApiMVC6</RootNamespace>
1111
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
1212
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
1313
</PropertyGroup>
1414
<PropertyGroup>
1515
<SchemaVersion>2.0</SchemaVersion>
16-
<DevelopmentServerPort>60097</DevelopmentServerPort>
1716
</PropertyGroup>
1817
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
19-
</Project>
18+
</Project>

src/SampleWebApiMVC6/Startup.cs

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,30 @@
44
using System.Threading.Tasks;
55
using Microsoft.AspNet.Builder;
66
using Microsoft.AspNet.Hosting;
7-
using Microsoft.AspNet.Http;
8-
using Microsoft.AspNet.Routing;
9-
using Microsoft.Framework.DependencyInjection;
7+
using Microsoft.Extensions.Configuration;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.Logging;
1010
using SampleWebApiMVC6.Models;
1111
using SampleWebApiMVC6.Services;
12-
using Microsoft.Framework.Configuration;
13-
using Microsoft.Dnx.Runtime;
1412

1513
namespace SampleWebApiMVC6
1614
{
1715
public class Startup
1816
{
19-
IConfigurationRoot Configuration;
20-
21-
public Startup(IApplicationEnvironment env)
17+
public Startup(IHostingEnvironment env)
2218
{
19+
// Set up configuration sources.
2320
var builder = new ConfigurationBuilder()
24-
.SetBasePath(env.ApplicationBasePath)
25-
//.AddJsonFile("config.json")
26-
.AddEnvironmentVariables();
27-
21+
.AddJsonFile("appsettings.json")
22+
.AddEnvironmentVariables();
2823
Configuration = builder.Build();
24+
}
25+
26+
public IConfigurationRoot Configuration { get; set; }
2927

28+
// This method gets called by the runtime. Use this method to add services to the container.
29+
public void ConfigureServices(IServiceCollection services)
30+
{
3031
List<HouseEntity> houses = new List<HouseEntity>()
3132
{
3233
new HouseEntity() {City = "Town1", Id = 1, Street = "Street1", ZipCode = 1234},
@@ -36,31 +37,26 @@ public Startup(IApplicationEnvironment env)
3637
};
3738

3839
Singleton.Instance.Houses = houses;
39-
}
40-
41-
// This method gets called by a runtime.
42-
// Use this method to add services to the container
43-
public void ConfigureServices(IServiceCollection services)
44-
{
45-
services.AddMvc();
46-
// Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
47-
// You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
48-
// services.AddWebApiConventions();
4940

5041
services.AddTransient<IHouseMapper, HouseMapper>();
42+
// Add framework services.
43+
services.AddMvc();
5144
}
5245

53-
// Configure is called after ConfigureServices is called.
54-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
46+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
47+
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
5548
{
49+
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
50+
loggerFactory.AddDebug();
51+
5652
app.UseIISPlatformHandler();
57-
// Configure the HTTP request pipeline.
53+
5854
app.UseStaticFiles();
5955

60-
// Add MVC to the request pipeline.
6156
app.UseMvc();
62-
// Add the following route for porting Web API 2 controllers.
63-
// routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
6457
}
58+
59+
// Entry point for the application.
60+
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
6561
}
6662
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Logging": {
3+
"IncludeScopes": false,
4+
"LogLevel": {
5+
"Default": "Verbose",
6+
"System": "Information",
7+
"Microsoft": "Information"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)