Browse Source

Смэрть

Imagara 3 years ago
parent
commit
34a15847d7

+ 3 - 4
MyTests/App.config

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <configSections>
     <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
@@ -8,12 +8,11 @@
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
   </startup>
   <entityFramework>
-    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
     <providers>
       <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
     </providers>
   </entityFramework>
 <connectionStrings>
-	
-<add name="MyTestsDataBaseEntities" connectionString="metadata=res://*/EDM.csdl|res://*/EDM.ssdl|res://*/EDM.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(localdb)\MSSQLLocalDB;initial catalog=MyTestsDataBase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>
+	<add name="MyTestsDataBaseEntities" connectionString="metadata=res://*/EDM.csdl|res://*/EDM.ssdl|res://*/EDM.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(localdb)\MSSQLLocalDB;initial catalog=MyTestsDataBase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
+</connectionStrings>
 </configuration>

+ 1 - 1
MyTests/Authorization.xaml

@@ -7,7 +7,7 @@
       mc:Ignorable="d" 
       d:DesignHeight="450" d:DesignWidth="800"
       Height="475" Width="475">
-    <Grid>
+    <Grid Background="#2F3136">
         <Button Content="Войти" Margin="0,250,15,0" VerticalAlignment="Top" Width="93" Click="Auth" Height="26" FontSize="18"/>
         <TextBox x:Name="Login" LostFocus="LostLogin" GotFocus="LoginFocus" Margin="0,150,15,0" TextWrapping="Wrap" Text ="Логин" VerticalAlignment="Top" Width="145" Height="25" FontSize="16" />
         <PasswordBox x:Name="Password" LostFocus="LostPassword" GotFocus="PasswordFocus" Margin="0,210,15,0" Password ="Password" VerticalAlignment="Top" Width="126"/>

+ 10 - 3
MyTests/Authorization.xaml.cs

@@ -27,10 +27,17 @@ namespace MyTests
         {
             if (!emptiness(Login.Text, Password.Password))
                 MessageBox.Show("Поля не могут быть пустыми.");
-            else if (Connection.db.Users.Select(item => item.Login + item.Password).Contains(Login.Text + Password.Password))
+            else if (cnt.db.Users.Select(item => item.Login + item.Password).Contains(Login.Text + Password.Password))
             {
-                Session.UserId = Connection.db.Users.First(item => item.Login == Login.Text).IdUsers;
-                MessageBox.Show("КУКУ");
+                Session.User = cnt.db.Users.First(item => item.Login == Login.Text);
+                MainWindow RegAuth = new MainWindow();
+                RegAuth.Show();
+                var windows = Application.Current.Windows;
+                for (int i = windows.Count - 1; i >= 0; i--)
+                {
+                    if (windows[i].ToString() == "MyTests.RegAuth")
+                        windows[i].Close();
+                }
             }
             else
                 MessageBox.Show("Неверный логин или пароль");

+ 0 - 13
MyTests/Connection.cs

@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace MyTests
-{
-    public class Connection
-    {
-        public static MyTestsEntities db = new MyTestsEntities();
-    }
-}

+ 1 - 2
MyTests/EDM.Context.cs

@@ -25,10 +25,9 @@ namespace MyTests
             throw new UnintentionalCodeFirstException();
         }
     
+        public virtual DbSet<Answers> Answers { get; set; }
         public virtual DbSet<Questions> Questions { get; set; }
         public virtual DbSet<Tests> Tests { get; set; }
         public virtual DbSet<Users> Users { get; set; }
-        public virtual DbSet<sysdiagrams> sysdiagrams { get; set; }
-        public virtual DbSet<Answers> Answers { get; set; }
     }
 }

+ 89 - 120
MyTests/EDM.edmx

@@ -4,7 +4,7 @@
   <edmx:Runtime>
     <!-- SSDL content -->
     <edmx:StorageModels>
-    <Schema Namespace="MyTestsDataBaseModel.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="Хранилище MyTestsDataBaseModel" 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="Answers">
           <Key>
             <PropertyRef Name="IdUserAnswer" />
@@ -23,16 +23,6 @@
           <Property Name="Content" Type="nvarchar" MaxLength="150" Nullable="false" />
           <Property Name="Answer" Type="nvarchar" MaxLength="150" Nullable="false" />
         </EntityType>
