Update Models according to DB change
authorRafał Długołęcki <dlugolecki.rafal@gmail.com>
Fri, 12 Feb 2016 01:09:31 +0000 (02:09 +0100)
committerRafał Długołęcki <dlugolecki.rafal@gmail.com>
Fri, 12 Feb 2016 01:09:31 +0000 (02:09 +0100)
24 files changed:
Projects/Controllers/ProjectTasksController.cs
Projects/Controllers/ProjectsController.cs
Projects/Models/Metadata.cs
Projects/Models/Model.Context.cs [moved from Projects/Models/Model1.Context.cs with 90% similarity]
Projects/Models/Model.Context.tt [moved from Projects/Models/Model1.Context.tt with 99% similarity]
Projects/Models/Model.Designer.cs [moved from Projects/Models/Model1.Designer.cs with 80% similarity]
Projects/Models/Model.cs [moved from Projects/Models/Model1.cs with 100% similarity]
Projects/Models/Model.edmx [moved from Projects/Models/Model1.edmx with 75% similarity]
Projects/Models/Model.edmx.diagram [moved from Projects/Models/Model1.edmx.diagram with 61% similarity]
Projects/Models/Model.tt [moved from Projects/Models/Model1.tt with 99% similarity]
Projects/Models/PartialClasses.cs
Projects/Models/Project.cs
Projects/Models/ProjectTask.cs
Projects/Models/TaskStatus.cs
Projects/Models/User.cs [moved from Projects/Models/ProjectUser.cs with 89% similarity]
Projects/Models/UserRole.cs [new file with mode: 0644]
Projects/Projects.csproj
Projects/Views/ProjectTasks/Delete.cshtml
Projects/Views/ProjectTasks/Details.cshtml
Projects/Views/ProjectTasks/Index.cshtml
Projects/Views/Projects/Delete.cshtml
Projects/Views/Projects/Details.cshtml
Projects/Views/Projects/Index.cshtml
Projects/Web.config

index 456bac8d0e694f51e1a34fff11d356890446ddcd..d738edc8e5d6691a565942f838797d4c9352b241 100644 (file)
@@ -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);
         }
 
index 38271281c663b6c280ee06a6e1ec3d5077f7431f..73205a873fce7718732831287ff24ec44f7b6c20 100644 (file)
@@ -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);
         }
 
index a22d125ad91800944631e5b07e58299d5f01bcb1..8009e997f7dfd36a30b211c65f45d49b13e340ec 100644 (file)
@@ -35,7 +35,7 @@ namespace Projects.Models
         public Nullable<System.DateTime> updated_at;
     }
 
-    public class ProjectUserMetadata
+    public class UserMetadata
     {
         [Display(Name = "Login")]
         public string login;
similarity index 90%
rename from Projects/Models/Model1.Context.cs
rename to Projects/Models/Model.Context.cs
index f782b462915cf8afc38df204ee413299f00c2b5d..f56dc65fb5a833ad3bd26d3d930b1b106d43f6f5 100644 (file)
@@ -27,8 +27,9 @@ namespace Projects.Models
     
         public virtual DbSet<Project> Projects { get; set; }
         public virtual DbSet<ProjectTask> ProjectTasks { get; set; }
-        public virtual DbSet<ProjectUser> ProjectUsers { get; set; }
         public virtual DbSet<sysdiagram> sysdiagrams { get; set; }
         public virtual DbSet<TaskStatus> TaskStatuses { get; set; }
+        public virtual DbSet<UserRole> UserRoles { get; set; }
+        public virtual DbSet<User> Users { get; set; }
     }
 }
