From 4a18d9cd9ac69fd85e12ff583235537f90561efd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Fri, 12 Feb 2016 02:09:31 +0100 Subject: [PATCH] Update Models according to DB change --- .../Controllers/ProjectTasksController.cs | 10 +- Projects/Controllers/ProjectsController.cs | 10 +- Projects/Models/Metadata.cs | 2 +- .../{Model1.Context.cs => Model.Context.cs} | 3 +- .../{Model1.Context.tt => Model.Context.tt} | 2 +- .../{Model1.Designer.cs => Model.Designer.cs} | 2 +- Projects/Models/{Model1.cs => Model.cs} | 0 Projects/Models/{Model1.edmx => Model.edmx} | 166 ++++++++++++------ ...Model1.edmx.diagram => Model.edmx.diagram} | 14 +- Projects/Models/{Model1.tt => Model.tt} | 2 +- Projects/Models/PartialClasses.cs | 4 +- Projects/Models/Project.cs | 2 +- Projects/Models/ProjectTask.cs | 2 +- Projects/Models/TaskStatus.cs | 2 +- Projects/Models/{ProjectUser.cs => User.cs} | 6 +- Projects/Models/UserRole.cs | 29 +++ Projects/Projects.csproj | 51 +++--- Projects/Views/ProjectTasks/Delete.cshtml | 4 +- Projects/Views/ProjectTasks/Details.cshtml | 4 +- Projects/Views/ProjectTasks/Index.cshtml | 4 +- Projects/Views/Projects/Delete.cshtml | 4 +- Projects/Views/Projects/Details.cshtml | 4 +- Projects/Views/Projects/Index.cshtml | 4 +- Projects/Web.config | 3 +- 24 files changed, 216 insertions(+), 118 deletions(-) rename Projects/Models/{Model1.Context.cs => Model.Context.cs} (90%) rename Projects/Models/{Model1.Context.tt => Model.Context.tt} (99%) rename Projects/Models/{Model1.Designer.cs => Model.Designer.cs} (80%) rename Projects/Models/{Model1.cs => Model.cs} (100%) rename Projects/Models/{Model1.edmx => Model.edmx} (75%) rename Projects/Models/{Model1.edmx.diagram => Model.edmx.diagram} (61%) rename Projects/Models/{Model1.tt => Model.tt} (99%) rename Projects/Models/{ProjectUser.cs => User.cs} (89%) create mode 100644 Projects/Models/UserRole.cs diff --git a/Projects/Controllers/ProjectTasksController.cs b/Projects/Controllers/ProjectTasksController.cs index 456bac8..d738edc 100644 --- a/Projects/Controllers/ProjectTasksController.cs +++ b/Projects/Controllers/ProjectTasksController.cs @@ -17,7 +17,7 @@ namespace Projects.Controllers // GET: ProjectTasks public ActionResult Index() { - var projectTasks = db.ProjectTasks.Include(p => p.Project).Include(p => p.TaskStatus).Include(p => p.ProjectUser); + var projectTasks = db.ProjectTasks.Include(p => p.Project).Include(p => p.TaskStatus).Include(p => p.User); return View(projectTasks.ToList()); } @@ -41,7 +41,7 @@ namespace Projects.Controllers { ViewBag.project_id = new SelectList(db.Projects, "id", "name"); ViewBag.task_status_id = new SelectList(db.TaskStatuses, "int", "status"); - ViewBag.user_id = new SelectList(db.ProjectUsers, "id", "login"); + ViewBag.user_id = new SelectList(db.Users, "id", "login"); return View(); } @@ -61,7 +61,7 @@ namespace Projects.Controllers ViewBag.project_id = new SelectList(db.Projects, "id", "name", projectTask.project_id); ViewBag.task_status_id = new SelectList(db.TaskStatuses, "int", "status", projectTask.task_status_id); - ViewBag.user_id = new SelectList(db.ProjectUsers, "id", "login", projectTask.user_id); + ViewBag.user_id = new SelectList(db.Users, "id", "login", projectTask.user_id); return View(projectTask); } @@ -79,7 +79,7 @@ namespace Projects.Controllers } ViewBag.project_id = new SelectList(db.Projects, "id", "name", projectTask.project_id); ViewBag.task_status_id = new SelectList(db.TaskStatuses, "int", "status", projectTask.task_status_id); - ViewBag.user_id = new SelectList(db.ProjectUsers, "id", "login", projectTask.user_id); + ViewBag.user_id = new SelectList(db.Users, "id", "login", projectTask.user_id); return View(projectTask); } @@ -98,7 +98,7 @@ namespace Projects.Controllers } ViewBag.project_id = new SelectList(db.Projects, "id", "name", projectTask.project_id); ViewBag.task_status_id = new SelectList(db.TaskStatuses, "int", "status", projectTask.task_status_id); - ViewBag.user_id = new SelectList(db.ProjectUsers, "id", "login", projectTask.user_id); + ViewBag.user_id = new SelectList(db.Users, "id", "login", projectTask.user_id); return View(projectTask); } diff --git a/Projects/Controllers/ProjectsController.cs b/Projects/Controllers/ProjectsController.cs index 3827128..73205a8 100644 --- a/Projects/Controllers/ProjectsController.cs +++ b/Projects/Controllers/ProjectsController.cs @@ -16,7 +16,7 @@ namespace Projects.Models // GET: Projects public ActionResult Index() { - var projects = db.Projects.Include(p => p.ProjectUser); + var projects = db.Projects.Include(p => p.User); return View(projects.ToList()); } @@ -38,7 +38,7 @@ namespace Projects.Models // GET: Projects/Create public ActionResult Create() { - ViewBag.user_id = new SelectList(db.ProjectUsers, "id", "login"); + ViewBag.user_id = new SelectList(db.Users, "id", "login"); return View(); } @@ -56,7 +56,7 @@ namespace Projects.Models return RedirectToAction("Index"); } - ViewBag.user_id = new SelectList(db.ProjectUsers, "id", "login", project.user_id); + ViewBag.user_id = new SelectList(db.Users, "id", "login", project.user_id); return View(project); } @@ -72,7 +72,7 @@ namespace Projects.Models { return HttpNotFound(); } - ViewBag.user_id = new SelectList(db.ProjectUsers, "id", "login", project.user_id); + ViewBag.user_id = new SelectList(db.Users, "id", "login", project.user_id); return View(project); } @@ -89,7 +89,7 @@ namespace Projects.Models db.SaveChanges(); return RedirectToAction("Index"); } - ViewBag.user_id = new SelectList(db.ProjectUsers, "id", "login", project.user_id); + ViewBag.user_id = new SelectList(db.Users, "id", "login", project.user_id); return View(project); } diff --git a/Projects/Models/Metadata.cs b/Projects/Models/Metadata.cs index a22d125..8009e99 100644 --- a/Projects/Models/Metadata.cs +++ b/Projects/Models/Metadata.cs @@ -35,7 +35,7 @@ namespace Projects.Models public Nullable updated_at; } - public class ProjectUserMetadata + public class UserMetadata { [Display(Name = "Login")] public string login; diff --git a/Projects/Models/Model1.Context.cs b/Projects/Models/Model.Context.cs similarity index 90% rename from Projects/Models/Model1.Context.cs rename to Projects/Models/Model.Context.cs index f782b46..f56dc65 100644 --- a/Projects/Models/Model1.Context.cs +++ b/Projects/Models/Model.Context.cs @@ -27,8 +27,9 @@ namespace Projects.Models public virtual DbSet Projects { get; set; } public virtual DbSet ProjectTasks { get; set; } - public virtual DbSet ProjectUsers { get; set; } public virtual DbSet sysdiagrams { get; set; } public virtual DbSet TaskStatuses { get; set; } + public virtual DbSet UserRoles { get; set; } + public virtual DbSet Users { get; set; } } } diff --git a/Projects/Models/Model1.Context.tt b/Projects/Models/Model.Context.tt similarity index 99% rename from Projects/Models/Model1.Context.tt rename to Projects/Models/Model.Context.tt index 7b8920f..cfb5c34 100644 --- a/Projects/Models/Model1.Context.tt +++ b/Projects/Models/Model.Context.tt @@ -2,7 +2,7 @@ <#@ include file="EF6.Utility.CS.ttinclude"#><#@ output extension=".cs"#><# -const string inputFile = @"Model1.edmx"; +const string inputFile = @"Model.edmx"; var textTransform = DynamicTextTransformation.Create(this); var code = new CodeGenerationTools(this); var ef = new MetadataTools(this); diff --git a/Projects/Models/Model1.Designer.cs b/Projects/Models/Model.Designer.cs similarity index 80% rename from Projects/Models/Model1.Designer.cs rename to Projects/Models/Model.Designer.cs index 838b941..13d396f 100644 --- a/Projects/Models/Model1.Designer.cs +++ b/Projects/Models/Model.Designer.cs @@ -1,4 +1,4 @@ -// T4 code generation is enabled for model 'c:\users\rafal\documents\visual studio 2015\Projects\Projects\Projects\Models\Model1.edmx'. +// T4 code generation is enabled for model 'C:\Users\Rafal\Documents\Visual Studio 2015\Projects\Projects\Projects\Models\Model.edmx'. // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model // is open in the designer. diff --git a/Projects/Models/Model1.cs b/Projects/Models/Model.cs similarity index 100% rename from Projects/Models/Model1.cs rename to Projects/Models/Model.cs diff --git a/Projects/Models/Model1.edmx b/Projects/Models/Model.edmx similarity index 75% rename from Projects/Models/Model1.edmx rename to Projects/Models/Model.edmx index b51f55a..dd9074c 100644 --- a/Projects/Models/Model1.edmx +++ b/Projects/Models/Model.edmx @@ -4,7 +4,7 @@ - + @@ -29,14 +29,6 @@ - - - - - - - - @@ -49,16 +41,32 @@ - + - + + + + + + + + + + + + + + + + + - + - + @@ -83,7 +91,7 @@ - + @@ -91,10 +99,10 @@ - + - + @@ -102,14 +110,27 @@ + + + + + + + + + + + + - + + - + @@ -121,11 +142,16 @@ - + + + + + - + + @@ -139,7 +165,7 @@ - + @@ -156,17 +182,7 @@ - - - - - - - - - - - + @@ -180,17 +196,37 @@ - + - + + + + + + + + + + + + + + + + + + + + + - + - + @@ -215,7 +251,7 @@ - + @@ -223,10 +259,10 @@ - + - + @@ -234,14 +270,27 @@ + + + + + + + + + + + + - + + - + @@ -253,9 +302,13 @@ - + + + + + @@ -289,15 +342,6 @@ - - - - - - - - - @@ -312,11 +356,29 @@ - + + + + + + + + + + + + + + + + + + + diff --git a/Projects/Models/Model1.edmx.diagram b/Projects/Models/Model.edmx.diagram similarity index 61% rename from Projects/Models/Model1.edmx.diagram rename to Projects/Models/Model.edmx.diagram index 70a2a7e..c2f69b0 100644 --- a/Projects/Models/Model1.edmx.diagram +++ b/Projects/Models/Model.edmx.diagram @@ -4,16 +4,18 @@ - - - - - - + + + + + + + + diff --git a/Projects/Models/Model1.tt b/Projects/Models/Model.tt similarity index 99% rename from Projects/Models/Model1.tt rename to Projects/Models/Model.tt index b0e43c7..98737df 100644 --- a/Projects/Models/Model1.tt +++ b/Projects/Models/Model.tt @@ -2,7 +2,7 @@ <#@ include file="EF6.Utility.CS.ttinclude"#><#@ output extension=".cs"#><# -const string inputFile = @"Model1.edmx"; +const string inputFile = @"Model.edmx"; var textTransform = DynamicTextTransformation.Create(this); var code = new CodeGenerationTools(this); var ef = new MetadataTools(this); diff --git a/Projects/Models/PartialClasses.cs b/Projects/Models/PartialClasses.cs index a30c5e5..67f881e 100644 --- a/Projects/Models/PartialClasses.cs +++ b/Projects/Models/PartialClasses.cs @@ -13,8 +13,8 @@ namespace Projects.Models { } - [MetadataType(typeof(ProjectUserMetadata))] - public partial class ProjectUser + [MetadataType(typeof(UserMetadata))] + public partial class User { } diff --git a/Projects/Models/Project.cs b/Projects/Models/Project.cs index 3874efa..2ba7028 100644 --- a/Projects/Models/Project.cs +++ b/Projects/Models/Project.cs @@ -27,7 +27,7 @@ namespace Projects.Models public Nullable created_at { get; set; } public Nullable updated_at { get; set; } - public virtual ProjectUser ProjectUser { get; set; } + public virtual User User { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection ProjectTasks { get; set; } } diff --git a/Projects/Models/ProjectTask.cs b/Projects/Models/ProjectTask.cs index 4885fe4..e908954 100644 --- a/Projects/Models/ProjectTask.cs +++ b/Projects/Models/ProjectTask.cs @@ -25,6 +25,6 @@ namespace Projects.Models public virtual Project Project { get; set; } public virtual TaskStatus TaskStatus { get; set; } - public virtual ProjectUser ProjectUser { get; set; } + public virtual User User { get; set; } } } diff --git a/Projects/Models/TaskStatus.cs b/Projects/Models/TaskStatus.cs index c418dfb..4570d3b 100644 --- a/Projects/Models/TaskStatus.cs +++ b/Projects/Models/TaskStatus.cs @@ -20,7 +20,7 @@ namespace Projects.Models this.ProjectTasks = new HashSet(); } - public int @int { get; set; } + public int id { get; set; } public string status { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] diff --git a/Projects/Models/ProjectUser.cs b/Projects/Models/User.cs similarity index 89% rename from Projects/Models/ProjectUser.cs rename to Projects/Models/User.cs index d34db39..0e170d9 100644 --- a/Projects/Models/ProjectUser.cs +++ b/Projects/Models/User.cs @@ -12,10 +12,10 @@ namespace Projects.Models using System; using System.Collections.Generic; - public partial class ProjectUser + public partial class User { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] - public ProjectUser() + public User() { this.Projects = new HashSet(); this.ProjectTasks = new HashSet(); @@ -24,10 +24,12 @@ namespace Projects.Models public int id { get; set; } public string login { get; set; } public string password { get; set; } + public int role_id { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection Projects { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection ProjectTasks { get; set; } + public virtual UserRole UserRole { get; set; } } } diff --git a/Projects/Models/UserRole.cs b/Projects/Models/UserRole.cs new file mode 100644 index 0000000..b180fcb --- /dev/null +++ b/Projects/Models/UserRole.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Projects.Models +{ + using System; + using System.Collections.Generic; + + public partial class UserRole + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public UserRole() + { + this.Users = new HashSet(); + } + + public int id { get; set; } + public string role { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Users { get; set; } + } +} diff --git a/Projects/Projects.csproj b/Projects/Projects.csproj index 50a0797..db60767 100644 --- a/Projects/Projects.csproj +++ b/Projects/Projects.csproj @@ -208,37 +208,40 @@ - + True True - Model1.Context.tt + Model.Context.tt - + True True - Model1.tt + Model.tt - + True True - Model1.edmx + Model.edmx + - Model1.tt + Model.tt - - Model1.tt - - - Model1.tt + Model.tt - Model1.tt + Model.tt - Model1.tt + Model.tt + + + Model.tt + + + Model.tt @@ -249,15 +252,15 @@ - + TextTemplatingFileGenerator - Model1.edmx - Model1.Context.cs + Model.edmx + Model.Context.cs - + TextTemplatingFileGenerator - Model1.edmx - Model1.cs + Model.edmx + Model.cs @@ -266,12 +269,12 @@ PreserveNewest - + EntityModelCodeGenerator - Model1.Designer.cs + Model.Designer.cs - - Model1.edmx + + Model.edmx diff --git a/Projects/Views/ProjectTasks/Delete.cshtml b/Projects/Views/ProjectTasks/Delete.cshtml index 2e90cbf..e4fa4fa 100644 --- a/Projects/Views/ProjectTasks/Delete.cshtml +++ b/Projects/Views/ProjectTasks/Delete.cshtml @@ -60,11 +60,11 @@
- @Html.DisplayNameFor(model => model.ProjectUser.login) + @Html.DisplayNameFor(model => model.User.login)
- @Html.DisplayFor(model => model.ProjectUser.login) + @Html.DisplayFor(model => model.User.login)
diff --git a/Projects/Views/ProjectTasks/Details.cshtml b/Projects/Views/ProjectTasks/Details.cshtml index 7e08571..8b0e593 100644 --- a/Projects/Views/ProjectTasks/Details.cshtml +++ b/Projects/Views/ProjectTasks/Details.cshtml @@ -59,11 +59,11 @@
- @Html.DisplayNameFor(model => model.ProjectUser.login) + @Html.DisplayNameFor(model => model.User.login)
- @Html.DisplayFor(model => model.ProjectUser.login) + @Html.DisplayFor(model => model.User.login)
diff --git a/Projects/Views/ProjectTasks/Index.cshtml b/Projects/Views/ProjectTasks/Index.cshtml index ceddb40..787dfea 100644 --- a/Projects/Views/ProjectTasks/Index.cshtml +++ b/Projects/Views/ProjectTasks/Index.cshtml @@ -30,7 +30,7 @@ @Html.DisplayNameFor(model => model.TaskStatus.status) - @Html.DisplayNameFor(model => model.ProjectUser.login) + @Html.DisplayNameFor(model => model.User.login) @@ -56,7 +56,7 @@ @Html.DisplayFor(modelItem => item.TaskStatus.status) - @Html.DisplayFor(modelItem => item.ProjectUser.login) + @Html.DisplayFor(modelItem => item.User.login) @Html.ActionLink("Edit", "Edit", new { id=item.id }) | diff --git a/Projects/Views/Projects/Delete.cshtml b/Projects/Views/Projects/Delete.cshtml index 39a8583..50c66da 100644 --- a/Projects/Views/Projects/Delete.cshtml +++ b/Projects/Views/Projects/Delete.cshtml @@ -44,11 +44,11 @@
- @Html.DisplayNameFor(model => model.ProjectUser.login) + @Html.DisplayNameFor(model => model.User.login)
- @Html.DisplayFor(model => model.ProjectUser.login) + @Html.DisplayFor(model => model.User.login)
diff --git a/Projects/Views/Projects/Details.cshtml b/Projects/Views/Projects/Details.cshtml index a7d0a4b..97e2772 100644 --- a/Projects/Views/Projects/Details.cshtml +++ b/Projects/Views/Projects/Details.cshtml @@ -43,11 +43,11 @@
- @Html.DisplayNameFor(model => model.ProjectUser.login) + @Html.DisplayNameFor(model => model.User.login)
- @Html.DisplayFor(model => model.ProjectUser.login) + @Html.DisplayFor(model => model.User.login)
diff --git a/Projects/Views/Projects/Index.cshtml b/Projects/Views/Projects/Index.cshtml index bed3736..00a00d4 100644 --- a/Projects/Views/Projects/Index.cshtml +++ b/Projects/Views/Projects/Index.cshtml @@ -24,7 +24,7 @@ @Html.DisplayNameFor(model => model.updated_at) - @Html.DisplayNameFor(model => model.ProjectUser.login) + @Html.DisplayNameFor(model => model.User.login) @@ -44,7 +44,7 @@ @Html.DisplayFor(modelItem => item.updated_at) - @Html.DisplayFor(modelItem => item.ProjectUser.login) + @Html.DisplayFor(modelItem => item.User.login) @Html.ActionLink("Edit", "Edit", new { id=item.id }) | diff --git a/Projects/Web.config b/Projects/Web.config index 178fa62..7c97ace 100644 --- a/Projects/Web.config +++ b/Projects/Web.config @@ -10,8 +10,7 @@ - - + -- 2.30.2