فهرست منبع

listbox test2

Imagara 2 سال پیش
والد
کامیت
ddbc7162c2
4فایلهای تغییر یافته به همراه22 افزوده شده و 21 حذف شده
  1. 16 14
      MyTests/Functions.cs
  2. 1 1
      MyTests/Pages/ProfilePage.xaml.cs
  3. 2 4
      MyTests/Pages/TestsCatalog.xaml
  4. 3 2
      MyTests/Pages/TestsCatalog.xaml.cs

+ 16 - 14
MyTests/Functions.cs

@@ -1,4 +1,6 @@
-namespace MyTests
+using System.Linq;
+
+namespace MyTests
 {
     public class Functions
     {
@@ -26,18 +28,18 @@
             else
                 return true;
         }
-        //// Проверка на правильность введеных данных при входе
-        //public static bool LoginCheck(string login, string password)
-        //{
-        //    if (cnt.db.User.Select(item => item.Login + item.Password).Contains(login + Encrypt.GetHash(password)))
-        //        return true;
-        //    else
-        //        return false;
-        //}
-        //// Проверка на уникальность логина
-        //public static bool IsLoginAlreadyTaken(string login)
-        //{
-        //    return cnt.db.User.Select(item => item.Login).Contains(login);
-        //}
+        // Проверка на правильность введеных данных при входе
+        public static bool LoginCheck(string login, string password)
+        {
+            //if (cnt.db.Users.Select(item => item.Login + item.Password).Contains(login + Encrypt.GetHash(password)))
+                return true;
+            //else
+            //    return false;
+        }
+        // Проверка на уникальность логина
+        public static bool IsLoginAlreadyTaken(string login)
+        {
+            return cnt.db.Users.Select(item => item.Login).Contains(login);
+        }
     }
 }

+ 1 - 1
MyTests/Pages/ProfilePage.xaml.cs

@@ -58,7 +58,7 @@ namespace MyTests.Pages
         }
         private void AddTest(string name, BitmapImage image, int questCount)
         {
-            MessageBox.Show($"{name}, quests:, {questCount}");
+            //MessageBox.Show($"{name}, quests:, {questCount}");
         }
 
         private void SaveButton(object sender, RoutedEventArgs e)

+ 2 - 4
MyTests/Pages/TestsCatalog.xaml

@@ -46,8 +46,6 @@
                            Margin="10"/>
                 </Button>
             </StackPanel>
-
-
         </Border>
 
         <ListBox Name="TestsListBox"
@@ -70,8 +68,8 @@
                             </Image>
                             <StackPanel>
                                 <StackPanel Orientation="Horizontal">
-                                    <Label Content="Тестовый тест"/>
-                                    <Label Content="by ima"/>
+                                    <Label Content="{Binding TestName}"/>
+                                    <Label Content="{Binding TestAuthor}"/>
                                 </StackPanel>
                                 <Label Content="Вопросов: 15"
                                    Margin="0,-7,0,0">

+ 3 - 2
MyTests/Pages/TestsCatalog.xaml.cs

@@ -23,7 +23,6 @@ namespace MyTests.Pages
         public TestsCatalog()
         {
             InitializeComponent();
-
             //LoadingTests();
         }
 
@@ -80,6 +79,7 @@ namespace MyTests.Pages
                 list = list.Where(item => item.Name == TestNameBox.Text).ToList();
             if(AuthorTestBox.Text != "Автор")
                 list = list.Where(item => item.Users.Login == AuthorTestBox.Text).ToList();
+
             foreach (Tests test in list)
             {
                 try
@@ -87,7 +87,8 @@ namespace MyTests.Pages
                     BitmapImage img = test.Image == null ?
                         new BitmapImage(new Uri("../Resources/Approval.png", UriKind.RelativeOrAbsolute)) :
                         ImagesManip.NewImage(cnt.db.Users.Where(item => item.IdUser == Session.userId).FirstOrDefault());
-                    AddTest(test.Name, img, cnt.db.Questions.Where(item => item.IdTest == test.IdTest).Count());
+                    TestsListBox.ItemsSource = new[] { new { TestName = test.Name, TestAuthor = test.Users.Login } };
+                    //AddTest(test.Name, img, cnt.db.Questions.Where(item => item.IdTest == test.IdTest).Count());
                 }
                 catch (Exception ex)
                 {