similarity index 99%
rename from Projects/Models/Model1.Context.tt
rename to Projects/Models/Model.Context.tt
index 7b8920f5a8febcbea88b9d8e13e7e994d6eeb3c8..cfb5c34e5d7f8fffd257e6f1ad95418655fda541 100644 (file)
@@ -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);
similarity index 80%
rename from Projects/Models/Model1.Designer.cs
rename to Projects/Models/Model.Designer.cs
index 838b941ea040213e9e8df99ca09d9365ec566572..13d396f6c984ccc59f9b3bc8437583bd939ec360 100644 (file)
@@ -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.
similarity index 75%
rename from Projects/Models/Model1.edmx
rename to Projects/Models/Model.edmx
index b51f55a3e16e14c707d551bbd77c1a05f63e339b..dd9074c6dd08056a12b309cf55a8f0ff4a0d9f1f 100644 (file)
@@ -4,7 +4,7 @@
   <edmx:Runtime>
     <!-- SSDL content -->
     <edmx:StorageModels>
-    <Schema Namespace="ProjectsDBModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
+      <Schema Namespace="ProjectsDBModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
         <EntityType Name="Projects">
           <Key>
             <PropertyRef Name="id" />
           <Property Name="task_status_id" Type="int" />
           <Property Name="user_id" Type="int" />
         </EntityType>
-        <EntityType Name="ProjectUsers">
-          <Key>
-            <PropertyRef Name="id" />
-          </Key>
-          <Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
-          <Property Name="login" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="password" Type="nvarchar" MaxLength="50" Nullable="false" />
-        </EntityType>
         <EntityType Name="sysdiagrams">
           <Key>
             <PropertyRef Name="diagram_id" />
         </EntityType>
         <EntityType Name="TaskStatuses">
           <Key>
-            <PropertyRef Name="int" />
+            <PropertyRef Name="id" />
           </Key>
-          <Property Name="int" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
           <Property Name="status" Type="nvarchar" MaxLength="50" />
         </EntityType>
+        <EntityType Name="UserRoles">
+          <Key>
+            <PropertyRef Name="id" />
+          </Key>
+          <Property Name="id" Type="int" Nullable="false" />
+          <Property Name="role" Type="nchar" MaxLength="10" Nullable="false" />
+        </EntityType>
+        <EntityType Name="Users">
+          <Key>
+            <PropertyRef Name="id" />
+          </Key>
+          <Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="login" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="password" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="role_id" Type="int" Nullable="false" />
+        </EntityType>
         <Association Name="FK_Projects_Users">
-          <End Role="ProjectUsers" Type="Self.ProjectUsers" Multiplicity="0..1" />
+          <End Role="Users" Type="Self.Users" Multiplicity="0..1" />
           <End Role="Projects" Type="Self.Projects" Multiplicity="*" />
           <ReferentialConstraint>
-            <Principal Role="ProjectUsers">
+            <Principal Role="Users">
               <PropertyRef Name="id" />
             </Principal>
             <Dependent Role="Projects">
@@ -83,7 +91,7 @@
           <End Role="ProjectTasks" Type="Self.ProjectTasks" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="TaskStatuses">
-              <PropertyRef Name="int" />
+              <PropertyRef Name="id" />
             </Principal>
             <Dependent Role="ProjectTasks">
               <PropertyRef Name="task_status_id" />
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Tasks_Users">
-          <End Role="ProjectUsers" Type="Self.ProjectUsers" Multiplicity="0..1" />
+          <End Role="Users" Type="Self.Users" Multiplicity="0..1" />
           <End Role="ProjectTasks" Type="Self.ProjectTasks" Multiplicity="*" />
           <ReferentialConstraint>
-            <Principal Role="ProjectUsers">
+            <Principal Role="Users">
               <PropertyRef Name="id" />
             </Principal>
             <Dependent Role="ProjectTasks">
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <Association Name="FK_Users_UserRoles">
+          <End Role="UserRoles" Type="Self.UserRoles" Multiplicity="1" />
+          <End Role="Users" Type="Self.Users" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="UserRoles">
+              <PropertyRef Name="id" />
+            </Principal>
+            <Dependent Role="Users">
+              <PropertyRef Name="role_id" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <EntityContainer Name="ProjectsDBModelStoreContainer">
           <EntitySet Name="Projects" EntityType="Self.Projects" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="ProjectTasks" EntityType="Self.ProjectTasks" Schema="dbo" store:Type="Tables" />
