From 51947e29e9da10d39021d2c22cf75bf042897cab Mon Sep 17 00:00:00 2001
From: abazov73 <92822431+abazov73@users.noreply.github.com>
Date: Mon, 24 Apr 2023 13:36:40 +0400
Subject: [PATCH] Begin MongoDB project
---
ConstructionCompany/ConstructionCompany.sln | 12 +++-
...ConstructionCompanyMongoDBImplement.csproj | 23 +++++++
.../Models/Employee.cs | 18 ++++++
.../Models/Position.cs | 63 +++++++++++++++++++
.../ConstructionCompanyView.csproj | 1 +
5 files changed, 114 insertions(+), 3 deletions(-)
create mode 100644 ConstructionCompany/ConstructionCompanyMongoDBImplement/ConstructionCompanyMongoDBImplement.csproj
create mode 100644 ConstructionCompany/ConstructionCompanyMongoDBImplement/Models/Employee.cs
create mode 100644 ConstructionCompany/ConstructionCompanyMongoDBImplement/Models/Position.cs
diff --git a/ConstructionCompany/ConstructionCompany.sln b/ConstructionCompany/ConstructionCompany.sln
index 428e4c2..0e1fa84 100644
--- a/ConstructionCompany/ConstructionCompany.sln
+++ b/ConstructionCompany/ConstructionCompany.sln
@@ -7,11 +7,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConstructionCompanyView", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConstructionCompanyDataModels", "ConstructionCompanyDataModels\ConstructionCompanyDataModels.csproj", "{78CB5CC6-B587-41DD-B595-13138E6351C8}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstructionCompanyContracts", "ConstructionCompanyContracts\ConstructionCompanyContracts.csproj", "{CFB66158-7025-4605-9739-C4A2F07D2EB6}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConstructionCompanyContracts", "ConstructionCompanyContracts\ConstructionCompanyContracts.csproj", "{CFB66158-7025-4605-9739-C4A2F07D2EB6}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstructionCompanyBusinessLogic", "ConstructionCompanyBusiness\ConstructionCompanyBusinessLogic.csproj", "{FB447245-07E1-4E0D-A4FC-701E295B7575}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConstructionCompanyBusinessLogic", "ConstructionCompanyBusiness\ConstructionCompanyBusinessLogic.csproj", "{FB447245-07E1-4E0D-A4FC-701E295B7575}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstructionCompanyPsqlImplement", "ConstructionCompanyPsqlImplement\ConstructionCompanyPsqlImplement.csproj", "{A92A2186-2021-4B42-B632-447A45EC3A58}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConstructionCompanyPsqlImplement", "ConstructionCompanyPsqlImplement\ConstructionCompanyPsqlImplement.csproj", "{A92A2186-2021-4B42-B632-447A45EC3A58}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstructionCompanyMongoDBImplement", "ConstructionCompanyMongoDBImplement\ConstructionCompanyMongoDBImplement.csproj", "{52991C32-415C-46C5-8995-007D01C70968}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -39,6 +41,10 @@ Global
{A92A2186-2021-4B42-B632-447A45EC3A58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A92A2186-2021-4B42-B632-447A45EC3A58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A92A2186-2021-4B42-B632-447A45EC3A58}.Release|Any CPU.Build.0 = Release|Any CPU
+ {52991C32-415C-46C5-8995-007D01C70968}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {52991C32-415C-46C5-8995-007D01C70968}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {52991C32-415C-46C5-8995-007D01C70968}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {52991C32-415C-46C5-8995-007D01C70968}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ConstructionCompany/ConstructionCompanyMongoDBImplement/ConstructionCompanyMongoDBImplement.csproj b/ConstructionCompany/ConstructionCompanyMongoDBImplement/ConstructionCompanyMongoDBImplement.csproj
new file mode 100644
index 0000000..2c6cff1
--- /dev/null
+++ b/ConstructionCompany/ConstructionCompanyMongoDBImplement/ConstructionCompanyMongoDBImplement.csproj
@@ -0,0 +1,23 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ConstructionCompany/ConstructionCompanyMongoDBImplement/Models/Employee.cs b/ConstructionCompany/ConstructionCompanyMongoDBImplement/Models/Employee.cs
new file mode 100644
index 0000000..9b0468d
--- /dev/null
+++ b/ConstructionCompany/ConstructionCompanyMongoDBImplement/Models/Employee.cs
@@ -0,0 +1,18 @@
+using ConstructionCompanyDataModels.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConstructionCompanyMongoDBImplement.Models
+{
+ public class Employee : IEmployeeModel
+ {
+ public string EmployeeName { get; private set; } = string.Empty;
+
+ public int Id { get; private set; }
+ public int PositionID { get; private set; }
+ public Position Position { get; set; } = new();
+ }
+}
diff --git a/ConstructionCompany/ConstructionCompanyMongoDBImplement/Models/Position.cs b/ConstructionCompany/ConstructionCompanyMongoDBImplement/Models/Position.cs
new file mode 100644
index 0000000..2f35678
--- /dev/null
+++ b/ConstructionCompany/ConstructionCompanyMongoDBImplement/Models/Position.cs
@@ -0,0 +1,63 @@
+using ConstructionCompanyContracts.BindingModels;
+using ConstructionCompanyDataModels.Models;
+using MongoDB.Bson;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConstructionCompanyMongoDBImplement.Models
+{
+ public class Position : IPositionModel
+ {
+ public string PositionName { get; private set; } = string.Empty;
+
+ public double Salary { get; set; }
+
+ public int Id { get; private set; }
+ public List Employees { get; private set; } = new List();
+
+ public static Position? Create(PositionBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Position()
+ {
+ Id = model.Id,
+ PositionName = model.PositionName,
+ Salary = model.Salary
+ };
+ }
+
+ public static BsonDocument? CreateBSON(PositionBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new BsonDocument
+ {
+ {"PositionName", $"{model.PositionName}"},
+ {"Salary", $"{model.Salary}" },
+ {"EmployeesId", new BsonArray{}}
+ };
+ }
+
+ public static BsonDocument? UpdateBSON(PositionBindingModel? model, List ids)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new BsonDocument
+ {
+ {"PositionName", $"{model.PositionName}"},
+ {"Salary", $"{model.Salary}" },
+ {"EmployeesId", new BsonArray(ids)}
+ };
+ }
+ }
+}
diff --git a/ConstructionCompany/ConstructionCompanyView/ConstructionCompanyView.csproj b/ConstructionCompany/ConstructionCompanyView/ConstructionCompanyView.csproj
index 48d2ba1..ca46dc5 100644
--- a/ConstructionCompany/ConstructionCompanyView/ConstructionCompanyView.csproj
+++ b/ConstructionCompany/ConstructionCompanyView/ConstructionCompanyView.csproj
@@ -25,6 +25,7 @@
+