Skip to content

Commit

Permalink
Merge pull request #5 from afuersch/master
Browse files Browse the repository at this point in the history
Upgrade to ASP.NET 5 Beta 8
  • Loading branch information
saxx committed Oct 24, 2015
2 parents 05d5112 + cb1d4f6 commit 5b9d29a
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 102 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta6"
"version": "1.0.0-beta8"
}
}
6 changes: 3 additions & 3 deletions src/Wuzlstats/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ private int Get(IConfiguration configuration, string key, int defaultValue)

private string Get(IConfiguration configuration, string key, string defaultValue)
{
string value;
return configuration.TryGet(key, out value) ? value : defaultValue;
string value = configuration[key];
return !string.IsNullOrEmpty(value) ? value : defaultValue;
}
}
}
}
5 changes: 3 additions & 2 deletions src/Wuzlstats/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.AspNet.Mvc;
using Wuzlstats.Models;
using Wuzlstats.ViewModels.Home;
using Microsoft.Framework.Primitives;

namespace Wuzlstats.Controllers
{
Expand Down Expand Up @@ -34,12 +35,12 @@ public IActionResult Index(string league)
public async Task<IActionResult> Index()
{
var leagueCookie = Request.Cookies["league"];
if (leagueCookie == null)
if (StringValues.IsNullOrEmpty(leagueCookie))
{
return RedirectToAction("Index", "Leagues");
}

var league = await _db.Leagues.FirstOrDefaultAsync(x => x.Name.ToLower() == leagueCookie.ToLower());
var league = await _db.Leagues.FirstOrDefaultAsync(x => x.Name.ToLower() == leagueCookie.ToString().ToLower());
if (league == null)
{
return RedirectToAction("Index", "Leagues");
Expand Down
2 changes: 1 addition & 1 deletion src/Wuzlstats/Hubs/ApiHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ private async Task<League> CheckAndLoadLeague(string league)
return leagueEntity;
}
}
}
}
43 changes: 17 additions & 26 deletions src/Wuzlstats/Migrations/20150810174412_Initial.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 28 additions & 30 deletions src/Wuzlstats/Migrations/20150810174412_Initial.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Migrations.Builders;
using Microsoft.Data.Entity.Migrations.Operations;
using System;

namespace Wuzlstats.Migrations
{
public partial class Initial : Migration
{
public override void Up(MigrationBuilder migration)
protected override void Up(MigrationBuilder migration)
{
migration.CreateTable(
name: "League",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", "IdentityColumn"),
Name = table.Column(type: "nvarchar(max)", nullable: true),
TimeoutConfiguration = table.Column(type: "nvarchar(max)", nullable: true)
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
TimeoutConfiguration = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
Expand All @@ -26,68 +24,68 @@ public override void Up(MigrationBuilder migration)
name: "Game",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", "IdentityColumn"),
BlueScore = table.Column(type: "int", nullable: false),
Date = table.Column(type: "datetime2", nullable: false),
LeagueId = table.Column(type: "int", nullable: false),
RedScore = table.Column(type: "int", nullable: false)
BlueScore = table.Column<int>(type: "int", nullable: false),
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
LeagueId = table.Column<int>(type: "int", nullable: false),
RedScore = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Game", x => x.Id);
table.ForeignKey(
name: "FK_Game_League_LeagueId",
columns: x => x.LeagueId,
referencedTable: "League",
referencedColumn: "Id");
});
principalTable: "League",
principalColumns: new[] { "Id" });
});
migration.CreateTable(
name: "Player",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", "IdentityColumn"),
Image = table.Column(type: "varbinary(max)", nullable: true),
LeagueId = table.Column(type: "int", nullable: false),
Name = table.Column(type: "nvarchar(max)", nullable: true)
Image = table.Column<byte[]>(type: "varbinary(max)", nullable: true),
LeagueId = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Player", x => x.Id);
table.ForeignKey(
name: "FK_Player_League_LeagueId",
columns: x => x.LeagueId,
referencedTable: "League",
referencedColumn: "Id");
principalTable: "League",
principalColumns: new[] { "Id" });
});
migration.CreateTable(
name: "PlayerPosition",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", "IdentityColumn"),
GameId = table.Column(type: "int", nullable: false),
PlayerId = table.Column(type: "int", nullable: false),
Position = table.Column(type: "int", nullable: false)
GameId = table.Column<int>(type: "int", nullable: false),
PlayerId = table.Column<int>(type: "int", nullable: false),
Position = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PlayerPosition", x => x.Id);
table.ForeignKey(
name: "FK_PlayerPosition_Game_GameId",
columns: x => x.GameId,
referencedTable: "Game",
referencedColumn: "Id");
principalTable: "Game",
principalColumns: new[] { "Id" });
table.ForeignKey(
name: "FK_PlayerPosition_Player_PlayerId",
columns: x => x.PlayerId,
referencedTable: "Player",
referencedColumn: "Id");
principalTable: "Player",
principalColumns: new[] { "Id" });
});
}