-        <EntityType Name="sysdiagrams">
-          <Key>
-            <PropertyRef Name="diagram_id" />
-          </Key>
-          <Property Name="name" Type="nvarchar" MaxLength="128" Nullable="false" />
-          <Property Name="principal_id" Type="int" Nullable="false" />
-          <Property Name="diagram_id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
-          <Property Name="version" Type="int" />
-          <Property Name="definition" Type="varbinary(max)" />
-        </EntityType>
         <EntityType Name="Tests">
           <Key>
             <PropertyRef Name="IdTest" />
@@ -101,10 +91,9 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
-        <EntityContainer Name="MyTestsDataBaseModelStoreContainer">
+        <EntityContainer Name="Хранилище MyTestsDataBaseModelContainer">
           <EntitySet Name="Answers" EntityType="Self.Answers" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Questions" EntityType="Self.Questions" Schema="dbo" store:Type="Tables" />
-          <EntitySet Name="sysdiagrams" EntityType="Self.sysdiagrams" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Tests" EntityType="Self.Tests" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
           <AssociationSet Name="FK_Answers_Questions" Association="Self.FK_Answers_Questions">
@@ -124,10 +113,22 @@
             <End Role="Tests" EntitySet="Tests" />
           </AssociationSet>
         </EntityContainer>
-      </Schema></edmx:StorageModels>
+      </Schema>
+    </edmx:StorageModels>
     <!-- CSDL content -->
     <edmx:ConceptualModels>
       <Schema Namespace="MyTestsDataBaseModel" 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">
+        <EntityType Name="Answers">
+          <Key>
+            <PropertyRef Name="IdUserAnswer" />
+          </Key>
+          <Property Name="IdUserAnswer" Type="Int32" Nullable="false" />
+          <Property Name="IdQuestion" Type="Int32" Nullable="false" />
+          <Property Name="IdUser" Type="Int32" Nullable="false" />
+          <Property Name="Answer" Type="String" MaxLength="150" FixedLength="false" Unicode="true" Nullable="false" />
+          <NavigationProperty Name="Questions" Relationship="Self.FK_Answers_Questions" FromRole="Answers" ToRole="Questions" />
+          <NavigationProperty Name="Users" Relationship="Self.FK_Answers_Users" FromRole="Answers" ToRole="Users" />
+        </EntityType>
         <EntityType Name="Questions">
           <Key>
             <PropertyRef Name="IdQuestion" />
@@ -135,9 +136,9 @@
           <Property Name="IdQuestion" Type="Int32" Nullable="false" />
           <Property Name="IdTest" Type="Int32" Nullable="false" />
           <Property Name="Content" Type="String" MaxLength="150" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Answer" Type="String" MaxLength="150" FixedLength="false" Unicode="true" Nullable="false" />
+          <NavigationProperty Name="Answers" Relationship="Self.FK_Answers_Questions" FromRole="Questions" ToRole="Answers" />
           <NavigationProperty Name="Tests" Relationship="Self.FK_Questions_Tests" FromRole="Questions" ToRole="Tests" />
-          <Property Name="Answer" Type="String" Nullable="false" MaxLength="150" FixedLength="false" Unicode="true" />
-          <NavigationProperty Name="Answers" Relationship="MyTestsDataBaseModel.FK_Answers_Questions" FromRole="Questions" ToRole="Answers" />
         </EntityType>
         <EntityType Name="Tests">
           <Key>
@@ -160,9 +161,33 @@
           <Property Name="Email" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
           <Property Name="Info" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
           <Property Name="Image" Type="Binary" MaxLength="Max" FixedLength="false" />
+          <NavigationProperty Name="Answers" Relationship="Self.FK_Answers_Users" FromRole="Users" ToRole="Answers" />
           <NavigationProperty Name="Tests" Relationship="Self.FK_Tests_Users" FromRole="Users" ToRole="Tests" />
-          <NavigationProperty Name="Answers" Relationship="MyTestsDataBaseModel.FK_Answers_Users" FromRole="Users" ToRole="Answers" />
         </EntityType>