-          <EntitySet Name="ProjectUsers" EntityType="Self.ProjectUsers" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="sysdiagrams" EntityType="Self.sysdiagrams" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="TaskStatuses" EntityType="Self.TaskStatuses" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="UserRoles" EntityType="Self.UserRoles" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
           <AssociationSet Name="FK_Projects_Users" Association="Self.FK_Projects_Users">
-            <End Role="ProjectUsers" EntitySet="ProjectUsers" />
+            <End Role="Users" EntitySet="Users" />
             <End Role="Projects" EntitySet="Projects" />
           </AssociationSet>
           <AssociationSet Name="FK_Tasks_Projects" Association="Self.FK_Tasks_Projects">
             <End Role="ProjectTasks" EntitySet="ProjectTasks" />
           </AssociationSet>
           <AssociationSet Name="FK_Tasks_Users" Association="Self.FK_Tasks_Users">
-            <End Role="ProjectUsers" EntitySet="ProjectUsers" />
+            <End Role="Users" EntitySet="Users" />
             <End Role="ProjectTasks" EntitySet="ProjectTasks" />
           </AssociationSet>
+          <AssociationSet Name="FK_Users_UserRoles" Association="Self.FK_Users_UserRoles">
+            <End Role="UserRoles" EntitySet="UserRoles" />
+            <End Role="Users" EntitySet="Users" />
+          </AssociationSet>
         </EntityContainer>
-      </Schema></edmx:StorageModels>
+      </Schema>
+    </edmx:StorageModels>
     <!-- CSDL content -->
     <edmx:ConceptualModels>
       <Schema Namespace="ProjectsDBModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
           <Property Name="description" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
           <Property Name="created_at" Type="DateTime" Precision="7" />
           <Property Name="updated_at" Type="DateTime" Precision="7" />
-          <NavigationProperty Name="ProjectUser" Relationship="Self.FK_Projects_Users" FromRole="Projects" ToRole="ProjectUsers" />
+          <NavigationProperty Name="User" Relationship="Self.FK_Projects_Users" FromRole="Projects" ToRole="Users" />
           <NavigationProperty Name="ProjectTasks" Relationship="Self.FK_Tasks_Projects" FromRole="Projects" ToRole="ProjectTasks" />
         </EntityType>
         <EntityType Name="ProjectTask">
           <Property Name="user_id" Type="Int32" />
           <NavigationProperty Name="Project" Relationship="Self.FK_Tasks_Projects" FromRole="ProjectTasks" ToRole="Projects" />
           <NavigationProperty Name="TaskStatus" Relationship="Self.FK_Tasks_TaskStatuses" FromRole="ProjectTasks" ToRole="TaskStatuses" />
-          <NavigationProperty Name="ProjectUser" Relationship="Self.FK_Tasks_Users" FromRole="ProjectTasks" ToRole="ProjectUsers" />
-        </EntityType>
-        <EntityType Name="ProjectUser">
-          <Key>
-            <PropertyRef Name="id" />
-          </Key>
-          <Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="login" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
-          <Property Name="password" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
-          <NavigationProperty Name="Projects" Relationship="Self.FK_Projects_Users" FromRole="ProjectUsers" ToRole="Projects" />
-          <NavigationProperty Name="ProjectTasks" Relationship="Self.FK_Tasks_Users" FromRole="ProjectUsers" ToRole="ProjectTasks" />
+          <NavigationProperty Name="User" Relationship="Self.FK_Tasks_Users" FromRole="ProjectTasks" ToRole="Users" />
         </EntityType>
         <EntityType Name="sysdiagram">
           <Key>
         </EntityType>
         <EntityType Name="TaskStatus">
           <Key>
-            <PropertyRef Name="int" />
+            <PropertyRef Name="id" />
           </Key>
-          <Property Name="int" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
           <Property Name="status" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
           <NavigationProperty Name="ProjectTasks" Relationship="Self.FK_Tasks_TaskStatuses" FromRole="TaskStatuses" ToRole="ProjectTasks" />
         </EntityType>
