├── .gitignore ├── README.md ├── aspnet5ng2seed.sln ├── global.json └── src └── aspnet5ng2seed ├── .bowerrc ├── Controllers ├── AuthController.cs └── DataController.cs ├── Migrations ├── 20151204180204_InitialCreate.Designer.cs ├── 20151204180204_InitialCreate.cs ├── 20151204181739_Identity.Designer.cs ├── 20151204181739_Identity.cs └── AppDbContextModelSnapshot.cs ├── Models ├── AppDbContext.cs ├── Seeder.cs └── Shipment.cs ├── Properties └── launchSettings.json ├── Startup.cs ├── ViewModels └── LoginViewModel.cs ├── Views ├── Auth │ └── Login.cshtml └── _ViewImports.cshtml ├── aspnet5ng2seed.xproj ├── bower.json ├── gulpfile.js ├── package.json ├── project.json ├── project.lock.json ├── scripts ├── app.ts ├── model.ts └── tsconfig.json └── wwwroot ├── app └── partials │ └── app.html ├── index.html └── web.config /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | *.xproj.user 3 | node_modules/ 4 | src/aspnet5ng2seed/wwwroot/app/**/*.js 5 | src/aspnet5ng2seed/wwwroot/app/**/*.js.map 6 | src/aspnet5ng2seed/wwwroot/lib/ 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Video tutorials 2 | 3 | 1. Setting up seed project: https://youtu.be/Zkesm9CUP_o 4 | 2. Consume data from aspnet5 mvc6 controller: https://youtu.be/Rq63N61C3G4 5 | 3. Get Started with EntityFramework 7: https://youtu.be/EYsQrEu9Z6c 6 | 7 | - Upgrade angular2 alpha 47 to 52: https://youtu.be/cbozcSC0L4A 8 | - Upgrade angular2 alpha 52 to beta0: https://youtu.be/UZAqWmWUuyI 9 | 10 | ## Future 11 | - Use Aspnet Identity 12 | - Implement cookie based authentication 13 | - Implement validation with aspnet5 taghelpers 14 | 15 | # Build 16 | 17 | 1. Make sure you have ASP.NET 5 RC1 installed. 18 | 2. Open and build the project. 19 | 20 | # Troubleshoot 21 | 22 | Sometimes VS failes to restore the npm deps, restore them from the cmd in that case. 23 | 24 | 1. Open a cmd prompt 25 | 2. Navigate to src\aspnet5ng2seed\ 26 | 3. run "npm install" 27 | 4. run "dnx ef database update" 28 | 5. Make sure the "node_modules" folder contains all the libs. 29 | 30 | # Upgrade dnvm and use 1.0.0-rc1-final 31 | 32 | 1. dnvm update-self 33 | 2. dnvm upgrade 34 | 3. dnvm use 1.0.0-rc1-final -r clr -arch x86 -p 35 | -------------------------------------------------------------------------------- /aspnet5ng2seed.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{511C35FF-369C-4338-BE86-7314D32E50BE}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FC600672-441A-4825-89E5-AD1DC32D2DF2}" 9 | ProjectSection(SolutionItems) = preProject 10 | global.json = global.json 11 | EndProjectSection 12 | EndProject 13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "aspnet5ng2seed", "src\aspnet5ng2seed\aspnet5ng2seed.xproj", "{8C980284-5D84-4F1A-BF4E-AB6B3F5B6205}" 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {8C980284-5D84-4F1A-BF4E-AB6B3F5B6205}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {8C980284-5D84-4F1A-BF4E-AB6B3F5B6205}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {8C980284-5D84-4F1A-BF4E-AB6B3F5B6205}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {8C980284-5D84-4F1A-BF4E-AB6B3F5B6205}.Release|Any CPU.Build.0 = Release|Any CPU 25 | EndGlobalSection 26 | GlobalSection(SolutionProperties) = preSolution 27 | HideSolutionNode = FALSE 28 | EndGlobalSection 29 | GlobalSection(NestedProjects) = preSolution 30 | {8C980284-5D84-4F1A-BF4E-AB6B3F5B6205} = {511C35FF-369C-4338-BE86-7314D32E50BE} 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "projects": [ "src", "test" ], 3 | "sdk": { 4 | "version": "1.0.0-rc1-final" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "wwwroot/lib" 3 | } 4 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Controllers/AuthController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using aspnet5ng2seed.ViewModels; 6 | using Microsoft.AspNet.Identity; 7 | using Microsoft.AspNet.Identity.EntityFramework; 8 | using Microsoft.AspNet.Mvc; 9 | 10 | // For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 11 | 12 | namespace aspnet5ng2seed.Controllers 13 | { 14 | public class AuthController : Controller 15 | { 16 | private readonly SignInManager _signInManager; 17 | 18 | public AuthController(SignInManager signInManager) 19 | { 20 | _signInManager = signInManager; 21 | } 22 | 23 | public IActionResult Login() 24 | { 25 | return View(); 26 | } 27 | 28 | [HttpPost] 29 | public async Task Login(LoginViewModel model) 30 | { 31 | if (ModelState.IsValid) 32 | { 33 | var result = await _signInManager.PasswordSignInAsync( 34 | model.Username, model.Password, true, false); 35 | 36 | if (result.Succeeded) 37 | { 38 | return Redirect("/"); 39 | } 40 | 41 | ModelState.AddModelError("", "Username or password is incorrect."); 42 | } 43 | 44 | return View(); 45 | } 46 | 47 | public async Task Logout() 48 | { 49 | 50 | if (User.Identity.IsAuthenticated) 51 | { 52 | await _signInManager.SignOutAsync(); 53 | } 54 | 55 | return Redirect("/"); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Controllers/DataController.cs: -------------------------------------------------------------------------------- 1 | using aspnet5ng2seed.Models; 2 | using Microsoft.AspNet.Authorization; 3 | using Microsoft.AspNet.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace aspnet5ng2seed.Controllers 10 | { 11 | [Route("api/[controller]")] 12 | //[Authorize] 13 | public class DataController : Controller 14 | { 15 | private readonly AppDbContext _context; 16 | 17 | public DataController(AppDbContext context) 18 | { 19 | _context = context; 20 | } 21 | 22 | public IEnumerable Get() 23 | { 24 | return _context.Shipments 25 | //.Where(x => x.Username == User.Identity.Name) 26 | .ToList(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Migrations/20151204180204_InitialCreate.Designer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Data.Entity; 3 | using Microsoft.Data.Entity.Infrastructure; 4 | using Microsoft.Data.Entity.Metadata; 5 | using Microsoft.Data.Entity.Migrations; 6 | using aspnet5ng2seed.Models; 7 | 8 | namespace aspnet5ng2seed.Migrations 9 | { 10 | [DbContext(typeof(AppDbContext))] 11 | [Migration("20151204180204_InitialCreate")] 12 | partial class InitialCreate 13 | { 14 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 15 | { 16 | modelBuilder 17 | .HasAnnotation("ProductVersion", "7.0.0-rc1-16348") 18 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 19 | 20 | modelBuilder.Entity("aspnet5ng2seed.Models.Shipment", b => 21 | { 22 | b.Property("Id") 23 | .ValueGeneratedOnAdd(); 24 | 25 | b.Property("Destination"); 26 | 27 | b.Property("Origin"); 28 | 29 | b.Property("ShippedDate"); 30 | 31 | b.HasKey("Id"); 32 | }); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Migrations/20151204180204_InitialCreate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.Data.Entity.Migrations; 4 | using Microsoft.Data.Entity.Metadata; 5 | 6 | namespace aspnet5ng2seed.Migrations 7 | { 8 | public partial class InitialCreate : Migration 9 | { 10 | protected override void Up(MigrationBuilder migrationBuilder) 11 | { 12 | migrationBuilder.CreateTable( 13 | name: "Shipment", 14 | columns: table => new 15 | { 16 | Id = table.Column(nullable: false) 17 | .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), 18 | Destination = table.Column(nullable: true), 19 | Origin = table.Column(nullable: true), 20 | ShippedDate = table.Column(nullable: false) 21 | }, 22 | constraints: table => 23 | { 24 | table.PrimaryKey("PK_Shipment", x => x.Id); 25 | }); 26 | } 27 | 28 | protected override void Down(MigrationBuilder migrationBuilder) 29 | { 30 | migrationBuilder.DropTable("Shipment"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Migrations/20151204181739_Identity.Designer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Data.Entity; 3 | using Microsoft.Data.Entity.Infrastructure; 4 | using Microsoft.Data.Entity.Metadata; 5 | using Microsoft.Data.Entity.Migrations; 6 | using aspnet5ng2seed.Models; 7 | 8 | namespace aspnet5ng2seed.Migrations 9 | { 10 | [DbContext(typeof(AppDbContext))] 11 | [Migration("20151204181739_Identity")] 12 | partial class Identity 13 | { 14 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 15 | { 16 | modelBuilder 17 | .HasAnnotation("ProductVersion", "7.0.0-rc1-16348") 18 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 19 | 20 | modelBuilder.Entity("aspnet5ng2seed.Models.Shipment", b => 21 | { 22 | b.Property("Id") 23 | .ValueGeneratedOnAdd(); 24 | 25 | b.Property("Destination"); 26 | 27 | b.Property("Origin"); 28 | 29 | b.Property("ShippedDate"); 30 | 31 | b.Property("Username"); 32 | 33 | b.HasKey("Id"); 34 | }); 35 | 36 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRole", b => 37 | { 38 | b.Property("Id"); 39 | 40 | b.Property("ConcurrencyStamp") 41 | .IsConcurrencyToken(); 42 | 43 | b.Property("Name") 44 | .HasAnnotation("MaxLength", 256); 45 | 46 | b.Property("NormalizedName") 47 | .HasAnnotation("MaxLength", 256); 48 | 49 | b.HasKey("Id"); 50 | 51 | b.HasIndex("NormalizedName") 52 | .HasAnnotation("Relational:Name", "RoleNameIndex"); 53 | 54 | b.HasAnnotation("Relational:TableName", "AspNetRoles"); 55 | }); 56 | 57 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b => 58 | { 59 | b.Property("Id") 60 | .ValueGeneratedOnAdd(); 61 | 62 | b.Property("ClaimType"); 63 | 64 | b.Property("ClaimValue"); 65 | 66 | b.Property("RoleId") 67 | .IsRequired(); 68 | 69 | b.HasKey("Id"); 70 | 71 | b.HasAnnotation("Relational:TableName", "AspNetRoleClaims"); 72 | }); 73 | 74 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUser", b => 75 | { 76 | b.Property("Id"); 77 | 78 | b.Property("AccessFailedCount"); 79 | 80 | b.Property("ConcurrencyStamp") 81 | .IsConcurrencyToken(); 82 | 83 | b.Property("Email") 84 | .HasAnnotation("MaxLength", 256); 85 | 86 | b.Property("EmailConfirmed"); 87 | 88 | b.Property("LockoutEnabled"); 89 | 90 | b.Property("LockoutEnd"); 91 | 92 | b.Property("NormalizedEmail") 93 | .HasAnnotation("MaxLength", 256); 94 | 95 | b.Property("NormalizedUserName") 96 | .HasAnnotation("MaxLength", 256); 97 | 98 | b.Property("PasswordHash"); 99 | 100 | b.Property("PhoneNumber"); 101 | 102 | b.Property("PhoneNumberConfirmed"); 103 | 104 | b.Property("SecurityStamp"); 105 | 106 | b.Property("TwoFactorEnabled"); 107 | 108 | b.Property("UserName") 109 | .HasAnnotation("MaxLength", 256); 110 | 111 | b.HasKey("Id"); 112 | 113 | b.HasIndex("NormalizedEmail") 114 | .HasAnnotation("Relational:Name", "EmailIndex"); 115 | 116 | b.HasIndex("NormalizedUserName") 117 | .HasAnnotation("Relational:Name", "UserNameIndex"); 118 | 119 | b.HasAnnotation("Relational:TableName", "AspNetUsers"); 120 | }); 121 | 122 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b => 123 | { 124 | b.Property("Id") 125 | .ValueGeneratedOnAdd(); 126 | 127 | b.Property("ClaimType"); 128 | 129 | b.Property("ClaimValue"); 130 | 131 | b.Property("UserId") 132 | .IsRequired(); 133 | 134 | b.HasKey("Id"); 135 | 136 | b.HasAnnotation("Relational:TableName", "AspNetUserClaims"); 137 | }); 138 | 139 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b => 140 | { 141 | b.Property("LoginProvider"); 142 | 143 | b.Property("ProviderKey"); 144 | 145 | b.Property("ProviderDisplayName"); 146 | 147 | b.Property("UserId") 148 | .IsRequired(); 149 | 150 | b.HasKey("LoginProvider", "ProviderKey"); 151 | 152 | b.HasAnnotation("Relational:TableName", "AspNetUserLogins"); 153 | }); 154 | 155 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b => 156 | { 157 | b.Property("UserId"); 158 | 159 | b.Property("RoleId"); 160 | 161 | b.HasKey("UserId", "RoleId"); 162 | 163 | b.HasAnnotation("Relational:TableName", "AspNetUserRoles"); 164 | }); 165 | 166 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b => 167 | { 168 | b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityRole") 169 | .WithMany() 170 | .HasForeignKey("RoleId"); 171 | }); 172 | 173 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b => 174 | { 175 | b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityUser") 176 | .WithMany() 177 | .HasForeignKey("UserId"); 178 | }); 179 | 180 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b => 181 | { 182 | b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityUser") 183 | .WithMany() 184 | .HasForeignKey("UserId"); 185 | }); 186 | 187 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b => 188 | { 189 | b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityRole") 190 | .WithMany() 191 | .HasForeignKey("RoleId"); 192 | 193 | b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityUser") 194 | .WithMany() 195 | .HasForeignKey("UserId"); 196 | }); 197 | } 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Migrations/20151204181739_Identity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.Data.Entity.Migrations; 4 | using Microsoft.Data.Entity.Metadata; 5 | 6 | namespace aspnet5ng2seed.Migrations 7 | { 8 | public partial class Identity : Migration 9 | { 10 | protected override void Up(MigrationBuilder migrationBuilder) 11 | { 12 | migrationBuilder.CreateTable( 13 | name: "AspNetRoles", 14 | columns: table => new 15 | { 16 | Id = table.Column(nullable: false), 17 | ConcurrencyStamp = table.Column(nullable: true), 18 | Name = table.Column(nullable: true), 19 | NormalizedName = table.Column(nullable: true) 20 | }, 21 | constraints: table => 22 | { 23 | table.PrimaryKey("PK_IdentityRole", x => x.Id); 24 | }); 25 | migrationBuilder.CreateTable( 26 | name: "AspNetUsers", 27 | columns: table => new 28 | { 29 | Id = table.Column(nullable: false), 30 | AccessFailedCount = table.Column(nullable: false), 31 | ConcurrencyStamp = table.Column(nullable: true), 32 | Email = table.Column(nullable: true), 33 | EmailConfirmed = table.Column(nullable: false), 34 | LockoutEnabled = table.Column(nullable: false), 35 | LockoutEnd = table.Column(nullable: true), 36 | NormalizedEmail = table.Column(nullable: true), 37 | NormalizedUserName = table.Column(nullable: true), 38 | PasswordHash = table.Column(nullable: true), 39 | PhoneNumber = table.Column(nullable: true), 40 | PhoneNumberConfirmed = table.Column(nullable: false), 41 | SecurityStamp = table.Column(nullable: true), 42 | TwoFactorEnabled = table.Column(nullable: false), 43 | UserName = table.Column(nullable: true) 44 | }, 45 | constraints: table => 46 | { 47 | table.PrimaryKey("PK_IdentityUser", x => x.Id); 48 | }); 49 | migrationBuilder.CreateTable( 50 | name: "AspNetRoleClaims", 51 | columns: table => new 52 | { 53 | Id = table.Column(nullable: false) 54 | .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), 55 | ClaimType = table.Column(nullable: true), 56 | ClaimValue = table.Column(nullable: true), 57 | RoleId = table.Column(nullable: false) 58 | }, 59 | constraints: table => 60 | { 61 | table.PrimaryKey("PK_IdentityRoleClaim", x => x.Id); 62 | table.ForeignKey( 63 | name: "FK_IdentityRoleClaim_IdentityRole_RoleId", 64 | column: x => x.RoleId, 65 | principalTable: "AspNetRoles", 66 | principalColumn: "Id", 67 | onDelete: ReferentialAction.Cascade); 68 | }); 69 | migrationBuilder.CreateTable( 70 | name: "AspNetUserClaims", 71 | columns: table => new 72 | { 73 | Id = table.Column(nullable: false) 74 | .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), 75 | ClaimType = table.Column(nullable: true), 76 | ClaimValue = table.Column(nullable: true), 77 | UserId = table.Column(nullable: false) 78 | }, 79 | constraints: table => 80 | { 81 | table.PrimaryKey("PK_IdentityUserClaim", x => x.Id); 82 | table.ForeignKey( 83 | name: "FK_IdentityUserClaim_IdentityUser_UserId", 84 | column: x => x.UserId, 85 | principalTable: "AspNetUsers", 86 | principalColumn: "Id", 87 | onDelete: ReferentialAction.Cascade); 88 | }); 89 | migrationBuilder.CreateTable( 90 | name: "AspNetUserLogins", 91 | columns: table => new 92 | { 93 | LoginProvider = table.Column(nullable: false), 94 | ProviderKey = table.Column(nullable: false), 95 | ProviderDisplayName = table.Column(nullable: true), 96 | UserId = table.Column(nullable: false) 97 | }, 98 | constraints: table => 99 | { 100 | table.PrimaryKey("PK_IdentityUserLogin", x => new { x.LoginProvider, x.ProviderKey }); 101 | table.ForeignKey( 102 | name: "FK_IdentityUserLogin_IdentityUser_UserId", 103 | column: x => x.UserId, 104 | principalTable: "AspNetUsers", 105 | principalColumn: "Id", 106 | onDelete: ReferentialAction.Cascade); 107 | }); 108 | migrationBuilder.CreateTable( 109 | name: "AspNetUserRoles", 110 | columns: table => new 111 | { 112 | UserId = table.Column(nullable: false), 113 | RoleId = table.Column(nullable: false) 114 | }, 115 | constraints: table => 116 | { 117 | table.PrimaryKey("PK_IdentityUserRole", x => new { x.UserId, x.RoleId }); 118 | table.ForeignKey( 119 | name: "FK_IdentityUserRole_IdentityRole_RoleId", 120 | column: x => x.RoleId, 121 | principalTable: "AspNetRoles", 122 | principalColumn: "Id", 123 | onDelete: ReferentialAction.Cascade); 124 | table.ForeignKey( 125 | name: "FK_IdentityUserRole_IdentityUser_UserId", 126 | column: x => x.UserId, 127 | principalTable: "AspNetUsers", 128 | principalColumn: "Id", 129 | onDelete: ReferentialAction.Cascade); 130 | }); 131 | migrationBuilder.AddColumn( 132 | name: "Username", 133 | table: "Shipment", 134 | nullable: true); 135 | migrationBuilder.CreateIndex( 136 | name: "RoleNameIndex", 137 | table: "AspNetRoles", 138 | column: "NormalizedName"); 139 | migrationBuilder.CreateIndex( 140 | name: "EmailIndex", 141 | table: "AspNetUsers", 142 | column: "NormalizedEmail"); 143 | migrationBuilder.CreateIndex( 144 | name: "UserNameIndex", 145 | table: "AspNetUsers", 146 | column: "NormalizedUserName"); 147 | } 148 | 149 | protected override void Down(MigrationBuilder migrationBuilder) 150 | { 151 | migrationBuilder.DropColumn(name: "Username", table: "Shipment"); 152 | migrationBuilder.DropTable("AspNetRoleClaims"); 153 | migrationBuilder.DropTable("AspNetUserClaims"); 154 | migrationBuilder.DropTable("AspNetUserLogins"); 155 | migrationBuilder.DropTable("AspNetUserRoles"); 156 | migrationBuilder.DropTable("AspNetRoles"); 157 | migrationBuilder.DropTable("AspNetUsers"); 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Migrations/AppDbContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Data.Entity; 3 | using Microsoft.Data.Entity.Infrastructure; 4 | using Microsoft.Data.Entity.Metadata; 5 | using Microsoft.Data.Entity.Migrations; 6 | using aspnet5ng2seed.Models; 7 | 8 | namespace aspnet5ng2seed.Migrations 9 | { 10 | [DbContext(typeof(AppDbContext))] 11 | partial class AppDbContextModelSnapshot : ModelSnapshot 12 | { 13 | protected override void BuildModel(ModelBuilder modelBuilder) 14 | { 15 | modelBuilder 16 | .HasAnnotation("ProductVersion", "7.0.0-rc1-16348") 17 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 18 | 19 | modelBuilder.Entity("aspnet5ng2seed.Models.Shipment", b => 20 | { 21 | b.Property("Id") 22 | .ValueGeneratedOnAdd(); 23 | 24 | b.Property("Destination"); 25 | 26 | b.Property("Origin"); 27 | 28 | b.Property("ShippedDate"); 29 | 30 | b.Property("Username"); 31 | 32 | b.HasKey("Id"); 33 | }); 34 | 35 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRole", b => 36 | { 37 | b.Property("Id"); 38 | 39 | b.Property("ConcurrencyStamp") 40 | .IsConcurrencyToken(); 41 | 42 | b.Property("Name") 43 | .HasAnnotation("MaxLength", 256); 44 | 45 | b.Property("NormalizedName") 46 | .HasAnnotation("MaxLength", 256); 47 | 48 | b.HasKey("Id"); 49 | 50 | b.HasIndex("NormalizedName") 51 | .HasAnnotation("Relational:Name", "RoleNameIndex"); 52 | 53 | b.HasAnnotation("Relational:TableName", "AspNetRoles"); 54 | }); 55 | 56 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b => 57 | { 58 | b.Property("Id") 59 | .ValueGeneratedOnAdd(); 60 | 61 | b.Property("ClaimType"); 62 | 63 | b.Property("ClaimValue"); 64 | 65 | b.Property("RoleId") 66 | .IsRequired(); 67 | 68 | b.HasKey("Id"); 69 | 70 | b.HasAnnotation("Relational:TableName", "AspNetRoleClaims"); 71 | }); 72 | 73 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUser", b => 74 | { 75 | b.Property("Id"); 76 | 77 | b.Property("AccessFailedCount"); 78 | 79 | b.Property("ConcurrencyStamp") 80 | .IsConcurrencyToken(); 81 | 82 | b.Property("Email") 83 | .HasAnnotation("MaxLength", 256); 84 | 85 | b.Property("EmailConfirmed"); 86 | 87 | b.Property("LockoutEnabled"); 88 | 89 | b.Property("LockoutEnd"); 90 | 91 | b.Property("NormalizedEmail") 92 | .HasAnnotation("MaxLength", 256); 93 | 94 | b.Property("NormalizedUserName") 95 | .HasAnnotation("MaxLength", 256); 96 | 97 | b.Property("PasswordHash"); 98 | 99 | b.Property("PhoneNumber"); 100 | 101 | b.Property("PhoneNumberConfirmed"); 102 | 103 | b.Property("SecurityStamp"); 104 | 105 | b.Property("TwoFactorEnabled"); 106 | 107 | b.Property("UserName") 108 | .HasAnnotation("MaxLength", 256); 109 | 110 | b.HasKey("Id"); 111 | 112 | b.HasIndex("NormalizedEmail") 113 | .HasAnnotation("Relational:Name", "EmailIndex"); 114 | 115 | b.HasIndex("NormalizedUserName") 116 | .HasAnnotation("Relational:Name", "UserNameIndex"); 117 | 118 | b.HasAnnotation("Relational:TableName", "AspNetUsers"); 119 | }); 120 | 121 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b => 122 | { 123 | b.Property("Id") 124 | .ValueGeneratedOnAdd(); 125 | 126 | b.Property("ClaimType"); 127 | 128 | b.Property("ClaimValue"); 129 | 130 | b.Property("UserId") 131 | .IsRequired(); 132 | 133 | b.HasKey("Id"); 134 | 135 | b.HasAnnotation("Relational:TableName", "AspNetUserClaims"); 136 | }); 137 | 138 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b => 139 | { 140 | b.Property("LoginProvider"); 141 | 142 | b.Property("ProviderKey"); 143 | 144 | b.Property("ProviderDisplayName"); 145 | 146 | b.Property("UserId") 147 | .IsRequired(); 148 | 149 | b.HasKey("LoginProvider", "ProviderKey"); 150 | 151 | b.HasAnnotation("Relational:TableName", "AspNetUserLogins"); 152 | }); 153 | 154 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b => 155 | { 156 | b.Property("UserId"); 157 | 158 | b.Property("RoleId"); 159 | 160 | b.HasKey("UserId", "RoleId"); 161 | 162 | b.HasAnnotation("Relational:TableName", "AspNetUserRoles"); 163 | }); 164 | 165 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b => 166 | { 167 | b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityRole") 168 | .WithMany() 169 | .HasForeignKey("RoleId"); 170 | }); 171 | 172 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b => 173 | { 174 | b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityUser") 175 | .WithMany() 176 | .HasForeignKey("UserId"); 177 | }); 178 | 179 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b => 180 | { 181 | b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityUser") 182 | .WithMany() 183 | .HasForeignKey("UserId"); 184 | }); 185 | 186 | modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b => 187 | { 188 | b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityRole") 189 | .WithMany() 190 | .HasForeignKey("RoleId"); 191 | 192 | b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityUser") 193 | .WithMany() 194 | .HasForeignKey("UserId"); 195 | }); 196 | } 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Models/AppDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNet.Identity.EntityFramework; 2 | using Microsoft.Data.Entity; 3 | 4 | namespace aspnet5ng2seed.Models 5 | { 6 | public class AppDbContext : IdentityDbContext 7 | { 8 | public DbSet Shipments { get; set; } 9 | 10 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 11 | { 12 | optionsBuilder.UseSqlServer( 13 | @"Server=(localdb)\ProjectsV13;Database=aspnet5ng2seed;Trusted_Connection=true;MultipleActiveResultSets=true;"); 14 | base.OnConfiguring(optionsBuilder); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Models/Seeder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNet.Identity; 6 | using Microsoft.AspNet.Identity.EntityFramework; 7 | 8 | namespace aspnet5ng2seed.Models 9 | { 10 | public class Seeder 11 | { 12 | private readonly AppDbContext _context; 13 | private readonly UserManager _userManager; 14 | 15 | public Seeder( 16 | AppDbContext context, 17 | UserManager userManager) 18 | { 19 | _context = context; 20 | _userManager = userManager; 21 | } 22 | 23 | public async Task EnsureSeedData() 24 | { 25 | if (!_context.Users.Any()) 26 | { 27 | for (int i = 0; i < 2; i++) 28 | { 29 | var user = new IdentityUser 30 | { 31 | UserName = $"test{i}", 32 | Email = $"test{i}@tester.com" 33 | }; 34 | 35 | await _userManager.CreateAsync(user, "123Qwerty!"); 36 | } 37 | } 38 | 39 | if (!_context.Shipments.Any()) 40 | { 41 | var shipments = new List 42 | { 43 | new Shipment 44 | { 45 | Origin = "Sweden, Norrköping", 46 | Destination = "Oslo, Norway", 47 | ShippedDate = DateTime.UtcNow.AddDays(-1.4), 48 | Username = "test0" 49 | }, 50 | new Shipment 51 | { 52 | Origin = "Sweden, Stockholm", 53 | Destination = "Sweden, Gothenburg", 54 | ShippedDate = DateTime.UtcNow, 55 | Username = "test1" 56 | } 57 | }; 58 | 59 | _context.Shipments.AddRange(shipments); 60 | await _context.SaveChangesAsync(); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Models/Shipment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace aspnet5ng2seed.Models 7 | { 8 | public class Shipment 9 | { 10 | public int Id { get; set; } 11 | public string Origin { get; set; } 12 | public string Destination { get; set; } 13 | public DateTime ShippedDate { get; set; } 14 | public string Username { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:2949/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "Hosting:Environment": "Development" 16 | } 17 | }, 18 | "web": { 19 | "commandName": "web", 20 | "environmentVariables": { 21 | "Hosting:Environment": "Development" 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using aspnet5ng2seed.Models; 6 | using Microsoft.AspNet.Builder; 7 | using Microsoft.AspNet.Hosting; 8 | using Microsoft.AspNet.Http; 9 | using Microsoft.AspNet.Identity.EntityFramework; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Newtonsoft.Json.Serialization; 12 | 13 | namespace aspnet5ng2seed 14 | { 15 | public class Startup 16 | { 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services 20 | .AddMvc() 21 | .AddJsonOptions(options => 22 | { 23 | options.SerializerSettings.ContractResolver = 24 | new CamelCasePropertyNamesContractResolver(); 25 | }); 26 | 27 | services.AddEntityFramework() 28 | .AddSqlServer() 29 | .AddDbContext(); 30 | 31 | services.AddIdentity( 32 | config => 33 | { 34 | config.Cookies.ApplicationCookie.LoginPath = "/Auth/Login"; 35 | }) 36 | .AddEntityFrameworkStores(); 37 | 38 | services.AddTransient(); 39 | } 40 | 41 | public void Configure( 42 | IApplicationBuilder app, 43 | Seeder seeder) 44 | { 45 | app.UseIISPlatformHandler(); 46 | 47 | app.UseDefaultFiles(); 48 | app.UseStaticFiles(); 49 | 50 | app.UseIdentity(); 51 | app.UseMvc(config => 52 | { 53 | config.MapRoute( 54 | name: "Default", 55 | template: "{controller}/{action}/{id?}"); 56 | }); 57 | 58 | seeder.EnsureSeedData().Wait(); 59 | } 60 | 61 | // Entry point for the application. 62 | public static void Main(string[] args) => WebApplication.Run(args); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/ViewModels/LoginViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace aspnet5ng2seed.ViewModels 4 | { 5 | public class LoginViewModel 6 | { 7 | [Required] 8 | [Display(Name = "Username")] 9 | public string Username { get; set; } 10 | [Required] 11 | [Display(Name = "Password")] 12 | public string Password { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Views/Auth/Login.cshtml: -------------------------------------------------------------------------------- 1 | @model aspnet5ng2seed.ViewModels.LoginViewModel 2 | 3 | 4 | 5 | 6 | 7 |
8 |
9 |
10 |

