Добавлены все файлы.

В некоторых файлах, основанных на интерфейсах, стоят заглушки.
Создана несколько экранов, которые также являются заглушками.
This commit is contained in:
maksim 2024-11-12 22:10:44 +04:00
parent ab2c31aa99
commit 1ddd362ab7
29 changed files with 456 additions and 291 deletions

View File

@ -8,81 +8,24 @@ namespace EmployeeManagmentBusinessLogic.BusinessLogic
{
public class EmployeeLogic : IEmployeeLogic
{
private readonly IEmployeeStorage _employeeStorage;
public EmployeeLogic(IEmployeeStorage employeeStorage)
{
_employeeStorage = employeeStorage;
}
public List<EmployeeViewModel> GetEmployees(EmployeeSearchModel model)
{
var employees = model == null ? _employeeStorage.GetFullList() : _employeeStorage.GetFilteredList(model);
return employees.Select(e => new EmployeeViewModel
{
Id = e.Id,
NameJob = e.NameJob,
StartJob = e.StartJob,
EndJob = e.EndJob,
PartTimeJob = e.PartTimeJob,
Bid = e.Bid,
PhysicalPersonName = e.PhysicalPerson.Name
}).ToList();
}
public EmployeeViewModel? GetEmployeeById(int id)
{
var employee = _employeeStorage.GetElement(id);
return employee != null ? new EmployeeViewModel
{
Id = employee.Id,
NameJob = employee.NameJob,
StartJob = employee.StartJob,
EndJob = employee.EndJob,
PartTimeJob = employee.PartTimeJob,
Bid = employee.Bid,
PhysicalPersonName = employee.PhysicalPerson.Name
} : null;
}
public void CreateOrUpdate(EmployeeBindingModel model)
{
if (model.Id.HasValue)
{
var existingEmployee = _employeeStorage.GetElement(model.Id.Value);
if (existingEmployee == null)
throw new Exception("Сотрудник не найден");
existingEmployee.NameJob = model.NameJob;
existingEmployee.StartJob = model.StartJob;
existingEmployee.EndJob = model.EndJob;
existingEmployee.PartTimeJob = model.PartTimeJob;
existingEmployee.Bid = model.Bid;
existingEmployee.PhysicalPersonId = model.PhysicalPersonId;
_employeeStorage.Update(existingEmployee);
}
else
{
var newEmployee = new Employee
{
NameJob = model.NameJob,
StartJob = model.StartJob,
EndJob = model.EndJob,
PartTimeJob = model.PartTimeJob,
Bid = model.Bid,
PhysicalPersonId = model.PhysicalPersonId
};
_employeeStorage.Insert(newEmployee);
}
throw new NotImplementedException();
}
public void Delete(int id)
{
var employee = _employeeStorage.GetElement(id);
if (employee == null)
throw new Exception("Сотрудник не найден");
_employeeStorage.Delete(id);
throw new NotImplementedException();
}
public EmployeeViewModel? GetEmployeeById(int id)
{
throw new NotImplementedException();
}
public List<EmployeeViewModel> GetEmployees(EmployeeSearchModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,35 @@
using EmployeeManagmentContracts.BindingModels;
using EmployeeManagmentContracts.BusinessLogicContracts;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentBusinessLogic.BusinessLogic
{
public class PhisicalPersonLogic : IPhisicalPersonLogic
{
public void CreateOrUpdate(PhisicalPersonBindingModel model)
{
throw new NotImplementedException();
}
public void Delete(int id)
{
throw new NotImplementedException();
}
public PhisicalPersonViewModel? GetPhisicalPersonById(int id)
{
throw new NotImplementedException();
}
public List<PhisicalPersonViewModel> GetPhisicalPersons(PhisicalPersonSearchModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -8,66 +8,24 @@ namespace EmployeeManagmentBusinessLogic.BusinessLogic
{
public class SalaryLogic : ISalaryLogic
{
private readonly ISalaryStorage _salaryStorage;
public SalaryLogic(ISalaryStorage salaryStorage)
{
_salaryStorage = salaryStorage;
}
public List<SalaryViewModel> GetSalaries(SalarySearchModel model)
{
var salaries = model == null ? _salaryStorage.GetFullList() : _salaryStorage.GetFilteredList(model);
return salaries.Select(s => new SalaryViewModel
{
Id = s.Id,
CountHours = s.CountHours,
PriceHour = s.PriceHour,
Premium = s.Premium,
Date = s.Date,
Passed = s.Passed,
EmployeeName = s.Employee.NameJob
}).ToList();
}
public void CreateOrUpdate(SalaryBindingModel model)
{
if (model.Id.HasValue)
{
var existingSalary = _salaryStorage.GetElement(model.Id.Value);
if (existingSalary == null)
throw new Exception("Зарплата не найдена");
existingSalary.CountHours = model.CountHours;
existingSalary.PriceHour = model.PriceHour;
existingSalary.Premium = model.Premium;
existingSalary.Date = model.Date;
existingSalary.Passed = model.Passed;
existingSalary.EmployeeId = model.EmployeeId;
_salaryStorage.Update(existingSalary);
}
else
{
var newSalary = new Salary
{
CountHours = model.CountHours,
PriceHour = model.PriceHour,
Premium = model.Premium,
Date = model.Date,
Passed = model.Passed,
EmployeeId = model.EmployeeId
};
_salaryStorage.Insert(newSalary);
}
throw new NotImplementedException();
}
public void Delete(int id)
{
var salary = _salaryStorage.GetElement(id);
if (salary == null)
throw new Exception("Зарплата не найдена");
_salaryStorage.Delete(id);
throw new NotImplementedException();
}
public List<SalaryViewModel> GetSalaries(SalarySearchModel model)
{
throw new NotImplementedException();
}
public SalaryViewModel? GetSalaryById(int id)
{
throw new NotImplementedException();
}
}
}

View File

@ -8,56 +8,24 @@ namespace EmployeeManagmentBusinessLogic.BusinessLogic
{
public class VacationLogic : IVacationLogic
{
private readonly IVacationStorage _vacationStorage;
public VacationLogic(IVacationStorage vacationStorage)
{
_vacationStorage = vacationStorage;
}
public List<VacationViewModel> GetVacations(VacationSearchModel model)
{
return _vacationStorage.GetFilteredList(model).Select(v => new VacationViewModel
{
Id = v.Id,
StartData = v.StartData,
EndData = v.EndData,
Passed = v.Passed,
EmployeeName = v.Employee.NameJob
}).ToList();
}
public void CreateOrUpdate(VacationBindingModel model)
{
if (model.Id.HasValue)
{
var existingVacation = _vacationStorage.GetElement(model.Id.Value);
if (existingVacation == null)
throw new Exception("Отпуск не найден");
existingVacation.StartData = model.StartData;
existingVacation.EndData = model.EndData;
existingVacation.Passed = model.Passed;
existingVacation.EmployeeId = model.EmployeeId;
_vacationStorage.Update(existingVacation);
}
else
{
var newVacation = new Vacation
{
StartData = model.StartData,
EndData = model.EndData,
Passed = model.Passed,
EmployeeId = model.EmployeeId
};
_vacationStorage.Insert(newVacation);
}
throw new NotImplementedException();
}
public void Delete(int id)
{
_vacationStorage.Delete(id);
throw new NotImplementedException();
}
public VacationViewModel? GetVacationById(int id)
{
throw new NotImplementedException();
}
public List<VacationViewModel> GetVacations(VacationSearchModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -14,6 +14,6 @@ namespace EmployeeManagmentContracts.BindingModels
public DateTime? EndJob { get; set; }
public string? PartTimeJob { get; set; }
public float Bid { get; set; }
public int PhysicalPersonId { get; set; }
public int PhisicalPersonId { get; set; }
}
}

View File

@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\EmployeeManagmentDataModels\EmployeeManagmentDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -1,4 +1,5 @@
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
@ -9,11 +10,11 @@ namespace EmployeeManagmentContracts.StoragesContracts
{
public interface IEmployeeStorage
{
List<Employee> GetFullList();
List<Employee> GetFilteredList(EmployeeSearchModel model);
Employee? GetElement(int id);
void Insert(Employee employee);
void Update(Employee employee);
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

@ -1,4 +1,6 @@
using System;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -8,11 +10,11 @@ namespace EmployeeManagmentContracts.StoragesContracts
{
public interface IPhisicalPersonStorage
{
List<PhisicalPerson> GetFullList();
List<PhisicalPerson> GetFilteredList(PhisicalPersonSearchModel model);
PhisicalPerson? GetElement(int id);
void Insert(PhisicalPerson phisicalPerson);
void Update(PhisicalPerson phisicalPerson);
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

@ -1,4 +1,6 @@
using System;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -8,11 +10,11 @@ namespace EmployeeManagmentContracts.StoragesContracts
{
public interface ISalaryStorage
{
List<Salary> GetFullList();
List<Salary> GetFilteredList(SalarySearchModel model);
Salary? GetElement(int id);
void Insert(Salary salary);
void Update(Salary salary);
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

@ -1,4 +1,5 @@
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
@ -9,11 +10,11 @@ namespace EmployeeManagmentContracts.StoragesContracts
{
public interface IVacationStorage
{
List<Vacation> GetFullList();
List<Vacation> GetFilteredList(VacationSearchModel model);
Vacation? GetElement(int id);
void Insert(Vacation vacation);
void Update(Vacation vacation);
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

@ -14,7 +14,7 @@ namespace EmployeeManagmentContracts.ViewModels
public DateTime? EndJob { get; set; }
public string? PartTimeJob { get; set; }
public float Bid { get; set; }
public string PhysicalPersonName { get; set; } = string.Empty;
public string PhisicalPersonName { get; set; } = string.Empty;
}
}

View File

@ -1,24 +0,0 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataBaseImplement
{
public class DatabaseContext : DbContext
{
public DbSet<Employee> Employees { get; set; }
public DbSet<PhysicalPerson> PhysicalPersons { get; set; }
public DbSet<Salary> Salaries { get; set; }
public DbSet<Vacation> Vacations { get; set; }
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
}

View File

@ -0,0 +1,23 @@
using EmployeeManagmentDataBaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataBaseImplement
{
public class EmployeeManagementDbContext : DbContext
{
public DbSet<Employee> Employees { get; set; }
public DbSet<PhisicalPerson> PhisicalPersons { get; set; }
public DbSet<Salary> Salaries { get; set; }
public DbSet<Vacation> Vacations { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("YourConnectionStringHere");
}
}
}

View File

@ -25,4 +25,8 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EmployeeManagmentContracts\EmployeeManagmentContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -1,85 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EmployeeManagmentContracts.SearchModels;
using EmployeeManagmentContracts.StoragesContracts;
using EmployeeManagmentContracts.ViewModels;
using EmployeeManagmentDataBaseImplement.Models;
namespace EmployeeManagmentDataBaseImplement.Implements
{
public class EmployeeStorage : IEmployeeStorage
{
public List<Employee> GetFullList()
{
using (var context = new DatabaseContext())
{
return context.Employees.ToList();
}
}
public List<Employee> GetFilteredList(EmployeeSearchModel searchModel)
{
using (var context = new DatabaseContext())
{
return context.Employees
.Where(e => searchModel.Name != null && e.Name.Contains(searchModel.Name))
.ToList();
}
}
public Employee? GetElement(EmployeeSearchModel searchModel)
{
using (var context = new DatabaseContext())
{
return context.Employees.FirstOrDefault(e => e.Id == searchModel.Id);
}
}
public void Insert(EmployeeBindingModel model)
{
using (var context = new DatabaseContext())
{
var newEmployee = new Employee
{
Name = model.Name,
StartJob = model.StartJob,
EndJob = model.EndJob,
PartTimeJob = model.PartTimeJob,
Bid = model.Bid,
PhysicalPersonsId = model.PhysicalPersonsId
};
context.Employees.Add(newEmployee);
context.SaveChanges();
}
}
public void Update(EmployeeBindingModel model)
{
using (var context = new DatabaseContext())
{
var employee = context.Employees.FirstOrDefault(e => e.Id == model.Id);
if (employee == null)
return;
employee.Name = model.Name;
employee.StartJob = model.StartJob;
employee.EndJob = model.EndJob;
employee.PartTimeJob = model.PartTimeJob;
employee.Bid = model.Bid;
context.SaveChanges();
}
}
public void Delete(int id)
{
using (var context = new DatabaseContext())
{
var employee = context.Employees.FirstOrDefault(e => e.Id == id);
if (employee != null)
{
context.Employees.Remove(employee);
context.SaveChanges();
}
}
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

@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EmployeeManagmentDataModels.Models;
namespace EmployeeManagmentDataBaseImplement.Models
{

View File

@ -0,0 +1,27 @@
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
{
[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; }
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;
// Связь с сотрудниками
public List<Employee>? Employees { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataBaseImplement.Models
{
public class Salary
{
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EmployeeManagmentDataBaseImplement.Models
{
public class Vacation
{
}
}

View File

@ -6,7 +6,10 @@ using System.Threading.Tasks;
namespace EmployeeManagmentDataModels.Enums
{
internal class VacationStatus
public enum VacationStatus
{
Planned, // Запланированный отпуск
Approved, // Одобренный отпуск
Taken // Отпуск использован
}
}

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,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>
/// Логика взаимодействия для EmployeesWindow.xaml
/// </summary>
public partial class EmployeesWindow : Window
{
public EmployeesWindow()
{
InitializeComponent();
}
}
}

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

@ -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>
/// Логика взаимодействия для SalariesWindow.xaml
/// </summary>
public partial class SalariesWindow : Window
{
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();
}
}
}