diff --git a/Database/EmployeeRepository.cs b/Database/EmployeeRepository.cs index 28af27b..f00aeab 100644 --- a/Database/EmployeeRepository.cs +++ b/Database/EmployeeRepository.cs @@ -15,10 +15,10 @@ public class EmployeeRepository connection = new MySqlConnection(connect.Value.ConnectionString); } - public List GetEmployees(Position position) + public List GetEmployees() { List result = new(); - string sql = "select * from `employee` where position_id = " + position.Id; + string sql = "select e.id as eid, e.position_id as pid, e.name as ename, e.surname as esurname, p.name as pname from employee e join position p on e.position_id = p.id"; try { connection.Open(); @@ -29,11 +29,20 @@ public class EmployeeRepository { result.Add(new Employee { + /* Id = reader.GetInt32("id"), Name = reader.GetString("name"), Surname = reader.GetString("surname"), - OnWork = reader.GetBoolean("on_work"), PositionId = reader.GetInt32("position_id"), + */ + Id = reader.GetInt32("eid"), + Name = reader.GetString("ename"), + Surname = reader.GetString("esurname"), + Position = new Position() + { + Id = reader.GetInt32("pid"), + Name = reader.GetString("name"), + } }); } } @@ -57,7 +66,6 @@ public class EmployeeRepository { command.Parameters.AddWithValue("@name", employee.Name); command.Parameters.AddWithValue("@surname", employee.Surname); - command.Parameters.AddWithValue("@on_work", employee.OnWork); command.Parameters.AddWithValue("@position_id", employee.PositionId); command.ExecuteNonQuery(); } @@ -82,7 +90,6 @@ public class EmployeeRepository { command.Parameters.AddWithValue("@name", employee.Name); command.Parameters.AddWithValue("@surname", employee.Surname); - command.Parameters.AddWithValue("@on_work", employee.OnWork); command.Parameters.AddWithValue("@position_id", employee.PositionId); command.ExecuteNonQuery(); } diff --git a/Models/Employee.cs b/Models/Employee.cs index 6c2e982..040a951 100644 --- a/Models/Employee.cs +++ b/Models/Employee.cs @@ -5,6 +5,6 @@ public class Employee public int Id { get; set; } public string Name { get; set; } public string Surname { get; set; } - public bool OnWork { get; set; } public int PositionId { get; set; } + public Position Position { get; set; } } \ No newline at end of file diff --git a/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs index 9df03bc..1456dcd 100644 --- a/ViewModels/MainWindowViewModel.cs +++ b/ViewModels/MainWindowViewModel.cs @@ -13,6 +13,7 @@ public partial class MainWindowViewModel : ViewModelBase private readonly OrderRepository _orderRepository; [ObservableProperty] List orders; + [ObservableProperty] List employees; public MainWindowViewModel(IServiceProvider serviceProvider, EmployeeRepository employeeRepository, OrderRepository orderRepository) { @@ -20,6 +21,7 @@ public partial class MainWindowViewModel : ViewModelBase _employeeRepository = employeeRepository; _orderRepository = orderRepository; + Employees = employeeRepository.GetEmployees(); Orders = orderRepository.GetOrders(); } } \ No newline at end of file diff --git a/Views/MainWindow.axaml b/Views/MainWindow.axaml index e6bbdfd..4d7bc17 100644 --- a/Views/MainWindow.axaml +++ b/Views/MainWindow.axaml @@ -16,17 +16,24 @@ - - - - - + + + + + + - + + + + + + + diff --git a/obj/Debug/net10.0/Avalonia/resources b/obj/Debug/net10.0/Avalonia/resources index 253638a..316af9d 100644 Binary files a/obj/Debug/net10.0/Avalonia/resources and b/obj/Debug/net10.0/Avalonia/resources differ diff --git a/obj/Debug/net10.0/BathHouseManagmet.AssemblyInfo.cs b/obj/Debug/net10.0/BathHouseManagmet.AssemblyInfo.cs index 97c457c..a631c4c 100644 --- a/obj/Debug/net10.0/BathHouseManagmet.AssemblyInfo.cs +++ b/obj/Debug/net10.0/BathHouseManagmet.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("BathHouseManagmet")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+55e84ef57c6abfe4ef4f4ef588ea91f719ce8536")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4e1ab770f1b973c62387290bf8e7c9407bc2cd2a")] [assembly: System.Reflection.AssemblyProductAttribute("BathHouseManagmet")] [assembly: System.Reflection.AssemblyTitleAttribute("BathHouseManagmet")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net10.0/BathHouseManagmet.AssemblyInfoInputs.cache b/obj/Debug/net10.0/BathHouseManagmet.AssemblyInfoInputs.cache index aade2f0..dcc5831 100644 --- a/obj/Debug/net10.0/BathHouseManagmet.AssemblyInfoInputs.cache +++ b/obj/Debug/net10.0/BathHouseManagmet.AssemblyInfoInputs.cache @@ -1 +1 @@ -af96d54e4de83c2d92c24c535a5ffbc3bfff4696e1e3b1ef13b37dfd8a84647a +f47cb2fe8a4221890c3e523f6ef8a05ece1d4ec0d2150086183c9d3e4a5ddd93