Compare commits

...

No commits in common. "test_docker" and "main" have entirely different histories.

76 changed files with 2235 additions and 339 deletions

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="EmployeeDB"
connectionString="Host=localhost;Port=5432;Database=EmployeeDB;Username=postgres;Password=yourpassword;"
providerName="Npgsql" />
</connectionStrings>
</configuration>

View File

@ -1,21 +0,0 @@
using EmployeeManagementApp.Views;
using System.Configuration;
using System.Data;
using System.Windows;
namespace EmployeeManagementApp
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
MainView mainView = new MainView();
mainView.Show();
}
}
}

View File

@ -1,22 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
</ItemGroup>
</Project>

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34622.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeManagementApp", "EmployeeManagementApp.csproj", "{9306908A-4709-44E8-8167-A460AF54E843}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9306908A-4709-44E8-8167-A460AF54E843}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9306908A-4709-44E8-8167-A460AF54E843}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9306908A-4709-44E8-8167-A460AF54E843}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9306908A-4709-44E8-8167-A460AF54E843}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2D98777E-2086-4BCE-BCBE-357B9813BA1F}
EndGlobalSection
EndGlobal

49
EmployeeManagmentApp.sln Normal file
View File

@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34622.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EmployeeManagmentView", "EmployeeManagmentView\EmployeeManagmentView.csproj", "{1A4AD060-3351-4B07-997E-59BAEDDAC493}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EmployeeManagmentContracts", "EmployeeManagmentContracts\EmployeeManagmentContracts.csproj", "{81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EmployeeManagmentBusinessLogic", "EmployeeManagmentBusinessLogic\EmployeeManagmentBusinessLogic.csproj", "{00B118F5-6A3C-4606-8947-88D0288AEFDB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EmployeeManagmentDataModels", "EmployeeManagmentDataModels\EmployeeManagmentDataModels.csproj", "{C5293211-E924-4CFA-9DE5-69003D8C9F48}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeManagmentDataBaseImplement", "EmployeeManagmentDataBaseImplement\EmployeeManagmentDataBaseImplement.csproj", "{18CB8173-C3E1-4655-A453-A48F20E1DF2E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1A4AD060-3351-4B07-997E-59BAEDDAC493}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A4AD060-3351-4B07-997E-59BAEDDAC493}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A4AD060-3351-4B07-997E-59BAEDDAC493}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A4AD060-3351-4B07-997E-59BAEDDAC493}.Release|Any CPU.Build.0 = Release|Any CPU
{81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}.Release|Any CPU.Build.0 = Release|Any CPU
{00B118F5-6A3C-4606-8947-88D0288AEFDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00B118F5-6A3C-4606-8947-88D0288AEFDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00B118F5-6A3C-4606-8947-88D0288AEFDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00B118F5-6A3C-4606-8947-88D0288AEFDB}.Release|Any CPU.Build.0 = Release|Any CPU
{C5293211-E924-4CFA-9DE5-69003D8C9F48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5293211-E924-4CFA-9DE5-69003D8C9F48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5293211-E924-4CFA-9DE5-69003D8C9F48}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5293211-E924-4CFA-9DE5-69003D8C9F48}.Release|Any CPU.Build.0 = Release|Any CPU
{18CB8173-C3E1-4655-A453-A48F20E1DF2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18CB8173-C3E1-4655-A453-A48F20E1DF2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18CB8173-C3E1-4655-A453-A48F20E1DF2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18CB8173-C3E1-4655-A453-A48F20E1DF2E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {20DBA0FB-B8AD-4C17-A7A8-16069474A58A}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,165 @@
using System.Collections.Generic;
using System.Linq;
using EmployeeManagmentContracts.BindingModels;
using EmployeeManagmentContracts.BusinessLogicContracts;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using EmployeeManagmentDataBaseImplement;
using EmployeeManagmentDataBaseImplement.Models;
namespace EmployeeManagmentBusinessLogic.BusinessLogic
{
public class EmployeeLogic : IEmployeeLogic
{
private readonly EmployeeManagementDbContext _context;
public EmployeeLogic(EmployeeManagementDbContext context)
{
_context = context;
}
public void CreateOrUpdate(EmployeeBindingModel model)
{
// Проверка на обязательные поля
if (string.IsNullOrWhiteSpace(model.NameJob))
{
throw new ArgumentException("Job name cannot be empty.");
}
// Ищем сотрудника по ID, если он уже существует
var employee = _context.Employees.FirstOrDefault(e => e.Id == model.Id);
if (employee == null)
{
// Создаем нового сотрудника, если не найден
employee = new Employee
{
NameJob = model.NameJob,
StartJob = model.StartJob,
EndJob = model.EndJob,
PartTimeJob = model.PartTimeJob,
Bid = model.Bid,
PhisicalPersonsId = model.PhisicalPersonsId
};
try
{
_context.Employees.Add(employee);
_context.SaveChanges();
}
catch (Exception ex)
{
// Логирование ошибки и обработка
throw new InvalidOperationException("Error while adding new employee: " + ex.Message);
}
}
else
{
// Обновляем данные существующего сотрудника
employee.NameJob = model.NameJob;
employee.StartJob = model.StartJob;
employee.EndJob = model.EndJob;
employee.PartTimeJob = model.PartTimeJob;
employee.Bid = model.Bid;
employee.PhisicalPersonsId = model.PhisicalPersonsId;
try
{
_context.SaveChanges();
}
catch (Exception ex)
{
// Логирование ошибки и обработка
throw new InvalidOperationException("Error while updating employee: " + ex.Message);
}
}
}
public void Delete(int id)
{
var employee = _context.Employees.FirstOrDefault(e => e.Id == id);
if (employee != null)
{
// Дополнительная проверка на связи с другими таблицами, если необходимо
if (employee.Salaries.Any() || employee.Vacations.Any())
{
throw new InvalidOperationException("Employee cannot be deleted because they have related data (e.g., salaries or vacations).");
}
_context.Employees.Remove(employee);
_context.SaveChanges();
}
else
{
throw new KeyNotFoundException($"Employee with ID {id} not found.");
}
}
public EmployeeViewModel? GetEmployeeById(int id)
{
var employee = _context.Employees
.Where(e => e.Id == id)
.Select(e => new EmployeeViewModel
{
Id = e.Id,
NameJob = e.NameJob,
StartJob = e.StartJob,
EndJob = e.EndJob,
PartTimeJob = e.PartTimeJob,
Bid = e.Bid,
PhysicalPersonsId = e.PhisicalPersonsId,
PhysicalPersonName = e.PhisicalPerson != null ? e.PhisicalPerson.Name : null
})
.FirstOrDefault();
return employee;
}
public List<EmployeeViewModel> GetEmployees(EmployeeSearchModel model)
{
var query = _context.Employees.AsQueryable();
if (model.Id.HasValue)
{
query = query.Where(e => e.Id == model.Id.Value);
}
if (!string.IsNullOrWhiteSpace(model.NameJob))
{
query = query.Where(e => e.NameJob.Contains(model.NameJob));
}
if (model.StartDateFrom.HasValue)
{
query = query.Where(e => e.StartJob >= model.StartDateFrom.Value);
}
if (model.StartDateTo.HasValue)
{
query = query.Where(e => e.StartJob <= model.StartDateTo.Value);
}
if (model.Bid.HasValue)
{
query = query.Where(e => e.Bid == model.Bid.Value);
}
return query
.Select(e => new EmployeeViewModel
{
Id = e.Id,
NameJob = e.NameJob,
StartJob = e.StartJob,
EndJob = e.EndJob,
PartTimeJob = e.PartTimeJob,
Bid = e.Bid,
PhysicalPersonsId = e.PhisicalPersonsId,
PhysicalPersonName = e.PhisicalPerson != null ? e.PhisicalPerson.Name : null
})
.ToList();
}
}
}

View File

@ -0,0 +1,123 @@
using EmployeeManagmentContracts.BindingModels;
using EmployeeManagmentContracts.BusinessLogicContracts;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using EmployeeManagmentDataBaseImplement.Models;
using EmployeeManagmentDataBaseImplement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentBusinessLogic.BusinessLogic
{
public class PhisicalPersonLogic : IPhisicalPersonLogic
{
private readonly EmployeeManagementDbContext _context;
public PhisicalPersonLogic(EmployeeManagementDbContext context)
{
_context = context;
}
public void CreateOrUpdate(PhisicalPersonBindingModel model)
{
PhisicalPerson? person = _context.PhysicalPersons
.FirstOrDefault(p => p.Id == model.Id);
if (person == null)
{
// Создание нового
person = new PhisicalPerson
{
Name = model.Name,
Surname = model.Surname,
Patronymic = model.Patronomic,
Birthday = model.Birthday,
Gender = model.Gender,
Address = model.Address,
Telephone = model.Telephone
};
_context.PhysicalPersons.Add(person);
}
else
{
// Обновление существующего
person.Name = model.Name;
person.Surname = model.Surname;
person.Patronymic = model.Patronomic;
person.Birthday = model.Birthday;
person.Gender = model.Gender;
person.Address = model.Address;
person.Telephone = model.Telephone;
}
_context.SaveChanges();
}
public void Delete(int id)
{
var person = _context.PhysicalPersons.FirstOrDefault(p => p.Id == id);
if (person != null)
{
_context.PhysicalPersons.Remove(person);
_context.SaveChanges();
}
}
public PhisicalPersonViewModel? GetPhisicalPersonById(int id)
{
var person = _context.PhysicalPersons
.Where(p => p.Id == id)
.Select(p => new PhisicalPersonViewModel
{
Id = p.Id,
Name = p.Name,
Surname = p.Surname,
Patronomic = p.Patronymic,
Birthday = p.Birthday,
Gender = p.Gender,
Address = p.Address,
Telephone = p.Telephone
})
.FirstOrDefault();
return person;
}
public List<PhisicalPersonViewModel> GetPhisicalPersons(PhisicalPersonSearchModel model)
{
var query = _context.PhysicalPersons.AsQueryable();
if (!string.IsNullOrEmpty(model.Name))
{
query = query.Where(p => p.Name.Contains(model.Name));
}
if (!string.IsNullOrEmpty(model.Surname))
{
query = query.Where(p => p.Surname.Contains(model.Surname));
}
if (!string.IsNullOrEmpty(model.Patronomic))
{
query = query.Where(p => p.Patronymic.Contains(model.Patronomic));
}
return query
.Select(p => new PhisicalPersonViewModel
{
Id = p.Id,
Name = p.Name,
Surname = p.Surname,
Patronomic = p.Patronymic,
Birthday = p.Birthday,
Gender = p.Gender,
Address = p.Address,
Telephone = p.Telephone
})
.ToList();
}
}
}

View File

@ -0,0 +1,31 @@
using EmployeeManagmentContracts.BindingModels;
using EmployeeManagmentContracts.BusinessLogicContracts;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.StoragesContracts;
using EmployeeManagmentContracts.ViewModels;
namespace EmployeeManagmentBusinessLogic.BusinessLogic
{
public class SalaryLogic : ISalaryLogic
{
public void CreateOrUpdate(SalaryBindingModel model)
{
throw new NotImplementedException();
}
public void Delete(int id)
{
throw new NotImplementedException();
}
public List<SalaryViewModel> GetSalaries(SalarySearchModel model)
{
throw new NotImplementedException();
}
public SalaryViewModel? GetSalaryById(int id)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,31 @@
using EmployeeManagmentContracts.BindingModels;
using EmployeeManagmentContracts.BusinessLogicContracts;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.StoragesContracts;
using EmployeeManagmentContracts.ViewModels;
namespace EmployeeManagmentBusinessLogic.BusinessLogic
{
public class VacationLogic : IVacationLogic
{
public void CreateOrUpdate(VacationBindingModel model)
{
throw new NotImplementedException();
}
public void Delete(int id)
{
throw new NotImplementedException();
}
public VacationViewModel? GetVacationById(int id)
{
throw new NotImplementedException();
}
public List<VacationViewModel> GetVacations(VacationSearchModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\EmployeeManagmentContracts\EmployeeManagmentContracts.csproj" />
<ProjectReference Include="..\EmployeeManagmentDataBaseImplement\EmployeeManagmentDataBaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.BindingModels
{
public class EmployeeBindingModel
{
public int? Id { get; set; }
public string NameJob { get; set; } = string.Empty;
public DateTime StartJob { get; set; }
public DateTime? EndJob { get; set; }
public string? PartTimeJob { get; set; }
public float Bid { get; set; }
public int PhisicalPersonsId { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.BindingModels
{
public class PhisicalPersonBindingModel
{
public int? Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string Patronomic { get; set; } = string.Empty;
public DateTime Birthday { get; set; }
public string Gender { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public string Telephone { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.BindingModels
{
public class SalaryBindingModel
{
public int? Id { get; set; }
public int CountHours { get; set; }
public float PriceHour { get; set; }
public float? Premium { get; set; }
public DateTime? Date { get; set; }
public bool Passed { get; set; }
public int EmployeeId { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.BindingModels
{
public class VacationBindingModel
{
public int? Id { get; set; }
public DateTime StartData { get; set; }
public DateTime EndData { get; set; }
public bool Passed { get; set; }
public int EmployeeId { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using EmployeeManagmentContracts.BindingModels;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.BusinessLogicContracts
{
public interface IEmployeeLogic
{
List<EmployeeViewModel> GetEmployees(EmployeeSearchModel model);
EmployeeViewModel? GetEmployeeById(int id);
void CreateOrUpdate(EmployeeBindingModel model);
void Delete(int id);
}
}

View File

@ -0,0 +1,19 @@
using EmployeeManagmentContracts.BindingModels;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.BusinessLogicContracts
{
public interface IPhisicalPersonLogic
{
List<PhisicalPersonViewModel> GetPhisicalPersons(PhisicalPersonSearchModel model);
PhisicalPersonViewModel? GetPhisicalPersonById(int id);
void CreateOrUpdate(PhisicalPersonBindingModel model);
void Delete(int id);
}
}

View File

@ -0,0 +1,20 @@
using EmployeeManagmentContracts.BindingModels;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.BusinessLogicContracts
{
public interface ISalaryLogic
{
List<SalaryViewModel> GetSalaries(SalarySearchModel model);
SalaryViewModel? GetSalaryById(int id);
void CreateOrUpdate(SalaryBindingModel model);
void Delete(int id);
}
}

View File

@ -0,0 +1,19 @@
using EmployeeManagmentContracts.BindingModels;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.BusinessLogicContracts
{
public interface IVacationLogic
{
List<VacationViewModel> GetVacations(VacationSearchModel model);
VacationViewModel? GetVacationById(int id);
void CreateOrUpdate(VacationBindingModel model);
void Delete(int id);
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\EmployeeManagmentDataModels\EmployeeManagmentDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.SearchModels
{
public class EmployeeSearchModel
{
public int? Id { get; set; }
public string? NameJob { get; set; }
public DateTime? StartDateFrom { get; set; }
public DateTime? StartDateTo { get; set; }
public float? Bid { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.SearchModels
{
public class PhisicalPersonSearchModel
{
public string? Name { get; set; }
public string? Surname { get; set; }
public string? Patronomic { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.SearchModels
{
public class SalarySearchModel
{
public DateTime? Date { get; set; }
public bool? Passed { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.SearchModels
{
public class VacationSearchModel
{
public int? Id { get; set; }
public int? EmployeeId { get; set; }
public DateTime? StartData { get; set; }
public DateTime? EndData { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.StoragesContracts
{
public interface IEmployeeStorage
{
List<EmployeeViewModel> GetFullList();
List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model);
EmployeeViewModel? GetElement(int id);
void Insert(EmployeeViewModel model);
void Update(EmployeeViewModel model);
void Delete(int id);
}
}

View File

@ -0,0 +1,20 @@
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.StoragesContracts
{
public interface IPhisicalPersonStorage
{
List<PhisicalPersonViewModel> GetFullList();
List<PhisicalPersonViewModel> GetFilteredList(PhisicalPersonSearchModel model);
PhisicalPersonViewModel? GetElement(int id);
void Insert(PhisicalPersonViewModel model);
void Update(PhisicalPersonViewModel model);
void Delete(int id);
}
}

View File

@ -0,0 +1,20 @@
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.StoragesContracts
{
public interface ISalaryStorage
{
List<SalaryViewModel> GetFullList();
List<SalaryViewModel> GetFilteredList(SalarySearchModel model);
SalaryViewModel? GetElement(int id);
void Insert(SalaryViewModel model);
void Update(SalaryViewModel model);
void Delete(int id);
}
}

View File

@ -0,0 +1,20 @@
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.StoragesContracts
{
public interface IVacationStorage
{
List<VacationViewModel> GetFullList();
List<VacationViewModel> GetFilteredList(VacationSearchModel model);
VacationViewModel? GetElement(int id);
void Insert(VacationViewModel model);
void Update(VacationViewModel model);
void Delete(int id);
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.ViewModels
{
public class EmployeeViewModel
{
public int Id { get; set; }
public string NameJob { get; set; } = string.Empty;
public DateTime? StartJob { get; set; }
public DateTime? EndJob { get; set; }
public string? PartTimeJob { get; set; }
public float Bid { get; set; }
public int PhysicalPersonsId { get; set; }
public string? PhysicalPersonName { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.ViewModels
{
public class PhisicalPersonViewModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Surname { get; set; } = string.Empty;
public string Patronomic { get; set; } = string.Empty;
public DateTime Birthday { get; set; }
public string Gender { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public string Telephone { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.ViewModels
{
public class SalaryViewModel
{
public int Id { get; set; }
public int CountHours { get; set; }
public float PriceHour { get; set; }
public float? Premium { get; set; }
public DateTime? Date { get; set; }
public bool Passed { get; set; }
public string EmployeeName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentContracts.ViewModels
{
public class VacationViewModel
{
public int Id { get; set; }
public DateTime StartData { get; set; }
public DateTime EndData { get; set; }
public bool Passed { get; set; }
public string EmployeeName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,24 @@
using EmployeeManagmentDataBaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace EmployeeManagmentDataBaseImplement
{
public class EmployeeManagementDbContext : DbContext
{
// DbSets для моделей
public virtual DbSet<Employee> Employees { get; set; }
public virtual DbSet<PhisicalPerson> PhysicalPersons { get; set; }
public virtual DbSet<Salary> Salaries { get; set; }
public virtual DbSet<Vacation> Vacations { get; set; }
// Метод для настройки конфигурации
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseMySQL("Server=localhost;Port=3306;Database=EmployeeDB;User=root;Password=SuperSecretPasswork2003;");
}
base.OnConfiguring(optionsBuilder);
}
}
}

View File

@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Include="MySql.EntityFrameworkCore" Version="8.0.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EmployeeManagmentContracts\EmployeeManagmentContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,40 @@
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.StoragesContracts;
using EmployeeManagmentContracts.ViewModels;
using EmployeeManagmentDataBaseImplement.Models;
namespace EmployeeManagmentDataBaseImplement.Implements
{
public class EmployeeStorage : IEmployeeStorage
{
public void Delete(int id)
{
throw new NotImplementedException();
}
public EmployeeViewModel? GetElement(int id)
{
throw new NotImplementedException();
}
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
{
throw new NotImplementedException();
}
public List<EmployeeViewModel> GetFullList()
{
throw new NotImplementedException();
}
public void Insert(EmployeeViewModel model)
{
throw new NotImplementedException();
}
public void Update(EmployeeViewModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,45 @@

using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.StoragesContracts;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataBaseImplement.Implements
{
public class PhisicalPersonStorage : IPhisicalPersonStorage
{
public void Delete(int id)
{
throw new NotImplementedException();
}
public PhisicalPersonViewModel? GetElement(int id)
{
throw new NotImplementedException();
}
public List<PhisicalPersonViewModel> GetFilteredList(PhisicalPersonSearchModel model)
{
throw new NotImplementedException();
}
public List<PhisicalPersonViewModel> GetFullList()
{
throw new NotImplementedException();
}
public void Insert(PhisicalPersonViewModel model)
{
throw new NotImplementedException();
}
public void Update(PhisicalPersonViewModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,44 @@
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.StoragesContracts;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataBaseImplement.Implements
{
public class SalaryStorage : ISalaryStorage
{
public void Delete(int id)
{
throw new NotImplementedException();
}
public SalaryViewModel? GetElement(int id)
{
throw new NotImplementedException();
}
public List<SalaryViewModel> GetFilteredList(SalarySearchModel model)
{
throw new NotImplementedException();
}
public List<SalaryViewModel> GetFullList()
{
throw new NotImplementedException();
}
public void Insert(SalaryViewModel model)
{
throw new NotImplementedException();
}
public void Update(SalaryViewModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,44 @@
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.StoragesContracts;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataBaseImplement.Implements
{
public class VacationStorage : ISalaryStorage
{
public void Delete(int id)
{
throw new NotImplementedException();
}
public SalaryViewModel? GetElement(int id)
{
throw new NotImplementedException();
}
public List<SalaryViewModel> GetFilteredList(SalarySearchModel model)
{
throw new NotImplementedException();
}
public List<SalaryViewModel> GetFullList()
{
throw new NotImplementedException();
}
public void Insert(SalaryViewModel model)
{
throw new NotImplementedException();
}
public void Update(SalaryViewModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,197 @@
// <auto-generated />
using System;
using EmployeeManagmentDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EmployeeManagmentDataBaseImplement.Migrations
{
[DbContext(typeof(EmployeeManagementDbContext))]
[Migration("20241113084724_InitialMigration")]
partial class InitialMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<float>("Bid")
.HasColumnType("float");
b.Property<DateTime?>("EndJob")
.HasColumnType("datetime(6)");
b.Property<string>("NameJob")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("PartTimeJob")
.HasColumnType("longtext");
b.Property<int>("PhisicalPersonsId")
.HasColumnType("int");
b.Property<DateTime?>("StartJob")
.HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("PhisicalPersonsId");
b.ToTable("Employees");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.PhisicalPerson", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("Birthday")
.HasColumnType("datetime(6)");
b.Property<string>("Gender")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Patronymic")
.HasColumnType("longtext");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Telephone")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("PhysicalPersons");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Salary", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("CountHours")
.HasColumnType("int");
b.Property<DateTime?>("Data")
.HasColumnType("datetime(6)");
b.Property<int>("EmployeesId")
.HasColumnType("int");
b.Property<bool>("Passed")
.HasColumnType("tinyint(1)");
b.Property<float?>("Premium")
.HasColumnType("float");
b.Property<float>("PriceHour")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("EmployeesId");
b.ToTable("Salaries");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Vacation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("EmployeesId")
.HasColumnType("int");
b.Property<DateTime>("EndData")
.HasColumnType("datetime(6)");
b.Property<bool>("Passed")
.HasColumnType("tinyint(1)");
b.Property<DateTime>("StartData")
.HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("EmployeesId");
b.ToTable("Vacations");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Employee", b =>
{
b.HasOne("EmployeeManagmentDataBaseImplement.Models.PhisicalPerson", "PhisicalPerson")
.WithMany("Employees")
.HasForeignKey("PhisicalPersonsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PhisicalPerson");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Salary", b =>
{
b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee")
.WithMany("Salaries")
.HasForeignKey("EmployeesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Vacation", b =>
{
b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee")
.WithMany("Vacations")
.HasForeignKey("EmployeesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Employee", b =>
{
b.Navigation("Salaries");
b.Navigation("Vacations");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.PhisicalPerson", b =>
{
b.Navigation("Employees");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,143 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using MySql.EntityFrameworkCore.Metadata;
#nullable disable
namespace EmployeeManagmentDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "PhysicalPersons",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "longtext", nullable: false),
Surname = table.Column<string>(type: "longtext", nullable: false),
Patronymic = table.Column<string>(type: "longtext", nullable: true),
Birthday = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Gender = table.Column<string>(type: "longtext", nullable: false),
Address = table.Column<string>(type: "longtext", nullable: false),
Telephone = table.Column<string>(type: "longtext", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PhysicalPersons", x => x.Id);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
NameJob = table.Column<string>(type: "longtext", nullable: false),
StartJob = table.Column<DateTime>(type: "datetime(6)", nullable: true),
EndJob = table.Column<DateTime>(type: "datetime(6)", nullable: true),
PartTimeJob = table.Column<string>(type: "longtext", nullable: true),
Bid = table.Column<float>(type: "float", nullable: false),
PhisicalPersonsId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Employees", x => x.Id);
table.ForeignKey(
name: "FK_Employees_PhysicalPersons_PhisicalPersonsId",
column: x => x.PhisicalPersonsId,
principalTable: "PhysicalPersons",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "Salaries",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
CountHours = table.Column<int>(type: "int", nullable: false),
PriceHour = table.Column<float>(type: "float", nullable: false),
Premium = table.Column<float>(type: "float", nullable: true),
Data = table.Column<DateTime>(type: "datetime(6)", nullable: true),
Passed = table.Column<bool>(type: "tinyint(1)", nullable: false),
EmployeesId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Salaries", x => x.Id);
table.ForeignKey(
name: "FK_Salaries_Employees_EmployeesId",
column: x => x.EmployeesId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "Vacations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
StartData = table.Column<DateTime>(type: "datetime(6)", nullable: false),
EndData = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Passed = table.Column<bool>(type: "tinyint(1)", nullable: false),
EmployeesId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Vacations", x => x.Id);
table.ForeignKey(
name: "FK_Vacations_Employees_EmployeesId",
column: x => x.EmployeesId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_Employees_PhisicalPersonsId",
table: "Employees",
column: "PhisicalPersonsId");
migrationBuilder.CreateIndex(
name: "IX_Salaries_EmployeesId",
table: "Salaries",
column: "EmployeesId");
migrationBuilder.CreateIndex(
name: "IX_Vacations_EmployeesId",
table: "Vacations",
column: "EmployeesId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Salaries");
migrationBuilder.DropTable(
name: "Vacations");
migrationBuilder.DropTable(
name: "Employees");
migrationBuilder.DropTable(
name: "PhysicalPersons");
}
}
}

View File

@ -0,0 +1,194 @@
// <auto-generated />
using System;
using EmployeeManagmentDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EmployeeManagmentDataBaseImplement.Migrations
{
[DbContext(typeof(EmployeeManagementDbContext))]
partial class EmployeeManagementDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<float>("Bid")
.HasColumnType("float");
b.Property<DateTime?>("EndJob")
.HasColumnType("datetime(6)");
b.Property<string>("NameJob")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("PartTimeJob")
.HasColumnType("longtext");
b.Property<int>("PhisicalPersonsId")
.HasColumnType("int");
b.Property<DateTime?>("StartJob")
.HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("PhisicalPersonsId");
b.ToTable("Employees");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.PhisicalPerson", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("longtext");
b.Property<DateTime>("Birthday")
.HasColumnType("datetime(6)");
b.Property<string>("Gender")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Patronymic")
.HasColumnType("longtext");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Telephone")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("PhysicalPersons");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Salary", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("CountHours")
.HasColumnType("int");
b.Property<DateTime?>("Data")
.HasColumnType("datetime(6)");
b.Property<int>("EmployeesId")
.HasColumnType("int");
b.Property<bool>("Passed")
.HasColumnType("tinyint(1)");
b.Property<float?>("Premium")
.HasColumnType("float");
b.Property<float>("PriceHour")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("EmployeesId");
b.ToTable("Salaries");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Vacation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("EmployeesId")
.HasColumnType("int");
b.Property<DateTime>("EndData")
.HasColumnType("datetime(6)");
b.Property<bool>("Passed")
.HasColumnType("tinyint(1)");
b.Property<DateTime>("StartData")
.HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("EmployeesId");
b.ToTable("Vacations");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Employee", b =>
{
b.HasOne("EmployeeManagmentDataBaseImplement.Models.PhisicalPerson", "PhisicalPerson")
.WithMany("Employees")
.HasForeignKey("PhisicalPersonsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PhisicalPerson");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Salary", b =>
{
b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee")
.WithMany("Salaries")
.HasForeignKey("EmployeesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Vacation", b =>
{
b.HasOne("EmployeeManagmentDataBaseImplement.Models.Employee", "Employee")
.WithMany("Vacations")
.HasForeignKey("EmployeesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.Employee", b =>
{
b.Navigation("Salaries");
b.Navigation("Vacations");
});
modelBuilder.Entity("EmployeeManagmentDataBaseImplement.Models.PhisicalPerson", b =>
{
b.Navigation("Employees");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,29 @@
using EmployeeManagmentDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EmployeeManagmentDataBaseImplement.Models
{
public class Employee : IEmployee
{
[Key]
public int Id { get; set; }
[Required]
public string NameJob { get; set; } = string.Empty;
public DateTime? StartJob { get; set; }
public DateTime? EndJob { get; set; }
public string? PartTimeJob { get; set; }
public float Bid { get; set; }
[ForeignKey("PhisicalPerson")]
public int PhisicalPersonsId { get; set; }
public PhisicalPerson? PhisicalPerson { get; set; }
public List<Salary> Salaries { get; set; } = new();
public List<Vacation> Vacations { get; set; } = new();
}
}

View File

@ -0,0 +1,34 @@
using EmployeeManagmentDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataBaseImplement.Models
{
public class PhisicalPerson : IPhisicalPerson
{
[Key]
public int Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public string Surname { get; set; } = string.Empty;
public string? Patronymic { get; set; }
[Required]
public DateTime Birthday { get; set; }
[Required]
public string Gender { get; set; } = string.Empty;
[Required]
public string Address { get; set; } = string.Empty;
[Required]
public string Telephone { get; set; } = string.Empty;
public List<Employee> Employees { get; set; } = new();
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EmployeeManagmentDataModels.Models;
namespace EmployeeManagmentDataBaseImplement.Models
{
public class Salary : ISalary
{
[Key]
public int Id { get; set; }
public int CountHours { get; set; }
public float PriceHour { get; set; }
public float? Premium { get; set; }
public DateTime? Data { get; set; }
public bool Passed { get; set; }
[ForeignKey("Employee")]
public int EmployeesId { get; set; }
public Employee? Employee { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EmployeeManagmentDataModels.Models;
namespace EmployeeManagmentDataBaseImplement.Models
{
public class Vacation : IVacation
{
[Key]
public int Id { get; set; }
public DateTime StartData { get; set; }
public DateTime EndData { get; set; }
public bool Passed { get; set; }
[ForeignKey("Employee")]
public int EmployeesId { get; set; }
public Employee? Employee { get; set; }
}
}

View File

@ -0,0 +1,5 @@
{
"ConnectionStrings": {
"SqlServerConnection": "Server=localhost,1433;Database=EmployeeManagementDB;User Id=sa;Password=YourStrong@Password123;"
}
}

View File

@ -20,4 +20,4 @@ volumes:
networks:
employee_network:
driver: bridge
driver: bridge

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataModels.Enums
{
public enum JobType
{
FullTime, // Полная занятость
PartTime, // Неполная занятость
Internship // Стажировка
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataModels.Enums
{
public enum VacationStatus
{
Planned, // Запланированный отпуск
Approved, // Одобренный отпуск
Taken // Отпуск использован
}
}

View File

@ -0,0 +1,20 @@
using EmployeeManagmentDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataModels.Models
{
public interface IEmployee
{
int Id { get; set; }
string NameJob { get; set; }
DateTime? StartJob { get; set; }
DateTime? EndJob { get; set; }
string? PartTimeJob { get; set; }
float Bid { get; set; }
int PhisicalPersonsId { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataModels.Models
{
public interface IPhisicalPerson
{
int Id { get; set; }
string Name { get; set; }
string Surname { get; set; }
string? Patronymic { get; set; }
DateTime Birthday { get; set; }
string Gender { get; set; }
string Address { get; set; }
string Telephone { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataModels.Models
{
public interface ISalary
{
int Id { get; set; }
int CountHours { get; set; }
float PriceHour { get; set; }
float? Premium { get; set; }
DateTime? Data { get; set; }
bool Passed { get; set; }
int EmployeesId { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using EmployeeManagmentDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataModels.Models
{
public interface IVacation
{
int Id { get; set; }
DateTime StartData { get; set; }
DateTime EndData { get; set; }
bool Passed { get; set; }
int EmployeesId { get; set; }
}
}

View File

@ -1,8 +1,9 @@
<Application x:Class="EmployeeManagementApp.App"
<Application x:Class="EmployeeManagmentView.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EmployeeManagementApp">
xmlns:local="clr-namespace:EmployeeManagmentView"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@ -0,0 +1,47 @@
using EmployeeManagmentDataBaseImplement;
using EmployeeManagmentBusinessLogic.BusinessLogic;
using EmployeeManagmentContracts.BusinessLogicContracts;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using System;
using System.Windows;
namespace EmployeeManagmentView
{
public partial class App : Application
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
protected override void OnStartup(StartupEventArgs e)
{
var serviceCollection = new ServiceCollection();
ConfigureServices(serviceCollection);
_serviceProvider = serviceCollection.BuildServiceProvider();
try
{
var mainWindow = _serviceProvider.GetRequiredService<MainWindow>();
mainWindow.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при открытии MainWindow", MessageBoxButton.OK, MessageBoxImage.Error);
}
base.OnStartup(e);
}
private static void ConfigureServices(ServiceCollection services)
{
// Регистрация контекста базы данных с использованием конфигурации
services.AddLogging(configure => configure.AddConsole());
// Регистрация бизнес-логики и других сервисов
services.AddTransient<IPhisicalPersonLogic, PhisicalPersonLogic>();
services.AddTransient<IEmployeeLogic, EmployeeLogic>();
// Регистрация окон
services.AddTransient<MainWindow>();
}
}
}

View File

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.6.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EmployeeManagmentBusinessLogic\EmployeeManagmentBusinessLogic.csproj" />
<ProjectReference Include="..\EmployeeManagmentContracts\EmployeeManagmentContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
<Window x:Class="EmployeeManagmentView.EmployeesWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Employees" Height="450" Width="800">
<Grid>
<TextBlock Text="Список сотрудников" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Window>

View File

@ -0,0 +1,29 @@
using EmployeeManagmentBusinessLogic.BusinessLogic;
using EmployeeManagmentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace EmployeeManagmentView
{
/// <summary>
/// Логика взаимодействия для EmployeesWindow.xaml
/// </summary>
public partial class EmployeesWindow : Window
{
public EmployeesWindow()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,37 @@
<Window x:Class="EmployeeManagmentView.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Employee Management System"
Height="450" Width="800">
<Grid>
<StackPanel>
<TextBlock Text="Система управления сотрудниками"
FontSize="24"
FontWeight="Bold"
Margin="10"/>
<Button Content="Просмотр физических лиц"
Width="200"
Height="40"
Margin="10"
Click="ViewPhisicalPerson_Click"/>
<Button Content="Просмотр сотрудников"
Width="200"
Height="40"
Margin="10"
Click="ViewEmployees_Click"/>
<Button Content="Управление зарплатами"
Width="200"
Height="40"
Margin="10"
Click="ManageSalaries_Click"/>
<Button Content="Управление отпусками"
Width="200"
Height="40"
Margin="10"
Click="ManageVacations_Click"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,49 @@
using EmployeeManagmentBusinessLogic.BusinessLogic;
using EmployeeManagmentContracts.BusinessLogicContracts;
using EmployeeManagmentContracts.ViewModels;
using System.Windows;
namespace EmployeeManagmentView
{
public partial class MainWindow : Window
{
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
private readonly IEmployeeLogic _employeeLogic;
// Constructor with Dependency Injection
public MainWindow(IPhisicalPersonLogic phisicalPersonLogic, IEmployeeLogic employeeLogic)
{
_phisicalPersonLogic = phisicalPersonLogic;
_employeeLogic = employeeLogic;
InitializeComponent();
}
private void ViewEmployees_Click(object sender, RoutedEventArgs e)
{
// Логика для открытия окна просмотра сотрудников
var employeesWindow = new EmployeesWindow();
employeesWindow.Show();
}
private void ViewPhisicalPerson_Click(object sender, RoutedEventArgs e)
{
// Передаем логику в конструктор окна
var phisicalPersonWindow = new PhisicalPersonWindow(_phisicalPersonLogic);
phisicalPersonWindow.Show();
}
private void ManageSalaries_Click(object sender, RoutedEventArgs e)
{
// Логика для открытия окна управления зарплатами
var salariesWindow = new SalariesWindow();
salariesWindow.Show();
}
private void ManageVacations_Click(object sender, RoutedEventArgs e)
{
// Логика для открытия окна управления отпусками
var vacationsWindow = new VacationsWindow();
vacationsWindow.Show();
}
}
}

View File

@ -0,0 +1,30 @@
<Window x:Class="EmployeeManagmentView.PhisicalPersonWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:EmployeeManagmentView"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="Physical Person Management" Height="450" Width="800">
<Grid>
<StackPanel>
<!-- TextBoxes with Watermark for all fields -->
<xctk:WatermarkTextBox Name="NameTextBox" Width="200" Margin="10" Watermark="Enter Name"/>
<xctk:WatermarkTextBox Name="SurnameTextBox" Width="200" Margin="10" Watermark="Enter Surname"/>
<xctk:WatermarkTextBox Name="AgeTextBox" Width="200" Margin="10" Watermark="Enter Age"/>
<xctk:WatermarkTextBox Name="AddressTextBox" Width="200" Margin="10" Watermark="Enter Address"/>
<xctk:WatermarkTextBox Name="TelephoneTextBox" Width="200" Margin="10" Watermark="Enter Telephone"/>
<xctk:WatermarkTextBox Name="GenderTextBox" Width="200" Margin="10" Watermark="Enter Gender"/>
<xctk:WatermarkTextBox Name="BirthdayTextBox" Width="200" Margin="10" Watermark="Enter Birthday (YYYY-MM-DD)"/>
<!-- Buttons for CRUD actions -->
<Button Content="Add" Width="100" Margin="10" Click="AddButton_Click"/>
<Button Content="Update" Width="100" Margin="10" Click="UpdateButton_Click"/>
<Button Content="Delete" Width="100" Margin="10" Click="DeleteButton_Click"/>
<!-- DataGrid to display PhysicalPersons -->
<DataGrid Name="PhysicalPersonsDataGrid" Margin="10" AutoGenerateColumns="True"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,149 @@
using EmployeeManagmentContracts.BindingModels;
using EmployeeManagmentContracts.BusinessLogicContracts;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace EmployeeManagmentView
{
/// <summary>
/// Логика взаимодействия для PhisicalPersonWindow.xaml
/// </summary>
public partial class PhisicalPersonWindow : Window
{
private readonly IPhisicalPersonLogic _phisicalPersonLogic;
public PhisicalPersonWindow(IPhisicalPersonLogic phisicalPersonLogic)
{
InitializeComponent();
_phisicalPersonLogic = phisicalPersonLogic;
LoadData();
}
// Загрузка данных в DataGrid
private void LoadData()
{
try
{
var physicalPersons = _phisicalPersonLogic.GetPhisicalPersons(null); // Здесь можно передавать параметры для фильтрации
PhysicalPersonsDataGrid.ItemsSource = physicalPersons;
}
catch (Exception ex)
{
MessageBox.Show($"Error loading data: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
var textBox = sender as TextBox;
if (textBox != null && textBox.Text == "Enter Name")
{
textBox.Text = "";
textBox.Foreground = new SolidColorBrush(Colors.Black); // Change text color to black
}
}
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
{
var textBox = sender as TextBox;
if (textBox != null && string.IsNullOrEmpty(textBox.Text))
{
textBox.Text = "Enter Name"; // Reset placeholder text
textBox.Foreground = new SolidColorBrush(Colors.Gray); // Change text color to gray
}
}
// Обработчик для кнопки "Add"
private void AddButton_Click(object sender, RoutedEventArgs e)
{
var model = new PhisicalPersonBindingModel
{
Name = NameTextBox.Text,
Surname = SurnameTextBox.Text,
Birthday = DateTime.TryParse(BirthdayTextBox.Text, out DateTime birthday) ? birthday : DateTime.Now,
Address = AddressTextBox.Text,
Telephone = TelephoneTextBox.Text,
Gender = GenderTextBox.Text
};
try
{
_phisicalPersonLogic.CreateOrUpdate(model);
MessageBox.Show("Physical person added successfully!");
LoadData();
}
catch (Exception ex)
{
MessageBox.Show($"Error adding data: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
// Обработчик для кнопки "Update"
private void UpdateButton_Click(object sender, RoutedEventArgs e)
{
// Получаем выбранную запись в DataGrid
var selectedPerson = PhysicalPersonsDataGrid.SelectedItem as PhisicalPersonViewModel;
if (selectedPerson == null)
{
MessageBox.Show("No person selected.");
return;
}
var model = new PhisicalPersonBindingModel
{
Id = selectedPerson.Id,
Name = NameTextBox.Text,
Surname = SurnameTextBox.Text,
Birthday = DateTime.TryParse(BirthdayTextBox.Text, out DateTime birthday) ? birthday : DateTime.Now,
Address = AddressTextBox.Text,
Telephone = TelephoneTextBox.Text,
Gender = GenderTextBox.Text
};
try
{
_phisicalPersonLogic.CreateOrUpdate(model);
MessageBox.Show("Physical person updated successfully!");
LoadData();
}
catch (Exception ex)
{
MessageBox.Show($"Error updating data: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
// Обработчик для кнопки "Delete"
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
var selectedPerson = PhysicalPersonsDataGrid.SelectedItem as PhisicalPersonViewModel;
if (selectedPerson == null)
{
MessageBox.Show("No person selected.");
return;
}
try
{
_phisicalPersonLogic.Delete(selectedPerson.Id);
MessageBox.Show("Physical person deleted successfully!");
LoadData();
}
catch (Exception ex)
{
MessageBox.Show($"Error deleting data: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}

View File

@ -0,0 +1,8 @@
<Window x:Class="EmployeeManagmentView.SalariesWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Salaries" Height="450" Width="800">
<Grid>
<TextBlock Text="Управление зарплатами" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Window>

View File

@ -12,14 +12,14 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace EmployeeManagementApp.Views
namespace EmployeeManagmentView
{
/// <summary>
/// Логика взаимодействия для MainView.xaml
/// Логика взаимодействия для SalariesWindow.xaml
/// </summary>
public partial class MainView : Window
public partial class SalariesWindow : Window
{
public MainView()
public SalariesWindow()
{
InitializeComponent();
}

View File

@ -0,0 +1,8 @@
<Window x:Class="EmployeeManagmentView.VacationsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Vacations" Height="450" Width="800">
<Grid>
<TextBlock Text="Управление отпусками" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace EmployeeManagmentView
{
/// <summary>
/// Логика взаимодействия для VacationsWindow.xaml
/// </summary>
public partial class VacationsWindow : Window
{
public VacationsWindow()
{
InitializeComponent();
}
}
}

View File

@ -1,55 +0,0 @@
// <auto-generated />
using EmployeeManagementApp.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EmployeeManagementApp.Migrations
{
[DbContext(typeof(EmployeeContext))]
[Migration("20241111130759_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("EmployeeManagementApp.Models.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Position")
.IsRequired()
.HasColumnType("longtext");
b.Property<decimal>("Salary")
.HasColumnType("decimal(18,2)");
b.Property<int>("VacationDays")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Employees");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,43 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
using MySql.EntityFrameworkCore.Metadata;
#nullable disable
namespace EmployeeManagementApp.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
FirstName = table.Column<string>(type: "longtext", nullable: false),
LastName = table.Column<string>(type: "longtext", nullable: false),
Position = table.Column<string>(type: "longtext", nullable: false),
Salary = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
VacationDays = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Employees", x => x.Id);
})
.Annotation("MySQL:Charset", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Employees");
}
}
}

View File

@ -1,52 +0,0 @@
// <auto-generated />
using EmployeeManagementApp.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EmployeeManagementApp.Migrations
{
[DbContext(typeof(EmployeeContext))]
partial class EmployeeContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("EmployeeManagementApp.Models.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Position")
.IsRequired()
.HasColumnType("longtext");
b.Property<decimal>("Salary")
.HasColumnType("decimal(18,2)");
b.Property<int>("VacationDays")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Employees");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagementApp.Models
{
public class Employee
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Position { get; set; }
public decimal Salary { get; set; }
public int VacationDays { get; set; }
}
}

View File

@ -1 +1 @@
# EmployeeManagementApp
# EmployeeManagmentApp

View File

@ -1,16 +0,0 @@
using Microsoft.EntityFrameworkCore;
using EmployeeManagementApp.Models;
namespace EmployeeManagementApp.Services
{
public class EmployeeContext : DbContext
{
public DbSet<Employee> Employees { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// Используем MySQL вместо PostgreSQL
optionsBuilder.UseMySQL("Server=localhost;Port=3306;Database=EmployeeDB;User=root;Password=SuperSecretPasswork2003;");
}
}
}

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagementApp.ViewModels
{
public class BaseViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@ -1,25 +0,0 @@
using EmployeeManagementApp.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagementApp.ViewModels
{
public class MainViewModel : BaseViewModel
{
public ObservableCollection<Employee> Employees { get; set; }
public MainViewModel()
{
// Инициализация данных
Employees = new ObservableCollection<Employee>
{
new Employee { Id = 1, FirstName = "Иван", LastName = "Иванов", Position = "Менеджер", Salary = 50000, VacationDays = 14 },
new Employee { Id = 2, FirstName = "Мария", LastName = "Петрова", Position = "Разработчик", Salary = 70000, VacationDays = 20 }
};
}
}
}

View File

@ -1,22 +0,0 @@
<Window x:Class="EmployeeManagementApp.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:EmployeeManagementApp.ViewModels"
Title="Управление Сотрудниками" Height="400" Width="600">
<Window.DataContext>
<vm:MainViewModel />
</Window.DataContext>
<Grid>
<DataGrid ItemsSource="{Binding Employees}" AutoGenerateColumns="False" Margin="10">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="50" />
<DataGridTextColumn Header="Имя" Binding="{Binding FirstName}" Width="150" />
<DataGridTextColumn Header="Фамилия" Binding="{Binding LastName}" Width="150" />
<DataGridTextColumn Header="Должность" Binding="{Binding Position}" Width="150" />
<DataGridTextColumn Header="Зарплата" Binding="{Binding Salary}" Width="100" />
<DataGridTextColumn Header="Дни отпуска" Binding="{Binding VacationDays}" Width="100" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>