public override void Down(MigrationBuilder migration)
protected override void Down(MigrationBuilder migration)
{
migration.DropTable("PlayerPosition");
migration.DropTable("Game");
Expand Down
31 changes: 15 additions & 16 deletions src/Wuzlstats/Migrations/DbModelSnapshot.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations.Infrastructure;
using Wuzlstats.Models;
using Microsoft.Data.Entity.Infrastructure;

namespace Wuzlstats.Migrations
{
[ContextType(typeof(Db))]
[DbContext(typeof(Db))]
partial class DbModelSnapshot : ModelSnapshot
{
public override void BuildModel(ModelBuilder builder)
protected override void BuildModel(ModelBuilder builder)
{
builder
.Annotation("ProductVersion", "7.0.0-beta6-13815")
Expand All @@ -28,7 +27,7 @@ public override void BuildModel(ModelBuilder builder)

b.Property<int>("RedScore");

b.Key("Id");
b.HasKey("Id");
});

builder.Entity("Wuzlstats.Models.League", b =>
Expand All @@ -40,7 +39,7 @@ public override void BuildModel(ModelBuilder builder)

b.Property<string>("TimeoutConfiguration");

b.Key("Id");
b.HasKey("Id");
});

builder.Entity("Wuzlstats.Models.Player", b =>
Expand All @@ -54,7 +53,7 @@ public override void BuildModel(ModelBuilder builder)

b.Property<string>("Name");

b.Key("Id");
b.HasKey("Id");
});

builder.Entity("Wuzlstats.Models.PlayerPosition", b =>
Expand All @@ -68,31 +67,31 @@ public override void BuildModel(ModelBuilder builder)

b.Property<int>("Position");

b.Key("Id");
b.HasKey("Id");
});

builder.Entity("Wuzlstats.Models.Game", b =>
{
b.Reference("Wuzlstats.Models.League")
.InverseCollection()
b.HasOne("Wuzlstats.Models.League")
.WithMany()
.ForeignKey("LeagueId");
});

builder.Entity("Wuzlstats.Models.Player", b =>
{
b.Reference("Wuzlstats.Models.League")
.InverseCollection()
b.HasOne("Wuzlstats.Models.League")
.WithMany()
.ForeignKey("LeagueId");
});

builder.Entity("Wuzlstats.Models.PlayerPosition", b =>
{
b.Reference("Wuzlstats.Models.Game")
.InverseCollection()
b.HasOne("Wuzlstats.Models.Game")
.WithMany()
.ForeignKey("GameId");

b.Reference("Wuzlstats.Models.Player")
.InverseCollection()
b.HasOne("Wuzlstats.Models.Player")
.WithMany()
.ForeignKey("PlayerId");
});
}
Expand Down
10 changes: 5 additions & 5 deletions src/Wuzlstats/Models/Db.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public class Db : DbContext

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Game>().Reference(x => x.League).InverseCollection(x => x.Games).ForeignKey(x => x.LeagueId);
modelBuilder.Entity<Player>().Reference(x => x.League).InverseCollection(x => x.Players).ForeignKey(x => x.LeagueId);
modelBuilder.Entity<PlayerPosition>().Reference(x => x.Player).InverseCollection(x => x.Positions).ForeignKey(x => x.PlayerId);
modelBuilder.Entity<PlayerPosition>().Reference(x => x.Game).InverseCollection(x => x.Positions).ForeignKey(x => x.GameId);
modelBuilder.Entity<Game>().HasOne(x => x.League).WithMany(x => x.Games).ForeignKey(x => x.LeagueId);
modelBuilder.Entity<Player>().HasOne(x => x.League).WithMany(x => x.Players).ForeignKey(x => x.LeagueId);
modelBuilder.Entity<PlayerPosition>().HasOne(x => x.Player).WithMany(x => x.Positions).ForeignKey(x => x.PlayerId);
modelBuilder.Entity<PlayerPosition>().HasOne(x => x.Game).WithMany(x => x.Positions).ForeignKey(x => x.GameId);

base.OnModelCreating(modelBuilder);
}
}
}
}
Loading

0 comments on commit 5b9d29a

Please sign in to comment.