+        <Association Name="FK_Answers_Questions">
+          <End Role="Questions" Type="Self.Questions" Multiplicity="1" />
+          <End Role="Answers" Type="Self.Answers" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Questions">
+              <PropertyRef Name="IdQuestion" />
+            </Principal>
+            <Dependent Role="Answers">
+              <PropertyRef Name="IdQuestion" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_Answers_Users">
+          <End Role="Users" Type="Self.Users" Multiplicity="1" />
+          <End Role="Answers" Type="Self.Answers" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Users">
+              <PropertyRef Name="IdUser" />
+            </Principal>
+            <Dependent Role="Answers">
+              <PropertyRef Name="IdUser" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <Association Name="FK_Questions_Tests">
           <End Role="Tests" Type="Self.Tests" Multiplicity="1" />
           <End Role="Questions" Type="Self.Questions" Multiplicity="*" />
@@ -188,134 +213,78 @@
           </ReferentialConstraint>
         </Association>
         <EntityContainer Name="MyTestsDataBaseEntities" annotation:LazyLoadingEnabled="true">
+          <EntitySet Name="Answers" EntityType="Self.Answers" />
           <EntitySet Name="Questions" EntityType="Self.Questions" />
           <EntitySet Name="Tests" EntityType="Self.Tests" />
           <EntitySet Name="Users" EntityType="Self.Users" />
-          <AssociationSet Name="FK_Questions_Tests" Association="Self.FK_Questions_Tests">
-            <End Role="Tests" EntitySet="Tests" />
+          <AssociationSet Name="FK_Answers_Questions" Association="Self.FK_Answers_Questions">
             <End Role="Questions" EntitySet="Questions" />
+            <End Role="Answers" EntitySet="Answers" />
           </AssociationSet>
-          <AssociationSet Name="FK_Tests_Users" Association="Self.FK_Tests_Users">
+          <AssociationSet Name="FK_Answers_Users" Association="Self.FK_Answers_Users">
             <End Role="Users" EntitySet="Users" />
-            <End Role="Tests" EntitySet="Tests" />
+            <End Role="Answers" EntitySet="Answers" />
           </AssociationSet>
-          <EntitySet Name="sysdiagrams" EntityType="MyTestsDataBaseModel.sysdiagrams" />
-          <EntitySet Name="Answers" EntityType="MyTestsDataBaseModel.Answers" />
-          <AssociationSet Name="FK_Answers_Questions" Association="MyTestsDataBaseModel.FK_Answers_Questions">
+          <AssociationSet Name="FK_Questions_Tests" Association="Self.FK_Questions_Tests">
+            <End Role="Tests" EntitySet="Tests" />
             <End Role="Questions" EntitySet="Questions" />
-            <End Role="Answers" EntitySet="Answers" />
           </AssociationSet>
-          <AssociationSet Name="FK_Answers_Users" Association="MyTestsDataBaseModel.FK_Answers_Users">
+          <AssociationSet Name="FK_Tests_Users" Association="Self.FK_Tests_Users">
             <End Role="Users" EntitySet="Users" />
-            <End Role="Answers" EntitySet="Answers" />
+            <End Role="Tests" EntitySet="Tests" />
           </AssociationSet>
         </EntityContainer>
-        <EntityType Name="sysdiagrams">
-          <Key>
-            <PropertyRef Name="diagram_id" />
-          </Key>
-          <Property Name="name" Type="String" Nullable="false" MaxLength="128" FixedLength="false" Unicode="true" />
-          <Property Name="principal_id" Type="Int32" Nullable="false" />
-          <Property Name="diagram_id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="version" Type="Int32" />
-          <Property Name="definition" Type="Binary" MaxLength="Max" FixedLength="false" />
-        </EntityType>
-        <EntityType Name="Answers">
-          <Key>
-            <PropertyRef Name="IdUserAnswer" />
-          </Key>
-          <Property Name="IdUserAnswer" Type="Int32" Nullable="false" />
-          <Property Name="IdQuestion" Type="Int32" Nullable="false" />
-          <Property Name="IdUser" Type="Int32" Nullable="false" />
-          <Property Name="Answer" Type="String" Nullable="false" MaxLength="150" FixedLength="false" Unicode="true" />
-          <NavigationProperty Name="Questions" Relationship="MyTestsDataBaseModel.FK_Answers_Questions" FromRole="Answers" ToRole="Questions" />
-          <NavigationProperty Name="Users" Relationship="MyTestsDataBaseModel.FK_Answers_Users" FromRole="Answers" ToRole="Users" />
-        </EntityType>
-        <Association Name="FK_Answers_Questions">
-          <End Type="MyTestsDataBaseModel.Questions" Role="Questions" Multiplicity="1" />
-          <End Type="MyTestsDataBaseModel.Answers" Role="Answers" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Questions">
-              <PropertyRef Name="IdQuestion" />
-            </Principal>
-            <Dependent Role="Answers">
-              <PropertyRef Name="IdQuestion" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
-        <Association Name="FK_Answers_Users">
-          <End Type="MyTestsDataBaseModel.Users" Role="Users" Multiplicity="1" />
-          <End Type="MyTestsDataBaseModel.Answers" Role="Answers" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Users">
-              <PropertyRef Name="IdUser" />
-            </Principal>
-            <Dependent Role="Answers">
-              <PropertyRef Name="IdUser" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
       </Schema>
     </edmx:ConceptualModels>
     <!-- C-S mapping content -->
     <edmx:Mappings>
       <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
