bai 4 months ago
parent
commit
ea6433242f

+ 23 - 0
ViewModels/AddEmployeesViewModel.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using Acosta.Models;
+using Acosta.Views;
 using ReactiveUI;
 
 namespace Acosta.ViewModels
@@ -9,14 +10,36 @@ namespace Acosta.ViewModels
 	{
         SuharevaContext myConnection;
         Employee currentUser;
+        string f;
+        string i;
+        string o;
+        string phone;
+        string email;
+        int role;
+        string password;
 
         public AddEmployeesViewModel(SuharevaContext myConnection)
         {
             this.myConnection = myConnection;
             CurrentUser = new Employee();
+            //CurrentUser.Surname = F;
+            //CurrentUser.Name = I;
+            //CurrentUser.Patronymic = O;
+            //CurrentUser.Phonenumber = Phone;
+            //CurrentUser.Email = Email;
+            //CurrentUser.Password = Password;
+            //CurrentUser.Role = Role;
             myConnection.Add(CurrentUser);
         }
 
         public Employee CurrentUser { get => currentUser; set => currentUser = value; }
+
+        public string Phone { get => phone; set => phone = value; }
+        public string Email { get => email; set => email = value; }
+        public int Role { get => role; set => role = value; }
+        public string Password { get => password; set => password = value; }
+        public string F { get => f; set => f = value; }
+        public string I { get => i; set => i = value; }
+        public string O { get => o; set => o = value; }
     }
 }

+ 4 - 1
ViewModels/MainWindowViewModel.cs

@@ -6,6 +6,7 @@ using System.Linq;
 using Acosta.ViewModels;
 using System.Collections.Generic;
 using Microsoft.EntityFrameworkCore;
+using System.Collections.Immutable;
 
 namespace Acosta.ViewModels
 {
@@ -56,6 +57,8 @@ namespace Acosta.ViewModels
         }
 
         public List<Project> ListProjects => myConnection.Projects.ToList();
+        public List<Role> rolesList => (from p in myConnection.Roles.ToList() where p.Title != "Оператор" select p).ToImmutableList().ToList();
+        public List<Employee> userList => (from p in myConnection.Employees.ToList() where p.Role != 1 select p).ToImmutableList().ToList();
 
         public void ExitFromProfile()
         {
@@ -89,7 +92,7 @@ namespace Acosta.ViewModels
         {
             UC = new EmployeesView();
         }
-        public void EditEmployeesView()
+        public void EditEmployeesView(int userID)
         {
             UC = new EditEmployeesView();
         }

+ 10 - 0
Views/AddEmployeesView.axaml

@@ -186,6 +186,16 @@
 						<TextBlock Classes="TextToTextBox">Роль:</TextBlock>
 						<TextBox Text="{Binding AddEmployeesViewModel.CurrentUser.Role}" Watermark="Роль" Width="360" Margin="200 20 0 0"></TextBox>
 					</StackPanel>
+					<!--<StackPanel Orientation="Horizontal">
+						<TextBlock Classes="TextToTextBox">Роль:</TextBlock>
+						<ComboBox ItemsSource="{Binding rolesList}">
+							<ComboBox.ItemTemplate>
+								<DataTemplate>
+									<TextBlock Text="{Binding Roleid}" />
+								</DataTemplate>
+							</ComboBox.ItemTemplate>
+						</ComboBox>
+					</StackPanel>-->
 					<Border Background="#969696" CornerRadius="13"  Width="1150" Height="0.5" Margin="197 30 0 10" HorizontalAlignment="Left"></Border>
 					<TextBlock Classes="TextToTextBox">Проекты:</TextBlock>
 					<ListBox ItemsSource="{Binding ListProjects}">

+ 9 - 0
Views/AddEmployeesView.axaml.cs

@@ -1,11 +1,20 @@
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Markup.Xaml;
+using System;
+using Acosta;
+using Acosta.Models;
+using System.Collections.Generic;
+using System.Linq;
+using Acosta.ViewModels;
 
 namespace Acosta.Views;
 
 public partial class AddEmployeesView : UserControl
 {
+    SuharevaContext myConnection;
+    Role role;
+    
     public AddEmployeesView()
     {
         InitializeComponent();