+        <EntityType Name="UserRole">
+          <Key>
+            <PropertyRef Name="id" />
+          </Key>
+          <Property Name="id" Type="Int32" Nullable="false" />
+          <Property Name="role" Type="String" MaxLength="10" FixedLength="true" Unicode="true" Nullable="false" />
+          <NavigationProperty Name="Users" Relationship="Self.FK_Users_UserRoles" FromRole="UserRoles" ToRole="Users" />
+        </EntityType>
+        <EntityType Name="User">
+          <Key>
+            <PropertyRef Name="id" />
+          </Key>
+          <Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="login" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="password" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="role_id" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="Projects" Relationship="Self.FK_Projects_Users" FromRole="Users" ToRole="Projects" />
+          <NavigationProperty Name="ProjectTasks" Relationship="Self.FK_Tasks_Users" FromRole="Users" ToRole="ProjectTasks" />
+          <NavigationProperty Name="UserRole" Relationship="Self.FK_Users_UserRoles" FromRole="Users" ToRole="UserRoles" />
+        </EntityType>
         <Association Name="FK_Projects_Users">
-          <End Role="ProjectUsers" Type="Self.ProjectUser" Multiplicity="0..1" />
+          <End Role="Users" Type="Self.User" Multiplicity="0..1" />
           <End Role="Projects" Type="Self.Project" Multiplicity="*" />
           <ReferentialConstraint>
-            <Principal Role="ProjectUsers">
+            <Principal Role="Users">
               <PropertyRef Name="id" />
             </Principal>
             <Dependent Role="Projects">
           <End Role="ProjectTasks" Type="Self.ProjectTask" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="TaskStatuses">
-              <PropertyRef Name="int" />
+              <PropertyRef Name="id" />
             </Principal>
             <Dependent Role="ProjectTasks">
               <PropertyRef Name="task_status_id" />
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Tasks_Users">
-          <End Role="ProjectUsers" Type="Self.ProjectUser" Multiplicity="0..1" />
+          <End Role="Users" Type="Self.User" Multiplicity="0..1" />
           <End Role="ProjectTasks" Type="Self.ProjectTask" Multiplicity="*" />
           <ReferentialConstraint>
-            <Principal Role="ProjectUsers">
+            <Principal Role="Users">
               <PropertyRef Name="id" />
             </Principal>
             <Dependent Role="ProjectTasks">
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <Association Name="FK_Users_UserRoles">
+          <End Role="UserRoles" Type="Self.UserRole" Multiplicity="1" />
+          <End Role="Users" Type="Self.User" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="UserRoles">
+              <PropertyRef Name="id" />
+            </Principal>
+            <Dependent Role="Users">
+              <PropertyRef Name="role_id" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <EntityContainer Name="ProjectsDBEntities" annotation:LazyLoadingEnabled="true">
           <EntitySet Name="Projects" EntityType="Self.Project" />
           <EntitySet Name="ProjectTasks" EntityType="Self.ProjectTask" />
-          <EntitySet Name="ProjectUsers" EntityType="Self.ProjectUser" />
           <EntitySet Name="sysdiagrams" EntityType="Self.sysdiagram" />
           <EntitySet Name="TaskStatuses" EntityType="Self.TaskStatus" />
+          <EntitySet Name="UserRoles" EntityType="Self.UserRole" />
+          <EntitySet Name="Users" EntityType="Self.User" />
           <AssociationSet Name="FK_Projects_Users" Association="Self.FK_Projects_Users">
-            <End Role="ProjectUsers" EntitySet="ProjectUsers" />
+            <End Role="Users" EntitySet="Users" />
             <End Role="Projects" EntitySet="Projects" />
           </AssociationSet>
           <AssociationSet Name="FK_Tasks_Projects" Association="Self.FK_Tasks_Projects">
             <End Role="ProjectTasks" EntitySet="ProjectTasks" />
           </AssociationSet>
           <AssociationSet Name="FK_Tasks_Users" Association="Self.FK_Tasks_Users">
-            <End Role="ProjectUsers" EntitySet="ProjectUsers" />
+            <End Role="Users" EntitySet="Users" />
             <End Role="ProjectTasks" EntitySet="ProjectTasks" />
           </AssociationSet>