-  <EntityContainerMapping StorageEntityContainer="MyTestsDataBaseModelStoreContainer" CdmEntityContainer="MyTestsDataBaseEntities">
-    <EntitySetMapping Name="Questions">
-      <EntityTypeMapping TypeName="IsTypeOf(MyTestsDataBaseModel.Questions)">
-        <MappingFragment StoreEntitySet="Questions">
-          <ScalarProperty Name="IdQuestion" ColumnName="IdQuestion" />
-          <ScalarProperty Name="IdTest" ColumnName="IdTest" />
-          <ScalarProperty Name="Content" ColumnName="Content" />
-          <ScalarProperty Name="Answer" ColumnName="Answer" />
-        </MappingFragment>
-      </EntityTypeMapping>
-    </EntitySetMapping>
-    <EntitySetMapping Name="Tests">
-      <EntityTypeMapping TypeName="IsTypeOf(MyTestsDataBaseModel.Tests)">
-        <MappingFragment StoreEntitySet="Tests">
-          <ScalarProperty Name="IdTest" ColumnName="IdTest" />
-          <ScalarProperty Name="IdUser" ColumnName="IdUser" />
-          <ScalarProperty Name="Name" ColumnName="Name" />
-          <ScalarProperty Name="Image" ColumnName="Image" />
-        </MappingFragment>
-      </EntityTypeMapping>
-    </EntitySetMapping>
-          <EntitySetMapping Name="Users">
-      <EntityTypeMapping TypeName="IsTypeOf(MyTestsDataBaseModel.Users)">
-              <MappingFragment StoreEntitySet="Users">
-          <ScalarProperty Name="IdUser" ColumnName="IdUser" />
-          <ScalarProperty Name="Login" ColumnName="Login" />
-          <ScalarProperty Name="Password" ColumnName="Password" />
-          <ScalarProperty Name="Email" ColumnName="Email" />
-          <ScalarProperty Name="Info" ColumnName="Info" />
-                <ScalarProperty Name="Image" ColumnName="Image" />
-        </MappingFragment>
-      </EntityTypeMapping>
-    </EntitySetMapping>
-          <EntitySetMapping Name="sysdiagrams">
-            <EntityTypeMapping TypeName="MyTestsDataBaseModel.sysdiagrams">
-              <MappingFragment StoreEntitySet="sysdiagrams">
-                <ScalarProperty Name="definition" ColumnName="definition" />
-                <ScalarProperty Name="version" ColumnName="version" />
-                <ScalarProperty Name="diagram_id" ColumnName="diagram_id" />
-                <ScalarProperty Name="principal_id" ColumnName="principal_id" />
-                <ScalarProperty Name="name" ColumnName="name" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
+        <EntityContainerMapping StorageEntityContainer="Хранилище MyTestsDataBaseModelContainer" CdmEntityContainer="MyTestsDataBaseEntities">
           <EntitySetMapping Name="Answers">
             <EntityTypeMapping TypeName="MyTestsDataBaseModel.Answers">
               <MappingFragment StoreEntitySet="Answers">
-                <ScalarProperty Name="Answer" ColumnName="Answer" />
+                <ScalarProperty Name="IdUserAnswer" ColumnName="IdUserAnswer" />
+                <ScalarProperty Name="IdQuestion" ColumnName="IdQuestion" />
                 <ScalarProperty Name="IdUser" ColumnName="IdUser" />
