diff --git a/ComputerStore/ComputerStore.sln b/ComputerStore/ComputerStore.sln
index 112e959..c2f7b18 100644
--- a/ComputerStore/ComputerStore.sln
+++ b/ComputerStore/ComputerStore.sln
@@ -3,15 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStore", "ComputerStore.csproj", "{695B79EB-71FD-456D-BFEA-634500FF2ECB}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerStoreEmployeeApp", "ComputerStoreEmployeeApp.csproj", "{695B79EB-71FD-456D-BFEA-634500FF2ECB}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStoreBusinessLogic", "..\ComputerStoreBusinessLogic\ComputerStoreBusinessLogic.csproj", "{17F8960F-03CB-49D7-B335-931E6BE5F9FF}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerStoreBusinessLogic", "..\ComputerStoreBusinessLogic\ComputerStoreBusinessLogic.csproj", "{17F8960F-03CB-49D7-B335-931E6BE5F9FF}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStoreContracts", "..\ComputerStoreContracts\ComputerStoreContracts.csproj", "{1C8DB816-F530-4CC3-9F36-F6191FE49C10}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerStoreContracts", "..\ComputerStoreContracts\ComputerStoreContracts.csproj", "{1C8DB816-F530-4CC3-9F36-F6191FE49C10}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStoreDataModels", "..\ComputerStoreDataModels\ComputerStoreDataModels.csproj", "{93679794-7F9A-43C4-A7C3-A1AE77FAB964}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerStoreDataModels", "..\ComputerStoreDataModels\ComputerStoreDataModels.csproj", "{93679794-7F9A-43C4-A7C3-A1AE77FAB964}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStoreDatabaseImplement", "..\ComputerStoreDatabaseImplement\ComputerStoreDatabaseImplement.csproj", "{24D66D03-F9DA-46C0-8C52-F55DDACDE8AF}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputerStoreDatabaseImplement", "..\ComputerStoreDatabaseImplement\ComputerStoreDatabaseImplement.csproj", "{24D66D03-F9DA-46C0-8C52-F55DDACDE8AF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputerStoreRestAPI", "..\ComputerStoreRestAPI\ComputerStoreRestAPI.csproj", "{11E7B5B7-7AF5-4E1E-837F-E6645D3C0EFB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -39,6 +41,10 @@ Global
{24D66D03-F9DA-46C0-8C52-F55DDACDE8AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24D66D03-F9DA-46C0-8C52-F55DDACDE8AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24D66D03-F9DA-46C0-8C52-F55DDACDE8AF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {11E7B5B7-7AF5-4E1E-837F-E6645D3C0EFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {11E7B5B7-7AF5-4E1E-837F-E6645D3C0EFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {11E7B5B7-7AF5-4E1E-837F-E6645D3C0EFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {11E7B5B7-7AF5-4E1E-837F-E6645D3C0EFB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ComputerStore/ComputerStore.csproj b/ComputerStore/ComputerStoreEmployeeApp.csproj
similarity index 100%
rename from ComputerStore/ComputerStore.csproj
rename to ComputerStore/ComputerStoreEmployeeApp.csproj
diff --git a/ComputerStoreContracts/SearchModels/EmployeeSearchModel.cs b/ComputerStoreContracts/SearchModels/EmployeeSearchModel.cs
index 5c1f3a2..6b58434 100644
--- a/ComputerStoreContracts/SearchModels/EmployeeSearchModel.cs
+++ b/ComputerStoreContracts/SearchModels/EmployeeSearchModel.cs
@@ -10,5 +10,6 @@ namespace ComputerStoreContracts.SearchModels
{
public int? ID { get; set; }
public string? Username { get; set; }
+ public string? Password { get; set; }
}
}
diff --git a/ComputerStoreRestAPI/ComputerStoreRestAPI.csproj b/ComputerStoreRestAPI/ComputerStoreRestAPI.csproj
new file mode 100644
index 0000000..60bf9ea
--- /dev/null
+++ b/ComputerStoreRestAPI/ComputerStoreRestAPI.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/ComputerStoreRestAPI/Controllers/EmployeeController.cs b/ComputerStoreRestAPI/Controllers/EmployeeController.cs
new file mode 100644
index 0000000..bbe511c
--- /dev/null
+++ b/ComputerStoreRestAPI/Controllers/EmployeeController.cs
@@ -0,0 +1,63 @@
+using ComputerStoreContracts.BindingModels;
+using ComputerStoreContracts.BusinessLogicContracts;
+using ComputerStoreContracts.SearchModels;
+using ComputerStoreContracts.ViewModels;
+using Microsoft.AspNetCore.Mvc;
+
+namespace ComputerStoreRestAPI.Controllers
+{
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ public class EmployeeController : Controller
+ {
+ private readonly ILogger _logger;
+ private readonly IEmployeeLogic _logic;
+
+ public EmployeeController(IEmployeeLogic logic, ILogger logger)
+ {
+ _logger = logger;
+ _logic = logic;
+ }
+
+ [HttpGet]
+ public EmployeeViewModel? Login(string login, string password)
+ {
+ try
+ {
+ return _logic.ReadElement(new EmployeeSearchModel { Username = login, Password = password });
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Employee logging in error"); throw;
+ }
+ }
+
+ [HttpPost]
+ public bool Register(EmployeeBindingModel employee)
+ {
+ try
+ {
+ return _logic.Create(employee);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Employee registration error ");
+ throw;
+ }
+ }
+
+ [HttpPatch]
+ public bool UpdateData(EmployeeBindingModel employee)
+ {
+ try
+ {
+ return _logic.Update(employee);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Update of data error ");
+ throw;
+ }
+ }
+ }
+}
diff --git a/ComputerStoreRestAPI/Controllers/MainController.cs b/ComputerStoreRestAPI/Controllers/MainController.cs
new file mode 100644
index 0000000..8909ea7
--- /dev/null
+++ b/ComputerStoreRestAPI/Controllers/MainController.cs
@@ -0,0 +1,195 @@
+using ComputerStoreContracts.BindingModels;
+using ComputerStoreContracts.BusinessLogicContracts;
+using ComputerStoreContracts.ViewModels;
+using Microsoft.AspNetCore.Mvc;
+
+namespace ComputerStoreRestAPI.Controllers
+{
+ [Route("api/[controller]/[action]")]
+ [ApiController]
+ public class MainController : Controller
+ {
+ private readonly ILogger _logger;
+ private readonly IComponentLogic _componentLogic;
+ private readonly IPCLogic _pcLogic;
+ private readonly IProductLogic _productLogic;
+ private readonly IEmployeeReportLogic _employeeReportLogic;
+
+ public MainController(ILogger logger, IComponentLogic componentLogic, IPCLogic pcLogic, IProductLogic productLogic, IEmployeeReportLogic employeeReportLogic)
+ {
+ _logger = logger;
+ _componentLogic = componentLogic;
+ _pcLogic = pcLogic;
+ _productLogic = productLogic;
+ _employeeReportLogic = employeeReportLogic;
+ }
+
+ [HttpGet]
+ public List? GetComponentsList()
+ {
+ try
+ {
+ return _componentLogic.ReadList(null);
+ }
+ catch(Exception ex)
+ {
+ _logger.LogError(ex, "Receiving list of components error.");
+ throw;
+ }
+ }
+
+ [HttpDelete]
+ public bool DeleteComponent(ComponentBindingModel component)
+ {
+ try
+ {
+ return _componentLogic.Delete(component);
+ }
+ catch(Exception ex)
+ {
+ _logger.LogError(ex, "Removing component error.");
+ throw;
+ }
+ }
+
+ [HttpPatch]
+ public bool UpdateComponent(ComponentBindingModel component)
+ {
+ try
+ {
+ return _componentLogic.Update(component);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Updating component error.");
+ throw;
+ }
+ }
+
+ [HttpPost]
+ public bool InsertComponent(ComponentBindingModel component)
+ {
+ try
+ {
+ return _componentLogic.Create(component);
+ }
+ catch(Exception ex)
+ {
+ _logger.LogError(ex, "Inserting component error.");
+ throw;
+ }
+ }
+
+ [HttpGet]
+ public List? GetProductsList()
+ {
+ try
+ {
+ return _productLogic.ReadList(null);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Receiving list of products error.");
+ throw;
+ }
+ }
+
+ [HttpDelete]
+ public bool DeleteProduct(ProductBindingModel product)
+ {
+ try
+ {
+ return _productLogic.Delete(product);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Removing product error.");
+ throw;
+ }
+ }
+
+ [HttpPatch]
+ public bool UpdateProduct(ProductBindingModel product)
+ {
+ try
+ {
+ return _productLogic.Update(product);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Updating product error.");
+ throw;
+ }
+ }
+
+ [HttpPost]
+ public bool InsertProduct(ProductBindingModel product)
+ {
+ try
+ {
+ return _productLogic.Create(product);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Inserting product error.");
+ throw;
+ }
+ }
+
+ [HttpGet]
+ public List? GetPCsList()
+ {
+ try
+ {
+ return _pcLogic.ReadList(null);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Receiving list of PCs error.");
+ throw;
+ }
+ }
+
+ [HttpDelete]
+ public bool DeletePC(PCBindingModel pc)
+ {
+ try
+ {
+ return _pcLogic.Delete(pc);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Removing PC error.");
+ throw;
+ }
+ }
+
+ [HttpPatch]
+ public bool UpdateProduct(PCBindingModel pc)
+ {
+ try
+ {
+ return _pcLogic.Update(pc);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Updating PC error.");
+ throw;
+ }
+ }
+
+ [HttpPost]
+ public bool InsertProduct(PCBindingModel pc)
+ {
+ try
+ {
+ return _pcLogic.Create(pc);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Inserting PC error.");
+ throw;
+ }
+ }
+ }
+}
diff --git a/ComputerStoreRestAPI/Program.cs b/ComputerStoreRestAPI/Program.cs
new file mode 100644
index 0000000..6f67cc8
--- /dev/null
+++ b/ComputerStoreRestAPI/Program.cs
@@ -0,0 +1,44 @@
+using ComputerStoreBusinessLogic.BusinessLogic;
+using ComputerStoreContracts.BusinessLogicContracts;
+using ComputerStoreContracts.StorageContracts;
+using ComputerStoreDatabaseImplement.Implements;
+
+var builder = WebApplication.CreateBuilder(args);
+
+builder.Logging.SetMinimumLevel(LogLevel.Trace);
+builder.Logging.AddLog4Net("log4net.config");
+
+// Add services to the container.
+
+builder.Services.AddTransient();
+builder.Services.AddTransient();
+builder.Services.AddTransient();
+builder.Services.AddTransient();
+
+builder.Services.AddTransient();
+builder.Services.AddTransient();
+builder.Services.AddTransient();
+builder.Services.AddTransient();
+builder.Services.AddTransient();
+
+builder.Services.AddControllers();
+// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
+builder.Services.AddEndpointsApiExplorer();
+builder.Services.AddSwaggerGen();
+
+var app = builder.Build();
+
+// Configure the HTTP request pipeline.
+if (app.Environment.IsDevelopment())
+{
+ app.UseSwagger();
+ app.UseSwaggerUI();
+}
+
+app.UseHttpsRedirection();
+
+app.UseAuthorization();
+
+app.MapControllers();
+
+app.Run();
diff --git a/ComputerStoreRestAPI/Properties/launchSettings.json b/ComputerStoreRestAPI/Properties/launchSettings.json
new file mode 100644
index 0000000..080239d
--- /dev/null
+++ b/ComputerStoreRestAPI/Properties/launchSettings.json
@@ -0,0 +1,31 @@
+{
+ "$schema": "https://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:11328",
+ "sslPort": 44392
+ }
+ },
+ "profiles": {
+ "ComputerStoreRestAPI": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "applicationUrl": "https://localhost:7081;http://localhost:5112",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "swagger",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/ComputerStoreRestAPI/appsettings.Development.json b/ComputerStoreRestAPI/appsettings.Development.json
new file mode 100644
index 0000000..0c208ae
--- /dev/null
+++ b/ComputerStoreRestAPI/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/ComputerStoreRestAPI/appsettings.json b/ComputerStoreRestAPI/appsettings.json
new file mode 100644
index 0000000..10f68b8
--- /dev/null
+++ b/ComputerStoreRestAPI/appsettings.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*"
+}