Browse Source

Try to do registration

AngelikaSuhareva 5 months ago
parent
commit
c7dc423b8a

+ 4 - 1
ViewModels/MainWindowViewModel.cs

@@ -9,7 +9,10 @@ namespace YtYtAvalonia.ViewModels
 #pragma warning disable CA1822 // Mark members as static
 
         public static SuharevaContext myConnection = new SuharevaContext();
-        public string Greeting => "Welcome to Avalonia!";
+
+        RegistrationViewModel regPage = new RegistrationViewModel(myConnection);
+        public RegistrationViewModel RegPage { get => regPage; set => regPage = value; }
+
 #pragma warning restore CA1822 // Mark members as static
     }
 }

+ 35 - 1
ViewModels/RegistrationViewModel.cs

@@ -1,10 +1,44 @@
 using System;
 using System.Collections.Generic;
 using ReactiveUI;
+using YtYtAvalonia.Models;
 
 namespace YtYtAvalonia.ViewModels
 {
 	public class RegistrationViewModel : ReactiveObject
 	{
-	}
+        /*string login = "";
+		string password = "";
+        string surname = "";
+        string name = "";
+        string patronymic = "";
+        int day;
+        int month;
+        int year;
+        string email = "";
+        int phone;
+
+        public string Login { get => login; set => login = value; }
+        public string Password { get => password; set => password = value; }
+        public string Surname { get => surname; set => surname = value; }
+        public string Name { get => name; set => name = value; }
+        public string Patronymic { get => patronymic; set => patronymic = value; }
+        public int Day { get => day; set => day = value; }
+        public int Month { get => month; set => month = value; }
+        public int Year { get => year; set => year = value; }
+        public string Email { get => email; set => email = value; }
+        public int Phone { get => phone; set => phone = value; }*/
+
+        SuharevaContext myConnection;
+        User currentUser;
+        public RegistrationViewModel(SuharevaContext myConnection)
+        {
+            this.myConnection = myConnection;
+            CurrentUser = new User();
+            myConnection.Add(CurrentUser);
+            myConnection.SaveChanges();
+        }
+
+        public User CurrentUser { get => currentUser; set => currentUser = value; }
+    }
 }

+ 3 - 1
Views/RegistrationView.axaml

@@ -3,6 +3,8 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+			 xmlns:vm="using:YtYtAvalonia.ViewModels"
+			 x:DataType="vm:MainWindowViewModel"
              x:Class="YtYtAvalonia.View.RegistrationView">
 	<Grid>
 		<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
@@ -35,7 +37,7 @@
 			</StackPanel.Styles>
 
 			<TextBlock HorizontalAlignment="Center" Margin="0 0 0 30" FontFamily="Roboto" FontSize="25" FontWeight="Bold">Регистрация</TextBlock>
-			<TextBox Watermark="Логин" Width="360" FontSize="13" Margin="0 0 0 10" ></TextBox>
+			<TextBox Text="{}" Watermark="Логин" Width="360" FontSize="13" Margin="0 0 0 10" ></TextBox>
 			<TextBox Watermark="Пароль" PasswordChar="•" Width="360" ></TextBox>
 			<TextBlock Margin="0 25 0 0"  FontFamily="Roboto" FontSize="14">Личные данные:</TextBlock>
 			<TextBox Watermark="Фамилия" Width="360" FontSize="13" Margin="0 10 0 10" ></TextBox>

+ 3 - 1
Views/RegistrationView.axaml.cs

@@ -1,6 +1,8 @@
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Markup.Xaml;
+using YtYtAvalonia.ViewModels;
+using YtYtAvalonia.Models;
 
 namespace YtYtAvalonia.View;
 
@@ -8,6 +10,6 @@ public partial class RegistrationView : UserControl
 {
     public RegistrationView()
     {
-        InitializeComponent();
+
     }
 }