+                <ScalarProperty Name="Answer" ColumnName="Answer" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Questions">
+            <EntityTypeMapping TypeName="MyTestsDataBaseModel.Questions">
+              <MappingFragment StoreEntitySet="Questions">
                 <ScalarProperty Name="IdQuestion" ColumnName="IdQuestion" />
-                <ScalarProperty Name="IdUserAnswer" ColumnName="IdUserAnswer" />
+                <ScalarProperty Name="IdTest" ColumnName="IdTest" />
+                <ScalarProperty Name="Content" ColumnName="Content" />
+                <ScalarProperty Name="Answer" ColumnName="Answer" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Tests">
+            <EntityTypeMapping TypeName="MyTestsDataBaseModel.Tests">
+              <MappingFragment StoreEntitySet="Tests">
+                <ScalarProperty Name="IdTest" ColumnName="IdTest" />
+                <ScalarProperty Name="IdUser" ColumnName="IdUser" />
+                <ScalarProperty Name="Name" ColumnName="Name" />
+                <ScalarProperty Name="Image" ColumnName="Image" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Users">
+            <EntityTypeMapping TypeName="MyTestsDataBaseModel.Users">
+              <MappingFragment StoreEntitySet="Users">
+                <ScalarProperty Name="IdUser" ColumnName="IdUser" />
+                <ScalarProperty Name="Login" ColumnName="Login" />
+                <ScalarProperty Name="Password" ColumnName="Password" />
+                <ScalarProperty Name="Email" ColumnName="Email" />
+                <ScalarProperty Name="Info" ColumnName="Info" />
+                <ScalarProperty Name="Image" ColumnName="Image" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
         </EntityContainerMapping>
-</Mapping></edmx:Mappings>
+      </Mapping>
+    </edmx:Mappings>
   </edmx:Runtime>
   <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
   <Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
@@ -329,7 +298,7 @@
         <DesignerProperty Name="ValidateOnBuild" Value="true" />
         <DesignerProperty Name="EnablePluralization" Value="false" />
         <DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
-        <DesignerProperty Name="UseLegacyProvider" Value="False" />
+        <DesignerProperty Name="UseLegacyProvider" Value="false" />
         <DesignerProperty Name="CodeGenerationStrategy" Value="Нет" />
       </DesignerInfoPropertySet>
     </Options>

+ 7 - 12
MyTests/EDM.edmx.diagram

@@ -4,20 +4,15 @@
   <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
-      <Diagram DiagramId="a3a420bb96024b0f95a0dd865890e046" Name="Diagram1" ZoomLevel="132">
-        <EntityTypeShape EntityType="MyTestsDataBaseModel.Questions" Width="1.5" PointX="5.25" PointY="1" IsExpanded="true" />
-        <EntityTypeShape EntityType="MyTestsDataBaseModel.Tests" Width="1.5" PointX="3" PointY="1" IsExpanded="true" />
-        <EntityTypeShape EntityType="MyTestsDataBaseModel.Users" Width="1.5" PointX="0.75" PointY="1" IsExpanded="true" />
+      <Diagram DiagramId="d43acb8abf174d81b935ee8c6a0e239d" Name="Diagram1">
+        <EntityTypeShape EntityType="MyTestsDataBaseModel.Answers" Width="1.5" PointX="7.5" PointY="3.875" IsExpanded="true" />
+        <EntityTypeShape EntityType="MyTestsDataBaseModel.Questions" Width="1.5" PointX="5.25" PointY="5.5" IsExpanded="true" />
+        <EntityTypeShape EntityType="MyTestsDataBaseModel.Tests" Width="1.5" PointX="3" PointY="5.5" IsExpanded="true" />
+        <EntityTypeShape EntityType="MyTestsDataBaseModel.Users" Width="1.5" PointX="0.75" PointY="2.375" IsExpanded="true" />
+        <AssociationConnector Association="MyTestsDataBaseModel.FK_Answers_Questions" ManuallyRouted="false" />
+        <AssociationConnector Association="MyTestsDataBaseModel.FK_Answers_Users" ManuallyRouted="false" />
         <AssociationConnector Association="MyTestsDataBaseModel.FK_Questions_Tests" ManuallyRouted="false" />
         <AssociationConnector Association="MyTestsDataBaseModel.FK_Tests_Users" ManuallyRouted="false" />
