Begin MongoDB project

This commit is contained in:
abazov73 2023-04-24 13:36:40 +04:00
parent a1b06003f7
commit 51947e29e9
5 changed files with 114 additions and 3 deletions

View File

@ -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

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Implements\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MongoDB.Bson" Version="2.19.1" />
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ConstructionCompanyBusiness\ConstructionCompanyBusinessLogic.csproj" />
<ProjectReference Include="..\ConstructionCompanyDataModels\ConstructionCompanyDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -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();
}
}

View File

@ -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<int> Employees { get; private set; } = new List<int>();
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<string> ids)
{
if (model == null)
{
return null;
}
return new BsonDocument
{
{"PositionName", $"{model.PositionName}"},
{"Salary", $"{model.Salary}" },
{"EmployeesId", new BsonArray(ids)}
};
}
}
}

View File

@ -25,6 +25,7 @@
<ItemGroup>
<ProjectReference Include="..\ConstructionCompanyBusiness\ConstructionCompanyBusinessLogic.csproj" />
<ProjectReference Include="..\ConstructionCompanyContracts\ConstructionCompanyContracts.csproj" />
<ProjectReference Include="..\ConstructionCompanyMongoDBImplement\ConstructionCompanyMongoDBImplement.csproj" />
<ProjectReference Include="..\ConstructionCompanyPsqlImplement\ConstructionCompanyPsqlImplement.csproj" />
</ItemGroup>