Доделанный проект EmployeeManagmentContracts
This commit is contained in:
parent
8f5c5c1b0a
commit
ab2c31aa99
@ -3,13 +3,15 @@ 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}") = "EmployeeManagmentView", "EmployeeManagmentView\EmployeeManagmentView.csproj", "{1A4AD060-3351-4B07-997E-59BAEDDAC493}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EmployeeManagmentView", "EmployeeManagmentView\EmployeeManagmentView.csproj", "{1A4AD060-3351-4B07-997E-59BAEDDAC493}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeManagmentContracts", "EmployeeManagmentContracts\EmployeeManagmentContracts.csproj", "{81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EmployeeManagmentContracts", "EmployeeManagmentContracts\EmployeeManagmentContracts.csproj", "{81DBCB6A-C1AD-4DC2-A016-C0ACB64AE2A7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeManagmentBusinessLogic", "EmployeeManagmentBusinessLogic\EmployeeManagmentBusinessLogic.csproj", "{00B118F5-6A3C-4606-8947-88D0288AEFDB}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EmployeeManagmentBusinessLogic", "EmployeeManagmentBusinessLogic\EmployeeManagmentBusinessLogic.csproj", "{00B118F5-6A3C-4606-8947-88D0288AEFDB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmployeeManagmentDataModels", "EmployeeManagmentDataModels\EmployeeManagmentDataModels.csproj", "{C5293211-E924-4CFA-9DE5-69003D8C9F48}"
|
||||
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
|
||||
@ -33,6 +35,10 @@ Global
|
||||
{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
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EmployeeManagmentContracts.BindingModels;
|
||||
using EmployeeManagmentContracts.BusinessLogicContracts;
|
||||
using EmployeeManagmentContracts.SearchModels;
|
||||
using EmployeeManagmentContracts.StoragesContracts;
|
||||
using EmployeeManagmentContracts.ViewModels;
|
||||
|
||||
namespace EmployeeManagmentBusinessLogic.BusinessLogic
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EmployeeManagmentContracts.BindingModels;
|
||||
using EmployeeManagmentContracts.BusinessLogicContracts;
|
||||
using EmployeeManagmentContracts.SearchModels;
|
||||
using EmployeeManagmentContracts.StoragesContracts;
|
||||
using EmployeeManagmentContracts.ViewModels;
|
||||
|
||||
namespace EmployeeManagmentBusinessLogic.BusinessLogic
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EmployeeManagmentContracts.BindingModels;
|
||||
using EmployeeManagmentContracts.BusinessLogicContracts;
|
||||
using EmployeeManagmentContracts.SearchModels;
|
||||
using EmployeeManagmentContracts.StoragesContracts;
|
||||
using EmployeeManagmentContracts.ViewModels;
|
||||
|
||||
namespace EmployeeManagmentBusinessLogic.BusinessLogic
|
||||
{
|
||||
|
@ -6,4 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\EmployeeManagmentContracts\EmployeeManagmentContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using EmployeeManagmentContracts.BindingModels;
|
||||
using EmployeeManagmentContracts.SearchModels;
|
||||
using EmployeeManagmentContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using EmployeeManagmentContracts.BindingModels;
|
||||
using EmployeeManagmentContracts.SearchModels;
|
||||
using EmployeeManagmentContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -12,5 +12,6 @@ namespace EmployeeManagmentContracts.SearchModels
|
||||
public string? NameJob { get; set; }
|
||||
public DateTime? StartDateFrom { get; set; }
|
||||
public DateTime? StartDateTo { get; set; }
|
||||
public float? Bid { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
14
EmployeeManagmentContracts/SearchModels/SalarySearchModel.cs
Normal file
14
EmployeeManagmentContracts/SearchModels/SalarySearchModel.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
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);
|
||||
void Delete(int id);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using EmployeeManagmentContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
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);
|
||||
void Delete(int id);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
17
EmployeeManagmentContracts/ViewModels/VacationViewModel.cs
Normal file
17
EmployeeManagmentContracts/ViewModels/VacationViewModel.cs
Normal 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;
|
||||
}
|
||||
}
|
24
EmployeeManagmentDataBaseImplement/DatabaseContext.cs
Normal file
24
EmployeeManagmentDataBaseImplement/DatabaseContext.cs
Normal file
@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
26
EmployeeManagmentDataBaseImplement/Models/Employee.cs
Normal file
26
EmployeeManagmentDataBaseImplement/Models/Employee.cs
Normal file
@ -0,0 +1,26 @@
|
||||
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 EmployeeManagmentDataBaseImplement.Models
|
||||
{
|
||||
public class Employee
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { 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("PhysicalPerson")]
|
||||
public int PhysicalPersonsId { get; set; }
|
||||
public PhysicalPerson? PhysicalPerson { get; set; }
|
||||
}
|
||||
}
|
5
EmployeeManagmentDataBaseImplement/appsettings.json
Normal file
5
EmployeeManagmentDataBaseImplement/appsettings.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"SqlServerConnection": "Server=localhost,1433;Database=EmployeeManagementDB;User Id=sa;Password=YourStrong@Password123;"
|
||||
}
|
||||
}
|
18
EmployeeManagmentDataBaseImplement/docker-compose.yml
Normal file
18
EmployeeManagmentDataBaseImplement/docker-compose.yml
Normal file
@ -0,0 +1,18 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
sqlserver-db:
|
||||
image: mcr.microsoft.com/mssql/server:2022-latest
|
||||
container_name: sqlserver-db
|
||||
environment:
|
||||
- ACCEPT_EULA=Y
|
||||
- SA_PASSWORD=YourStrong@Password123
|
||||
- MSSQL_PID=Express
|
||||
ports:
|
||||
- "1433:1433"
|
||||
volumes:
|
||||
- sql_data:/var/opt/mssql
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
sql_data:
|
Loading…
Reference in New Issue
Block a user