-        <EntityTypeShape EntityType="MyTestsDataBaseModel.sysdiagrams" Width="1.5" PointX="0.75" PointY="4.75" />
-        <EntityTypeShape EntityType="MyTestsDataBaseModel.Answers" Width="1.5" PointX="3.125" PointY="4" />
-        <AssociationConnector Association="MyTestsDataBaseModel.FK_Answers_Questions" />
-        <AssociationConnector Association="MyTestsDataBaseModel.FK_Answers_Users" ManuallyRouted="true" >
-          <ConnectorPoint PointX="1.5" PointY="3.5571907552083331" />
-          <ConnectorPoint PointX="1.5" PointY="4.4754490993496754" />
-          <ConnectorPoint PointX="3.125" PointY="4.4754490993496754" />
-        </AssociationConnector>
       </Diagram>
     </edmx:Diagrams>
   </edmx:Designer>

+ 21 - 3
MyTests/MyTests.csproj

@@ -67,6 +67,9 @@
     <Compile Include="Answers.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
+    <Compile Include="Authorization.xaml.cs">
+      <DependentUpon>Authorization.xaml</DependentUpon>
+    </Compile>
     <Compile Include="EDM.Context.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
@@ -100,17 +103,24 @@
     <Compile Include="Questions.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
+    <Compile Include="RegAuth.xaml.cs">
+      <DependentUpon>RegAuth.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Registration.xaml.cs">
+      <DependentUpon>Registration.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Session.cs" />
     <Compile Include="Styles\Style.cs" />
-    <Compile Include="sysdiagrams.cs">
-      <DependentUpon>EDM.tt</DependentUpon>
-    </Compile>
     <Compile Include="Tests.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
     <Compile Include="Users.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
+    <Page Include="Authorization.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="ConfirmationWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -160,6 +170,14 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="RegAuth.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
+    <Page Include="Registration.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
     <Page Include="Styles\Style.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 5 - 4
MyTests/Pages/ProfilePage.xaml

@@ -53,7 +53,7 @@
                 </Grid.RowDefinitions>
                 <StackPanel Grid.Row="0"
                             Orientation="Horizontal">
-                    <TextBox Text="Email: "
+                    <Label Content="Email: "
                              Background="{x:Null}"
                              BorderBrush="{x:Null}"
                              FontSize="22"/>
@@ -62,17 +62,18 @@
                          FontSize="22"
                          Background="{x:Null}"
                          BorderBrush="{x:Null}"
-                         Width="{Binding Path=ActualWidth, ElementName=UserInfoGrid}">
+                         Width="{Binding Path=ActualWidth, ElementName=UserInfoGrid}"
+                              >
                     </TextBox>
                 </StackPanel>
 
                 <StackPanel Grid.Row="1"
                             Orientation="Horizontal">
-                    <TextBox Text="Инфо: "
+                    <Label Content="Инфо: "
                          FontSize="22"
                          Background="{x:Null}"
                          BorderBrush="{x:Null}">
-                    </TextBox>
+                    </Label>
                     <TextBox Name="InfoBox"
                          Text=""
                          FontSize="22"

+ 5 - 0
MyTests/Pages/ProfilePage.xaml.cs

@@ -21,6 +21,11 @@ namespace MyTests.Pages
                 ProfileImage.Source = ImagesManip.NewImage(user);
             EmailBox.Text = user.Email;
             InfoBox.Text = user.Info;
+            if (user != Session.User)
+            {
+                EmailBox.IsEnabled = false;
+                InfoBox.IsEnabled = false;
+            }
             TestsLoading();
         }
         private void EditImage_Click(object sender, RoutedEventArgs e)

+ 1 - 1
MyTests/Questions.cs

@@ -25,8 +25,8 @@ namespace MyTests
         public string Content { get; set; }
         public string Answer { get; set; }
     
-        public virtual Tests Tests { get; set; }
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Answers> Answers { get; set; }
+        public virtual Tests Tests { get; set; }
     }
 }

+ 1 - 1
MyTests/RegAuth.xaml

@@ -7,7 +7,7 @@
         xmlns:local="clr-namespace:MyTests"
         mc:Ignorable="d"
         Title="RegAuth" Height="475" Width="475">