+          <AssociationSet Name="FK_Users_UserRoles" Association="Self.FK_Users_UserRoles">
+            <End Role="UserRoles" EntitySet="UserRoles" />
+            <End Role="Users" EntitySet="Users" />
+          </AssociationSet>
         </EntityContainer>
       </Schema>
     </edmx:ConceptualModels>
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
-          <EntitySetMapping Name="ProjectUsers">
-            <EntityTypeMapping TypeName="ProjectsDBModel.ProjectUser">
-              <MappingFragment StoreEntitySet="ProjectUsers">
-                <ScalarProperty Name="id" ColumnName="id" />
-                <ScalarProperty Name="login" ColumnName="login" />
-                <ScalarProperty Name="password" ColumnName="password" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
           <EntitySetMapping Name="sysdiagrams">
             <EntityTypeMapping TypeName="ProjectsDBModel.sysdiagram">
               <MappingFragment StoreEntitySet="sysdiagrams">
           <EntitySetMapping Name="TaskStatuses">
             <EntityTypeMapping TypeName="ProjectsDBModel.TaskStatus">
               <MappingFragment StoreEntitySet="TaskStatuses">
-                <ScalarProperty Name="int" ColumnName="int" />
+                <ScalarProperty Name="id" ColumnName="id" />
                 <ScalarProperty Name="status" ColumnName="status" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
+          <EntitySetMapping Name="UserRoles">
+            <EntityTypeMapping TypeName="ProjectsDBModel.UserRole">
+              <MappingFragment StoreEntitySet="UserRoles">
+                <ScalarProperty Name="id" ColumnName="id" />
+                <ScalarProperty Name="role" ColumnName="role" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Users">
+            <EntityTypeMapping TypeName="ProjectsDBModel.User">
+              <MappingFragment StoreEntitySet="Users">
+                <ScalarProperty Name="id" ColumnName="id" />
+                <ScalarProperty Name="login" ColumnName="login" />
+                <ScalarProperty Name="password" ColumnName="password" />
+                <ScalarProperty Name="role_id" ColumnName="role_id" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
         </EntityContainerMapping>
       </Mapping>
     </edmx:Mappings>
similarity index 61%
rename from Projects/Models/Model1.edmx.diagram
rename to Projects/Models/Model.edmx.diagram
index 70a2a7ed612cf107fbbb7ac7adc4d466c4211d55..c2f69b0b183d018103c497bcdfd52b770ac2f8ea 100644 (file)
@@ -4,16 +4,18 @@
   <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
-      <Diagram DiagramId="8eea6ea450c84400b6b16899211fcd8a" Name="Diagram1">
-        <EntityTypeShape EntityType="ProjectsDBModel.Project" Width="1.5" PointX="3" PointY="1.25" IsExpanded="true" />
-        <EntityTypeShape EntityType="ProjectsDBModel.ProjectTask" Width="1.5" PointX="5.25" PointY="1" IsExpanded="true" />
-        <EntityTypeShape EntityType="ProjectsDBModel.ProjectUser" Width="1.5" PointX="0.75" PointY="1.5" IsExpanded="true" />
-        <EntityTypeShape EntityType="ProjectsDBModel.sysdiagram" Width="1.5" PointX="5.75" PointY="4.75" IsExpanded="true" />
-        <EntityTypeShape EntityType="ProjectsDBModel.TaskStatus" Width="1.5" PointX="3" PointY="5.625" IsExpanded="true" />
+      <Diagram DiagramId="fb52aa34f4b64f1489c1c8e9f3269c72" Name="Diagram1">
+        <EntityTypeShape EntityType="ProjectsDBModel.Project" Width="1.5" PointX="5.25" PointY="1.25" IsExpanded="true" />
+        <EntityTypeShape EntityType="ProjectsDBModel.ProjectTask" Width="1.5" PointX="7.5" PointY="1" IsExpanded="true" />
+        <EntityTypeShape EntityType="ProjectsDBModel.sysdiagram" Width="1.5" PointX="0.75" PointY="4.75" IsExpanded="true" />
+        <EntityTypeShape EntityType="ProjectsDBModel.TaskStatus" Width="1.5" PointX="5.25" PointY="5.625" IsExpanded="true" />
+        <EntityTypeShape EntityType="ProjectsDBModel.UserRole" Width="1.5" PointX="0.75" PointY="1.625" IsExpanded="true" />
+        <EntityTypeShape EntityType="ProjectsDBModel.User" Width="1.5" PointX="3" PointY="1.25" IsExpanded="true" />
         <AssociationConnector Association="ProjectsDBModel.FK_Projects_Users" ManuallyRouted="false" />
         <AssociationConnector Association="ProjectsDBModel.FK_Tasks_Projects" ManuallyRouted="false" />
         <AssociationConnector Association="ProjectsDBModel.FK_Tasks_TaskStatuses" ManuallyRouted="false" />
         <AssociationConnector Association="ProjectsDBModel.FK_Tasks_Users" ManuallyRouted="false" />