Login

11 |
12 |
13 |
14 | 15 | 16 | 17 |
18 |
19 | 20 | 21 | 22 |
23 |
24 | 25 |
26 |
27 |
28 |
29 |
30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers" -------------------------------------------------------------------------------- /src/aspnet5ng2seed/aspnet5ng2seed.xproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 14.0 5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 6 | 7 | 8 | 9 | 10 | 8c980284-5d84-4f1a-bf4e-ab6b3f5b6205 11 | aspnet5ng2seed 12 | ..\..\artifacts\obj\$(MSBuildProjectName) 13 | ..\..\artifacts\bin\$(MSBuildProjectName)\ 14 | 15 | 16 | 17 | 2.0 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ASP.NET", 3 | "private": true, 4 | "dependencies": { 5 | "jquery": "~2.1.4", 6 | "bootstrap": "~3.3.5", 7 | "jquery-validation": "~1.14.0", 8 | "jquery-validation-unobtrusive": "~3.2.3" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/gulpfile.js: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var gulp = require('gulp'); 4 | var rimraf = require('rimraf'); 5 | 6 | var paths = { 7 | npm: './node_modules/', 8 | lib: './wwwroot/lib/' 9 | }; 10 | 11 | var libs = [ 12 | paths.npm + 'angular2/bundles/angular2.dev.js', 13 | paths.npm + 'angular2/bundles/http.dev.js', 14 | paths.npm + 'angular2/bundles/angular2-polyfills.js', 15 | paths.npm + 'es6-shim/es6-shim.js', 16 | paths.npm + 'systemjs/dist/system.js', 17 | paths.npm + 'systemjs/dist/system-polyfills.js' 18 | ]; 19 | 20 | gulp.task('rxjs', function () { 21 | return gulp.src(paths.npm + 'rxjs/**/*.js').pipe(gulp.dest(paths.lib + 'rxjs/')); 22 | }); 23 | 24 | gulp.task('libs', ['rxjs'], function () { 25 | return gulp.src(libs).pipe(gulp.dest(paths.lib)); 26 | }); 27 | 28 | gulp.task('clean', function (callback) { 29 | rimraf(paths.lib, callback); 30 | }); -------------------------------------------------------------------------------- /src/aspnet5ng2seed/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0", 3 | "name": "ASP.NET", 4 | "private": true, 5 | "dependencies": { 6 | "angular2": "^2.0.0-beta.0", 7 | "es6-shim": "0.33.13", 8 | "systemjs": "0.19.6", 9 | "reflect-metadata": "^0.1.2", 10 | "rxjs": "^5.0.0-beta.0", 11 | "zone.js": "^0.5.10" 12 | }, 13 | "devDependencies": { 14 | "gulp": "^3.9.0", 15 | "rimraf": "^2.4.4" 16 | } 17 | } -------------------------------------------------------------------------------- /src/aspnet5ng2seed/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.0-*", 3 | "compilationOptions": { 4 | "emitEntryPoint": true 5 | }, 6 | 7 | "dependencies": { 8 | "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final", 9 | "EntityFramework.Core": "7.0.0-rc1-final", 10 | "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final", 11 | "EntityFramework.Commands": "7.0.0-rc1-final", 12 | "Microsoft.AspNet.Identity": "3.0.0-rc1-final", 13 | "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final", 14 | "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", 15 | "Microsoft.AspNet.Mvc": "6.0.0-rc1-final", 16 | "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", 17 | "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final" 18 | }, 19 | 20 | "commands": { 21 | "web": "Microsoft.AspNet.Server.Kestrel", 22 | "ef": "EntityFramework.Commands" 23 | }, 24 | 25 | "frameworks": { 26 | "dnx451": { }, 27 | "dnxcore50": { } 28 | }, 29 | 30 | "exclude": [ 31 | "wwwroot", 32 | "node_modules" 33 | ], 34 | "publishExclude": [ 35 | "**.user", 36 | "**.vspscc" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/scripts/app.ts: -------------------------------------------------------------------------------- 1 | import { bootstrap } from 'angular2/platform/browser'; 2 | import { Component, View } from 'angular2/core'; 3 | //import { NgFor } from 'angular2/common'; 4 | import { Http, HTTP_PROVIDERS, Response } from 'angular2/http'; 5 | import { Shipment } from './model'; 6 | import 'rxjs/add/operator/map'; 7 | 8 | @Component({ 9 | selector: "my-app" 10 | }) 11 | @View({ 12 | //directives: [NgFor], 13 | templateUrl: 'app/partials/app.html' 14 | }) 15 | class AppComponent { 16 | shipments: Array = []; 17 | 18 | constructor(public http: Http) { 19 | this.getData(); 20 | } 21 | 22 | getData() { 23 | this.http.get('http://localhost:2949/api/data') 24 | .map(res => (res).json()) 25 | .map((shipments: Array) => { 26 | let result: Array = []; 27 | if (shipments) { 28 | shipments.forEach(shipment => { 29 | result.push( 30 | new Shipment( 31 | shipment.id, 32 | shipment.origin, 33 | shipment.destination, 34 | new Date(shipment.shippedDate))); 35 | }); 36 | } 37 | 38 | return result; 39 | }). 40 | subscribe( 41 | data => { 42 | this.shipments = data; 43 | console.log(this.shipments); 44 | }, 45 | err => console.log(err) 46 | ); 47 | } 48 | } 49 | 50 | bootstrap(AppComponent, [HTTP_PROVIDERS]); -------------------------------------------------------------------------------- /src/aspnet5ng2seed/scripts/model.ts: -------------------------------------------------------------------------------- 1 | export class Shipment { 2 | constructor( 3 | public id: number, 4 | public origin: string, 5 | public destination: string, 6 | public shippedDate: any 7 | ) { } 8 | } 9 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/scripts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": false, 4 | "noEmitOnError": true, 5 | "removeComments": false, 6 | "sourceMap": false, 7 | "target": "es5", 8 | "module": "commonjs", 9 | "outDir": "../wwwroot/app/", 10 | "experimentalDecorators": true, 11 | "emitDecoratorMetadata": true 12 | }, 13 | "exclude": [ 14 | "node_modules", 15 | "wwwroot" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/wwwroot/app/partials/app.html: -------------------------------------------------------------------------------- 1 | 
2 | {{shipment.shippedDate | date:'yyyy-MM-dd HH:mm'}} 3 | {{shipment.origin}} 4 | {{shipment.destination}} 5 |
-------------------------------------------------------------------------------- /src/aspnet5ng2seed/wwwroot/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Angular2 Aspnet5 Seed 6 | 7 | 8 | 9 | 17 | 18 | 19 | 22 | 23 | 24 | Loading... 25 | 26 | -------------------------------------------------------------------------------- /src/aspnet5ng2seed/wwwroot/web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | --------------------------------------------------------------------------------