From 039fe574d69d274b6c727f87f0436a062f6aa7d3 Mon Sep 17 00:00:00 2001 From: Uncled1023 Date: Tue, 24 Nov 2015 16:52:20 -0800 Subject: [PATCH] Added automatic Database Migration on startup. Moved Models and ViewModels into their respective Areas. Added Groups/Roles to models. --- Teknik/App_Start/BundleConfig.cs | 2 +- Teknik/{ => Areas/Blog}/Models/Blog.cs | 3 +- Teknik/{ => Areas/Blog}/Models/Post.cs | 2 +- Teknik/Areas/Home/Controllers/HomeController.cs | 1 + Teknik/Areas/Home/Views/Home/Index.cshtml | 2 +- .../Areas/Profile/Controllers/ProfileController.cs | 81 +++++++++ Teknik/Areas/Profile/Models/AuthUser.cs | 14 ++ Teknik/Areas/Profile/Models/Group.cs | 19 ++ Teknik/Areas/Profile/Models/PermissionTarget.cs | 15 ++ Teknik/Areas/Profile/Models/PermissionType.cs | 15 ++ Teknik/Areas/Profile/Models/Role.cs | 21 +++ Teknik/{ => Areas/Profile}/Models/User.cs | 6 +- Teknik/Areas/Profile/Models/UserIdentity.cs | 12 ++ Teknik/Areas/Profile/ProfileAreaRegistration.cs | 33 ++++ .../Profile}/ViewModels/LoginViewModel.cs | 2 +- .../Profile}/ViewModels/RegisterViewModel.cs | 3 +- Teknik/Areas/Profile/Views/Profile/Index.cshtml | 1 + .../{ => Areas/Profile}/Views/Profile/Login.cshtml | 4 +- .../Profile}/Views/Profile/Register.cshtml | 2 +- Teknik/Areas/Profile/Views/_ViewStart.cshtml | 3 + Teknik/Areas/Profile/Views/web.config | 36 ++++ Teknik/Controllers/ProfileController.cs | 193 --------------------- Teknik/Global.asax.cs | 4 + Teknik/Migrations/Configuration.cs | 32 ++++ Teknik/Models/TeknikEntities.cs | 10 +- Teknik/Teknik.csproj | 30 ++-- Teknik/Views/Profile/Index.cshtml | 1 - Teknik/Views/Shared/_Layout.cshtml | 2 +- Teknik/Views/Shared/_LoginPartial.cshtml | 8 +- 29 files changed, 337 insertions(+), 220 deletions(-) rename Teknik/{ => Areas/Blog}/Models/Blog.cs (78%) rename Teknik/{ => Areas/Blog}/Models/Post.cs (93%) create mode 100644 Teknik/Areas/Profile/Controllers/ProfileController.cs create mode 100644 Teknik/Areas/Profile/Models/AuthUser.cs create mode 100644 Teknik/Areas/Profile/Models/Group.cs create mode 100644 Teknik/Areas/Profile/Models/PermissionTarget.cs create mode 100644 Teknik/Areas/Profile/Models/PermissionType.cs create mode 100644 Teknik/Areas/Profile/Models/Role.cs rename Teknik/{ => Areas/Profile}/Models/User.cs (78%) create mode 100644 Teknik/Areas/Profile/Models/UserIdentity.cs create mode 100644 Teknik/Areas/Profile/ProfileAreaRegistration.cs rename Teknik/{ => Areas/Profile}/ViewModels/LoginViewModel.cs (96%) rename Teknik/{ => Areas/Profile}/ViewModels/RegisterViewModel.cs (93%) create mode 100644 Teknik/Areas/Profile/Views/Profile/Index.cshtml rename Teknik/{ => Areas/Profile}/Views/Profile/Login.cshtml (89%) rename Teknik/{ => Areas/Profile}/Views/Profile/Register.cshtml (94%) create mode 100644 Teknik/Areas/Profile/Views/_ViewStart.cshtml create mode 100644 Teknik/Areas/Profile/Views/web.config delete mode 100644 Teknik/Controllers/ProfileController.cs create mode 100644 Teknik/Migrations/Configuration.cs delete mode 100644 Teknik/Views/Profile/Index.cshtml diff --git a/Teknik/App_Start/BundleConfig.cs b/Teknik/App_Start/BundleConfig.cs index 9851cfa..8bc0f70 100644 --- a/Teknik/App_Start/BundleConfig.cs +++ b/Teknik/App_Start/BundleConfig.cs @@ -30,7 +30,7 @@ namespace Teknik bundles.Add(new ScriptBundle("~/bundles/common").Include( "~/Scripts/common.js")); - bundles.Add(new StyleBundle("~/Content/css").Include( + bundles.Add(new StyleBundle("~/Content/CSS/Common").Include( "~/Content/CSS/bootstrap.css", "~/Content/CSS/font-awesome.css", "~/Content/CSS/Site.css")); diff --git a/Teknik/Models/Blog.cs b/Teknik/Areas/Blog/Models/Blog.cs similarity index 78% rename from Teknik/Models/Blog.cs rename to Teknik/Areas/Blog/Models/Blog.cs index d8f948d..bc65c8b 100644 --- a/Teknik/Models/Blog.cs +++ b/Teknik/Areas/Blog/Models/Blog.cs @@ -1,7 +1,8 @@ using System; using System.Collections.Generic; +using Teknik.Areas.Profile.Models; -namespace Teknik.Models +namespace Teknik.Areas.Blog.Models { public class Blog { diff --git a/Teknik/Models/Post.cs b/Teknik/Areas/Blog/Models/Post.cs similarity index 93% rename from Teknik/Models/Post.cs rename to Teknik/Areas/Blog/Models/Post.cs index b362044..57a802c 100644 --- a/Teknik/Models/Post.cs +++ b/Teknik/Areas/Blog/Models/Post.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace Teknik.Models +namespace Teknik.Areas.Blog.Models { public class Post { diff --git a/Teknik/Areas/Home/Controllers/HomeController.cs b/Teknik/Areas/Home/Controllers/HomeController.cs index c9eeb55..f927aca 100644 --- a/Teknik/Areas/Home/Controllers/HomeController.cs +++ b/Teknik/Areas/Home/Controllers/HomeController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; +using Teknik.Areas.Blog.Models; using Teknik.Controllers; using Teknik.Models; diff --git a/Teknik/Areas/Home/Views/Home/Index.cshtml b/Teknik/Areas/Home/Views/Home/Index.cshtml index 2f9523b..e6f023b 100644 --- a/Teknik/Areas/Home/Views/Home/Index.cshtml +++ b/Teknik/Areas/Home/Views/Home/Index.cshtml @@ -1,4 +1,4 @@ -@using Teknik.Models +@using Teknik.Areas.Blog.Models
diff --git a/Teknik/Areas/Profile/Controllers/ProfileController.cs b/Teknik/Areas/Profile/Controllers/ProfileController.cs new file mode 100644 index 0000000..57aedb0 --- /dev/null +++ b/Teknik/Areas/Profile/Controllers/ProfileController.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using System.Web.Security; +using Teknik.Areas.Profile.ViewModels; +using Teknik.Controllers; +using Teknik.Models; +using Teknik.ViewModels; + +namespace Teknik.Areas.Profile.Controllers +{ + public class ProfileController : DefaultController + { + private TeknikEntities db = new TeknikEntities(); + + // GET: Profile/Profile + public ActionResult Index() + { + ViewBag.Title = Config.Title + " - Profile"; + ViewBag.Message = "View Your Profile"; + + return View(); + } + + [HttpGet] + [AllowAnonymous] + // GET: Profile + public ActionResult Login() + { + return View(); + } + + [HttpPost] + [AllowAnonymous] + public ActionResult Login(LoginViewModel model) + { + if (ModelState.IsValid) + { + if (model.IsValid()) + { + FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe); + return Json(new { result = "true" }); + } + } + return Json(new { error = "Invalid User name or Password." }); + } + + public ActionResult Logout() + { + FormsAuthentication.SignOut(); + return RedirectToAction("Index", "Home", new { Area = "Home" }); + } + + [HttpPost] + [AllowAnonymous] + public ActionResult Register(RegisterViewModel model) + { + if (ModelState.IsValid) + { + var foundUser = db.Users.Where(b => b.Username == model.Username); + if (foundUser.Any()) + { + return Json(new { error = "That username already exists." }); + } + if (model.Password != model.ConfirmPassword) + { + return Json(new { error = "Passwords must match." }); + } + if (model.Insert()) + { + return RedirectToAction("Login", "Profile", new LoginViewModel { Username = model.Username, Password = model.Password }); + } + return Json(new { error = "You must include all fields." }); + } + return Json(new { error = "You must include all fields." }); + } + + } +} \ No newline at end of file diff --git a/Teknik/Areas/Profile/Models/AuthUser.cs b/Teknik/Areas/Profile/Models/AuthUser.cs new file mode 100644 index 0000000..b5eb6ac --- /dev/null +++ b/Teknik/Areas/Profile/Models/AuthUser.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNet.Identity.EntityFramework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Teknik.Areas.Profile.Models +{ + public class AuthUser : IdentityUser + { + public User User { get; set; } + } +} diff --git a/Teknik/Areas/Profile/Models/Group.cs b/Teknik/Areas/Profile/Models/Group.cs new file mode 100644 index 0000000..a4c6576 --- /dev/null +++ b/Teknik/Areas/Profile/Models/Group.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Teknik.Areas.Profile.Models +{ + public class Group + { + public int GroupId { get; set; } + + public string Name { get; set; } + + public string Description { get; set; } + + public List Roles { get; set; } + } +} diff --git a/Teknik/Areas/Profile/Models/PermissionTarget.cs b/Teknik/Areas/Profile/Models/PermissionTarget.cs new file mode 100644 index 0000000..c07d0c8 --- /dev/null +++ b/Teknik/Areas/Profile/Models/PermissionTarget.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Teknik.Areas.Profile.Models +{ + public enum PermissionTarget + { + Blog, + User, + Profile + } +} diff --git a/Teknik/Areas/Profile/Models/PermissionType.cs b/Teknik/Areas/Profile/Models/PermissionType.cs new file mode 100644 index 0000000..c171214 --- /dev/null +++ b/Teknik/Areas/Profile/Models/PermissionType.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Teknik.Areas.Profile.Models +{ + public enum PermissionType + { + Add, + Edit, + Delete + } +} diff --git a/Teknik/Areas/Profile/Models/Role.cs b/Teknik/Areas/Profile/Models/Role.cs new file mode 100644 index 0000000..ceb76af --- /dev/null +++ b/Teknik/Areas/Profile/Models/Role.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Teknik.Areas.Profile.Models +{ + public class Role + { + public int RoleId { get; set; } + + public string Name { get; set; } + + public string Description { get; set; } + + public PermissionType Permission { get; set; } + + public PermissionTarget Target { get; set; } + } +} diff --git a/Teknik/Models/User.cs b/Teknik/Areas/Profile/Models/User.cs similarity index 78% rename from Teknik/Models/User.cs rename to Teknik/Areas/Profile/Models/User.cs index 39170ea..2637160 100644 --- a/Teknik/Models/User.cs +++ b/Teknik/Areas/Profile/Models/User.cs @@ -1,8 +1,9 @@ using System; using System.ComponentModel.DataAnnotations; using Microsoft.AspNet.Identity.EntityFramework; +using System.Collections.Generic; -namespace Teknik.Models +namespace Teknik.Areas.Profile.Models { public class User { @@ -16,12 +17,15 @@ namespace Teknik.Models public DateTime LastSeen { get; set; } + public List Groups { get; set; } + public User() { Username = String.Empty; HashedPassword = String.Empty; JoinDate = DateTime.Now; LastSeen = DateTime.Now; + Groups = new List(); } } } \ No newline at end of file diff --git a/Teknik/Areas/Profile/Models/UserIdentity.cs b/Teknik/Areas/Profile/Models/UserIdentity.cs new file mode 100644 index 0000000..386041b --- /dev/null +++ b/Teknik/Areas/Profile/Models/UserIdentity.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Teknik.Areas.Profile.Models +{ + public class UserIdentity : User + { + } +} diff --git a/Teknik/Areas/Profile/ProfileAreaRegistration.cs b/Teknik/Areas/Profile/ProfileAreaRegistration.cs new file mode 100644 index 0000000..a37c8b5 --- /dev/null +++ b/Teknik/Areas/Profile/ProfileAreaRegistration.cs @@ -0,0 +1,33 @@ +using System.Web.Mvc; + +namespace Teknik.Areas.Profile +{ + public class ProfileAreaRegistration : AreaRegistration + { + public override string AreaName + { + get + { + return "Profile"; + } + } + + public override void RegisterArea(AreaRegistrationContext context) + { + context.MapSubdomainRoute( + "Profile_dev", // Route name + "dev", + "Profile/{controller}/{action}", // URL with parameters + new { controller = "Profile", action = "Index" }, // Parameter defaults + new[] { typeof(Controllers.ProfileController).Namespace } + ); + context.MapSubdomainRoute( + "Profile_default", // Route name + "profile", + "{controller}/{action}", // URL with parameters + new { controller = "Profile", action = "Index" }, // Parameter defaults + new[] { typeof(Controllers.ProfileController).Namespace } + ); + } + } +} \ No newline at end of file diff --git a/Teknik/ViewModels/LoginViewModel.cs b/Teknik/Areas/Profile/ViewModels/LoginViewModel.cs similarity index 96% rename from Teknik/ViewModels/LoginViewModel.cs rename to Teknik/Areas/Profile/ViewModels/LoginViewModel.cs index 492cdcb..199e0f9 100644 --- a/Teknik/ViewModels/LoginViewModel.cs +++ b/Teknik/Areas/Profile/ViewModels/LoginViewModel.cs @@ -7,7 +7,7 @@ using System.Web.Security; using Teknik.Helpers; using Teknik.Models; -namespace Teknik.ViewModels +namespace Teknik.Areas.Profile.ViewModels { public class LoginViewModel { diff --git a/Teknik/ViewModels/RegisterViewModel.cs b/Teknik/Areas/Profile/ViewModels/RegisterViewModel.cs similarity index 93% rename from Teknik/ViewModels/RegisterViewModel.cs rename to Teknik/Areas/Profile/ViewModels/RegisterViewModel.cs index 31523ae..c2d8cae 100644 --- a/Teknik/ViewModels/RegisterViewModel.cs +++ b/Teknik/Areas/Profile/ViewModels/RegisterViewModel.cs @@ -1,9 +1,10 @@ using System; using System.ComponentModel.DataAnnotations; +using Teknik.Areas.Profile.Models; using Teknik.Helpers; using Teknik.Models; -namespace Teknik.ViewModels +namespace Teknik.Areas.Profile.ViewModels { public class RegisterViewModel { diff --git a/Teknik/Areas/Profile/Views/Profile/Index.cshtml b/Teknik/Areas/Profile/Views/Profile/Index.cshtml new file mode 100644 index 0000000..49b7aaf --- /dev/null +++ b/Teknik/Areas/Profile/Views/Profile/Index.cshtml @@ -0,0 +1 @@ +@using Teknik.Models diff --git a/Teknik/Views/Profile/Login.cshtml b/Teknik/Areas/Profile/Views/Profile/Login.cshtml similarity index 89% rename from Teknik/Views/Profile/Login.cshtml rename to Teknik/Areas/Profile/Views/Profile/Login.cshtml index 634ab2a..edeac94 100644 --- a/Teknik/Views/Profile/Login.cshtml +++ b/Teknik/Areas/Profile/Views/Profile/Login.cshtml @@ -1,6 +1,6 @@ -@model Teknik.ViewModels.LoginViewModel +@model Teknik.Areas.Profile.ViewModels.LoginViewModel -
+ @Html.ValidationSummary(true, "Login failed. Check your login details.")
diff --git a/Teknik/Views/Profile/Register.cshtml b/Teknik/Areas/Profile/Views/Profile/Register.cshtml similarity index 94% rename from Teknik/Views/Profile/Register.cshtml rename to Teknik/Areas/Profile/Views/Profile/Register.cshtml index 74e189e..c5cda14 100644 --- a/Teknik/Views/Profile/Register.cshtml +++ b/Teknik/Areas/Profile/Views/Profile/Register.cshtml @@ -1,4 +1,4 @@ -@model Teknik.ViewModels.RegisterViewModel +@model Teknik.Areas.Profile.ViewModels.RegisterViewModel @Html.ValidationSummary(true, "Registration failed. Check your registration details.") diff --git a/Teknik/Areas/Profile/Views/_ViewStart.cshtml b/Teknik/Areas/Profile/Views/_ViewStart.cshtml new file mode 100644 index 0000000..2de6241 --- /dev/null +++ b/Teknik/Areas/Profile/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "~/Views/Shared/_Layout.cshtml"; +} diff --git a/Teknik/Areas/Profile/Views/web.config b/Teknik/Areas/Profile/Views/web.config new file mode 100644 index 0000000..ada5aaf --- /dev/null +++ b/Teknik/Areas/Profile/Views/web.config @@ -0,0 +1,36 @@ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Teknik/Controllers/ProfileController.cs b/Teknik/Controllers/ProfileController.cs deleted file mode 100644 index edea631..0000000 --- a/Teknik/Controllers/ProfileController.cs +++ /dev/null @@ -1,193 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.Entity; -using System.Linq; -using System.Net; -using System.Security.Cryptography; -using System.Security.Policy; -using System.Text; -using System.Web; -using System.Web.Mvc; -using System.Web.Security; -using SecurityDriven.Inferno.Hash; -using SecurityDriven.Inferno.Mac; -using Teknik.Models; -using Teknik.ViewModels; -using SHA384 = Teknik.Helpers.SHA384; - -namespace Teknik.Controllers -{ - public class ProfileController : DefaultController - { - private TeknikEntities db = new TeknikEntities(); - - [AllowAnonymous] - // GET: Profile - public ActionResult Index() - { - return View(); - } - - [HttpGet] - [AllowAnonymous] - // GET: Profile - public ActionResult Login() - { - return View(); - } - - [HttpPost] - [AllowAnonymous] - public ActionResult Login(LoginViewModel model) - { - if (ModelState.IsValid) - { - if (model.IsValid()) - { - FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe); - return Json(new {result = "true"}); - } - } - return Json(new { error = "Invalid User name or Password." }); - } - - public ActionResult Logout() - { - FormsAuthentication.SignOut(); - return RedirectToAction("Index", "Home"); - } - - [HttpPost] - [AllowAnonymous] - public ActionResult Register(RegisterViewModel model) - { - if (ModelState.IsValid) - { - var foundUser = db.Users.Where(b => b.Username == model.Username); - if (foundUser.Any()) - { - return Json(new {error = "That username already exists."}); - } - if (model.Password != model.ConfirmPassword) - { - return Json(new {error = "Passwords must match."}); - } - if (model.Insert()) - { - return RedirectToAction("Login", "Profile", new LoginViewModel { Username = model.Username, Password = model.Password }); - } - return Json(new { error = "You must include all fields." }); - } - return Json(new { error = "You must include all fields." }); - } - - // GET: Profile/Details/5 - public ActionResult Details(int? id) - { - if (ModelState.IsValid) - { - if (id == null) - { - return new HttpStatusCodeResult(HttpStatusCode.BadRequest); - } - User user = db.Users.Find(id); - if (user == null) - { - return HttpNotFound(); - } - return View(user); - } - return HttpNotFound(); - } - - // GET: Profile/Create - public ActionResult Create() - { - return View(); - } - - // POST: Profile/Create - // To protect from overposting attacks, please enable the specific properties you want to bind to, for - // more details see http://go.microsoft.com/fwlink/?LinkId=317598. - [HttpPost] - [ValidateAntiForgeryToken] - public ActionResult Create([Bind(Include = "UserId,Username")] User user) - { - if (ModelState.IsValid) - { - db.Users.Add(user); - db.SaveChanges(); - return RedirectToAction("Index"); - } - - return View(user); - } - - // GET: Profile/Edit/5 - public ActionResult Edit(int? id) - { - if (id == null) - { - return new HttpStatusCodeResult(HttpStatusCode.BadRequest); - } - User user = db.Users.Find(id); - if (user == null) - { - return HttpNotFound(); - } - return View(user); - } - - // POST: Profile/Edit/5 - // To protect from overposting attacks, please enable the specific properties you want to bind to, for - // more details see http://go.microsoft.com/fwlink/?LinkId=317598. - [HttpPost] - [ValidateAntiForgeryToken] - public ActionResult Edit([Bind(Include = "UserId,Username")] User user) - { - if (ModelState.IsValid) - { - db.Entry(user).State = EntityState.Modified; - db.SaveChanges(); - return RedirectToAction("Index"); - } - return View(user); - } - - // GET: Profile/Delete/5 - public ActionResult Delete(int? id) - { - if (id == null) - { - return new HttpStatusCodeResult(HttpStatusCode.BadRequest); - } - User user = db.Users.Find(id); - if (user == null) - { - return HttpNotFound(); - } - return View(user); - } - - // POST: Profile/Delete/5 - [HttpPost, ActionName("Delete")] - [ValidateAntiForgeryToken] - public ActionResult DeleteConfirmed(int id) - { - User user = db.Users.Find(id); - db.Users.Remove(user); - db.SaveChanges(); - return RedirectToAction("Index"); - } - - protected override void Dispose(bool disposing) - { - if (disposing) - { - db.Dispose(); - } - base.Dispose(disposing); - } - } -} diff --git a/Teknik/Global.asax.cs b/Teknik/Global.asax.cs index a715f0d..41b1b63 100644 --- a/Teknik/Global.asax.cs +++ b/Teknik/Global.asax.cs @@ -8,6 +8,8 @@ using System.Web.Routing; using Teknik.Models; using System.Data.Entity; using System.Web.Security; +using Teknik.Migrations; +using System.Data.Entity.Migrations; namespace Teknik { @@ -15,6 +17,8 @@ namespace Teknik { protected void Application_Start() { + Database.SetInitializer(new MigrateDatabaseToLatestVersion()); + AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); diff --git a/Teknik/Migrations/Configuration.cs b/Teknik/Migrations/Configuration.cs new file mode 100644 index 0000000..9e374db --- /dev/null +++ b/Teknik/Migrations/Configuration.cs @@ -0,0 +1,32 @@ +namespace Teknik.Migrations +{ + using System; + using System.Data.Entity; + using System.Data.Entity.Migrations; + using System.Linq; + + internal sealed class Configuration : DbMigrationsConfiguration + { + public Configuration() + { + AutomaticMigrationsEnabled = true; + AutomaticMigrationDataLossAllowed = true; + } + + protected override void Seed(Teknik.Models.TeknikEntities context) + { + // This method will be called after migrating to the latest version. + + // You can use the DbSet.AddOrUpdate() helper extension method + // to avoid creating duplicate seed data. E.g. + // + // context.People.AddOrUpdate( + // p => p.FullName, + // new Person { FullName = "Andrew Peters" }, + // new Person { FullName = "Brice Lambson" }, + // new Person { FullName = "Rowan Miller" } + // ); + // + } + } +} diff --git a/Teknik/Models/TeknikEntities.cs b/Teknik/Models/TeknikEntities.cs index 7ab91e3..f2e28c0 100644 --- a/Teknik/Models/TeknikEntities.cs +++ b/Teknik/Models/TeknikEntities.cs @@ -1,17 +1,25 @@ -using System.Data.Entity; +using Microsoft.AspNet.Identity.EntityFramework; +using System.Data.Entity; using System.Data.Entity.Infrastructure; +using Teknik.Areas.Blog.Models; +using Teknik.Areas.Profile.Models; +using Teknik.Migrations; namespace Teknik.Models { public class TeknikEntities : DbContext { public DbSet Users { get; set; } + public DbSet Groups { get; set; } + public DbSet Roles { get; set; } public DbSet Blogs { get; set; } public DbSet Posts { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity().ToTable("Users"); + modelBuilder.Entity().ToTable("Groups"); + modelBuilder.Entity().ToTable("Roles"); modelBuilder.Entity().ToTable("Blogs"); modelBuilder.Entity().ToTable("Posts"); diff --git a/Teknik/Teknik.csproj b/Teknik/Teknik.csproj index 48936ba..abc03d2 100644 --- a/Teknik/Teknik.csproj +++ b/Teknik/Teknik.csproj @@ -145,21 +145,29 @@ + + + + - Global.asax - + + + + + + - - - - + + + + @@ -214,6 +222,9 @@ + + + @@ -250,15 +261,13 @@ - - - + + - @@ -268,6 +277,7 @@ + diff --git a/Teknik/Views/Profile/Index.cshtml b/Teknik/Views/Profile/Index.cshtml deleted file mode 100644 index 5f28270..0000000 --- a/Teknik/Views/Profile/Index.cshtml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Teknik/Views/Shared/_Layout.cshtml b/Teknik/Views/Shared/_Layout.cshtml index 992d02a..19ce1a1 100644 --- a/Teknik/Views/Shared/_Layout.cshtml +++ b/Teknik/Views/Shared/_Layout.cshtml @@ -8,7 +8,7 @@ @ViewBag.Title - @Styles.Render("~/Content/css") + @Styles.Render("~/Content/CSS/Common") @Scripts.Render("~/bundles/modernizr") @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/markdown") diff --git a/Teknik/Views/Shared/_LoginPartial.cshtml b/Teknik/Views/Shared/_LoginPartial.cshtml index 999863b..7053e5d 100644 --- a/Teknik/Views/Shared/_LoginPartial.cshtml +++ b/Teknik/Views/Shared/_LoginPartial.cshtml @@ -12,14 +12,14 @@
  • Blog
  • - if (User.Identity.Group == Groups.Founder) + @if (User.IsInRole("Admin")) {
  • Administration
  • }
  • - @Html.ActionLink("Sign Out", "Logout", "Profile", new { area = "Profile" }) + @Html.ActionLink("Sign Out", "Logout", "Profile", new { area = "Profile" }, null)
  • @@ -29,14 +29,14 @@ else }