+        <AssociationConnector Association="ProjectsDBModel.FK_Users_UserRoles" ManuallyRouted="false" />
       </Diagram>
     </edmx:Diagrams>
   </edmx:Designer>
similarity index 99%
rename from Projects/Models/Model1.tt
rename to Projects/Models/Model.tt
index b0e43c7def08d7e934eb4cf9fb2eced783bbb0d8..98737df9b962d6ed46d42213ce61a64cd64dc0f3 100644 (file)
@@ -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);
index a30c5e5a4bae0371e6caab4cdec4642549ff235c..67f881eaca9dc403098ffd873bd6c67135862639 100644 (file)
@@ -13,8 +13,8 @@ namespace Projects.Models
     {
     }
 
-    [MetadataType(typeof(ProjectUserMetadata))]
-    public partial class ProjectUser
+    [MetadataType(typeof(UserMetadata))]
+    public partial class User
     {
     }
 
index 3874efab2587c3143cc9569026fb1bf431b03204..2ba7028b329e88c2aed857ef3466f5f6a265f8f5 100644 (file)
@@ -27,7 +27,7 @@ namespace Projects.Models
         public Nullable<System.DateTime> created_at { get; set; }
         public Nullable<System.DateTime> 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<ProjectTask> ProjectTasks { get; set; }
     }
index 4885fe4b509047abc6783001ff09ff22d52cd832..e9089543ad3fb9f6a7b5e7d729c98975d86f5bb6 100644 (file)
@@ -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; }
     }
 }
index c418dfb5b37c9c6e9cb3bd55db9ddbf5032db433..4570d3b16364b3692d7216b2c4d727eaf2ccba01 100644 (file)
@@ -20,7 +20,7 @@ namespace Projects.Models
             this.ProjectTasks = new HashSet<ProjectTask>();
         }
     
-        public int @int { get; set; }
+        public int id { get; set; }
         public string status { get; set; }
     
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
similarity index 89%
rename from Projects/Models/ProjectUser.cs
rename to Projects/Models/User.cs
index d34db393d286613f3c42b2df076b97a31b6d1443..0e170d9755a42a0fc25912a4736a4a768d1ba971 100644 (file)
@@ -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<Project>();
             this.ProjectTasks = new HashSet<ProjectTask>();
@@ -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<Project> Projects { get; set; }
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<ProjectTask> 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 (file)
index 0000000..b180fcb
--- /dev/null
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     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.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+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<User>();
+        }
+    
+        public int id { get; set; }
+        public string role { get; set; }
+    
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<User> Users { get; set; }
+    }
+}
index 50a07979e42ed8a097d3b3738dacc72dc7408cfc..db6076717fcc22dce0d3a2b7b0bd0873527bd085 100644 (file)
     <Compile Include="Models\IdentityModels.cs" />
     <Compile Include="Models\ManageViewModels.cs" />
     <Compile Include="Models\Metadata.cs" />