-    <Grid>
+    <Grid Background="#2F3136">
         <Grid.RowDefinitions>
             <RowDefinition Height="50*"/>
             <RowDefinition Height="25*"/>

+ 1 - 1
MyTests/Registration.xaml

@@ -8,7 +8,7 @@
       d:DesignHeight="450" d:DesignWidth="800"
       Title="Registration" Height="475" Width="475">
 
-    <Grid>
+    <Grid Background="#2F3136">
         <TextBox x:Name="Login" LostFocus="LoginLostFocus" GotFocus="LoginFocus" HorizontalAlignment="Center" Height="30" Margin="174,19,175,0" TextWrapping="Wrap" Text="Логин" VerticalAlignment="Top" Width="126" TextAlignment="Center" FontSize="14"/>
         <TextBox x:Name="Password" LostFocus="PasswordLostFocus" GotFocus="PasswordFocus" HorizontalAlignment="Center" Height="30" Margin="174,72,175,0" TextWrapping="Wrap" Text="Пароль" VerticalAlignment="Top" Width="126" TextAlignment="Center" FontSize="14"/>
         <TextBox x:Name="Email" LostFocus="EmailLostFocus" GotFocus="EmailNameFocus" HorizontalAlignment="Center" Height="30" Margin="174,122,175,0" TextWrapping="Wrap" Text="Почта" VerticalAlignment="Top" Width="126" TextAlignment="Center" FontSize="14"/>

+ 6 - 5
MyTests/Registration.xaml.cs

@@ -37,16 +37,17 @@ namespace MyTests
                     {
                         Users newUser = new Users()
                         {
-                            IdUsers = Connection.db.Users.Select(p => p.IdUsers).DefaultIfEmpty(0).Max() + 1,
+                            IdUser = cnt.db.Users.Select(p => p.IdUser).DefaultIfEmpty(0).Max() + 1,
                             Login = Login.Text,
                             Password = Password.Text,
                             Email = Email.Text,
                             Info = Info.Text
                         };
-                        Connection.db.Users.Add(newUser);
-                        Connection.db.SaveChanges();
+                        cnt.db.Users.Add(newUser);
+                        cnt.db.SaveChanges();
                         MessageBox.Show("Вы успешно зарегистрировались");
-                        Session.UserId = Connection.db.Users.Select(item => item.IdUsers).Max();
+                        Session.User = cnt.db.Users.Where(item => item.Login == Login.Text && item.Password == Password.Text).FirstOrDefault();
+
                         MainWindow RegAuth = new MainWindow();
                         RegAuth.Show();
                     }
@@ -65,7 +66,7 @@ namespace MyTests
 
         public bool RegistrLogin(string Login)
         {
-            //if (Connection.db.Users.Select(item => item.Login).Contains(Login))
+            //if (cnt.db.Users.Select(item => item.Login).Contains(Login))
             //    return true;
             //else
                 return false;

+ 1 - 1
MyTests/Session.cs

@@ -8,7 +8,7 @@ namespace MyTests
 {
     class Session
     {
-        public static Users User = cnt.db.Users.Where(item => item.IdUser == 1).FirstOrDefault(); //{ get; set; }
+        public static Users User { get; set; }
         public static Tests OpenedTest { get; set; }
         public static int Points = 0;
         public static int CurQuestion = 0;

+ 3 - 3
MyTests/Users.cs

@@ -17,8 +17,8 @@ namespace MyTests
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
         public Users()
         {
-            this.Tests = new HashSet<Tests>();
             this.Answers = new HashSet<Answers>();
+            this.Tests = new HashSet<Tests>();
         }
     
         public int IdUser { get; set; }
@@ -29,8 +29,8 @@ namespace MyTests
         public byte[] Image { get; set; }
     
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
-        public virtual ICollection<Tests> Tests { get; set; }
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Answers> Answers { get; set; }
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<Tests> Tests { get; set; }
     }
 }

+ 0 - 23
MyTests/sysdiagrams.cs

@@ -1,23 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-//     Этот код создан по шаблону.
-//
-//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
-//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace MyTests
-{
-    using System;
-    using System.Collections.Generic;
-    
-    public partial class sysdiagrams
-    {
-        public string name { get; set; }
-        public int principal_id { get; set; }
-        public int diagram_id { get; set; }
-        public Nullable<int> version { get; set; }
-        public byte[] definition { get; set; }
-    }
-}