-    <Compile Include="Models\Model1.Context.cs">
+    <Compile Include="Models\Model.Context.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
-      <DependentUpon>Model1.Context.tt</DependentUpon>
+      <DependentUpon>Model.Context.tt</DependentUpon>
     </Compile>
-    <Compile Include="Models\Model1.cs">
+    <Compile Include="Models\Model.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
-      <DependentUpon>Model1.tt</DependentUpon>
+      <DependentUpon>Model.tt</DependentUpon>
     </Compile>
-    <Compile Include="Models\Model1.Designer.cs">
+    <Compile Include="Models\Model.Designer.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
-      <DependentUpon>Model1.edmx</DependentUpon>
+      <DependentUpon>Model.edmx</DependentUpon>
     </Compile>
     <Compile Include="Models\PartialClasses.cs" />
+    <Compile Include="Controllers\ProjectsController.cs" />
     <Compile Include="Models\Project.cs">
-      <DependentUpon>Model1.tt</DependentUpon>
+      <DependentUpon>Model.tt</DependentUpon>
     </Compile>
-    <Compile Include="Controllers\ProjectsController.cs" />
     <Compile Include="Models\ProjectTask.cs">
-      <DependentUpon>Model1.tt</DependentUpon>
-    </Compile>
-    <Compile Include="Models\ProjectUser.cs">
-      <DependentUpon>Model1.tt</DependentUpon>
+      <DependentUpon>Model.tt</DependentUpon>
     </Compile>
     <Compile Include="Models\sysdiagram.cs">
-      <DependentUpon>Model1.tt</DependentUpon>
+      <DependentUpon>Model.tt</DependentUpon>
     </Compile>
     <Compile Include="Models\TaskStatus.cs">
-      <DependentUpon>Model1.tt</DependentUpon>
+      <DependentUpon>Model.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Models\User.cs">
+      <DependentUpon>Model.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Models\UserRole.cs">
+      <DependentUpon>Model.tt</DependentUpon>
     </Compile>
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Startup.cs" />
     <Content Include="favicon.ico" />
     <Content Include="Global.asax" />
     <Content Include="Content\Site.css" />
-    <Content Include="Models\Model1.Context.tt">
+    <Content Include="Models\Model.Context.tt">
       <Generator>TextTemplatingFileGenerator</Generator>
-      <DependentUpon>Model1.edmx</DependentUpon>
-      <LastGenOutput>Model1.Context.cs</LastGenOutput>
+      <DependentUpon>Model.edmx</DependentUpon>
+      <LastGenOutput>Model.Context.cs</LastGenOutput>
     </Content>
-    <Content Include="Models\Model1.tt">
+    <Content Include="Models\Model.tt">
       <Generator>TextTemplatingFileGenerator</Generator>
-      <DependentUpon>Model1.edmx</DependentUpon>
-      <LastGenOutput>Model1.cs</LastGenOutput>
+      <DependentUpon>Model.edmx</DependentUpon>
+      <LastGenOutput>Model.cs</LastGenOutput>
     </Content>
     <Content Include="Scripts\ai.0.15.0-build58334.js" />
     <Content Include="Scripts\ai.0.15.0-build58334.min.js" />
     <Content Include="ApplicationInsights.config">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-    <EntityDeploy Include="Models\Model1.edmx">
+    <EntityDeploy Include="Models\Model.edmx">
       <Generator>EntityModelCodeGenerator</Generator>
-      <LastGenOutput>Model1.Designer.cs</LastGenOutput>
+      <LastGenOutput>Model.Designer.cs</LastGenOutput>
     </EntityDeploy>
-    <Content Include="Models\Model1.edmx.diagram">
-      <DependentUpon>Model1.edmx</DependentUpon>
+    <Content Include="Models\Model.edmx.diagram">
+      <DependentUpon>Model.edmx</DependentUpon>
     </Content>
     <None Include="Scripts\jquery-1.10.2.intellisense.js" />
     <Content Include="Scripts\jquery-1.10.2.js" />
index 2e90cbfed27681ab11c66a6cb60087d94390e366..e4fa4fa0f1f3417b08b778d27a802090e9877e05 100644 (file)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => model.ProjectUser.login)
+            @Html.DisplayNameFor(model => model.User.login)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => model.ProjectUser.login)
+            @Html.DisplayFor(model => model.User.login)
         </dd>
 
     </dl>
index 7e08571378384356e84a534a1fd0f9391a84a6bd..8b0e5938cafa9bdeddea0b57eb408cb0de7f704f 100644 (file)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => model.ProjectUser.login)
+            @Html.DisplayNameFor(model => model.User.login)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => model.ProjectUser.login)
+            @Html.DisplayFor(model => model.User.login)
         </dd>
 
     </dl>
index ceddb407880a4b65b7ba2985835563fdaa987392..787dfea0e98f5650724bc3a89a0940081278cd44 100644 (file)
@@ -30,7 +30,7 @@
             @Html.DisplayNameFor(model => model.TaskStatus.status)
         </th>
         <th>
-            @Html.DisplayNameFor(model => model.ProjectUser.login)
+            @Html.DisplayNameFor(model => model.User.login)
         </th>
         <th></th>
     </tr>
@@ -56,7 +56,7 @@
             @Html.DisplayFor(modelItem => item.TaskStatus.status)
         </td>
         <td>
-            @Html.DisplayFor(modelItem => item.ProjectUser.login)
+            @Html.DisplayFor(modelItem => item.User.login)
         </td>
         <td>
             @Html.ActionLink("Edit", "Edit", new { id=item.id }) |
index 39a8583eb3bf2e1a1600adf42b5d6e7677ebb749..50c66da767bbfe1744d5b5e1162ff6725adbad58 100644 (file)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => model.ProjectUser.login)
+            @Html.DisplayNameFor(model => model.User.login)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => model.ProjectUser.login)
+            @Html.DisplayFor(model => model.User.login)
         </dd>
 
     </dl>
index a7d0a4ba8005548c055149a673ae87cce5af39e0..97e27723464b334ca0a12793622244390d5c2dab 100644 (file)
         </dd>
 
         <dt>
-            @Html.DisplayNameFor(model => model.ProjectUser.login)
+            @Html.DisplayNameFor(model => model.User.login)
         </dt>
 
         <dd>
-            @Html.DisplayFor(model => model.ProjectUser.login)
+            @Html.DisplayFor(model => model.User.login)
         </dd>
 
     </dl>
index bed3736c9469a1572f0f8c25a78dbdc7e04b6cbd..00a00d43dd0d0ee8285478193c2cc55cbe587150 100644 (file)
@@ -24,7 +24,7 @@
             @Html.DisplayNameFor(model => model.updated_at)
         </th>
         <th>
-            @Html.DisplayNameFor(model => model.ProjectUser.login)
+            @Html.DisplayNameFor(model => model.User.login)
         </th>
         <th></th>
     </tr>
@@ -44,7 +44,7 @@
             @Html.DisplayFor(modelItem => item.updated_at)
         </td>
         <td>
-            @Html.DisplayFor(modelItem => item.ProjectUser.login)
+            @Html.DisplayFor(modelItem => item.User.login)
         </td>
         <td>
             @Html.ActionLink("Edit", "Edit", new { id=item.id }) |
index 178fa62cad1a35ddb3693924be2100ee5f78de97..7c97ace6389e841904f25549b694689fbff97f57 100644 (file)
@@ -10,8 +10,7 @@
   </configSections>
   <connectionStrings>
     <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-Projects-20160211114506.mdf;Initial Catalog=aspnet-Projects-20160211114506;Integrated Security=True" providerName="System.Data.SqlClient" />
-    <add name="ProjectsDBEntities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=RAFAL-PC\SQLEXPRESS;initial catalog=ProjectsDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
-  </connectionStrings>
+  <add name="ProjectsDBEntities" connectionString="metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=RAFAL-PC\SQLEXPRESS;initial catalog=ProjectsDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>
   <appSettings>
     <add key="webpages:Version" value="3.0.0.0" />
     <add key="webpages:Enabled" value="false" />