Storages for MongoDB (w/o reports) + models fixes

This commit is contained in:
abazov73 2023-05-09 22:06:53 +04:00
parent d8186eecc0
commit 306064c808
13 changed files with 690 additions and 13 deletions

View File

@ -83,6 +83,12 @@ namespace ConstructionCompanyMongoDBImplement
}
return _instance;
}
public BsonDocument ReadDocument(BsonDocument filter, string collectionName)
{
var collection = client.GetDatabase(databaseName).GetCollection<BsonDocument>(collectionName);
BsonDocument result = collection.Find(filter).ToList()[0];
return result;
}
public void InsertDocument(BsonDocument bson, string collectionName)
{
@ -168,7 +174,8 @@ namespace ConstructionCompanyMongoDBImplement
}
string? customerNumber = order[5].ToString();
DateTime dateBegin = order[6].ToUniversalTime();
DateTime dateEnd = order[7].ToUniversalTime();
DateTime? dateEnd = null;
if (order[7].ToString().Length > 5) dateEnd = order[7].ToUniversalTime();
Order? newOrder = Order.Create(new OrderBindingModel { Id = id, Description = description, Adress = adress, Price = price,
Status = orderStatus, CustomerNumber = customerNumber, DateBegin = dateBegin, DateEnd = dateEnd });
if (newOrder != null) _orders.Add(newOrder);
@ -186,6 +193,7 @@ namespace ConstructionCompanyMongoDBImplement
int materialId = material[0].ToInt32();
int quantity = material[1].ToInt32();
MaterialOrder? materialOrder = MaterialOrder.Create(new MaterialOrderBindingModel { MaterialId = materialId, OrderId = id, Quantity = quantity }, _materials, _orders);
if (materialOrder != null) _materialOrders.Add(materialOrder);
}
}
}

View File

@ -6,10 +6,6 @@
<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" />

View File

@ -0,0 +1,111 @@
using ConstructionCompanyContracts.BindingModels;
using ConstructionCompanyContracts.SearchModels;
using ConstructionCompanyContracts.StorageContracts;
using ConstructionCompanyContracts.ViewModels;
using ConstructionCompanyMongoDBImplement.Models;
using MongoDB.Bson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConstructionCompanyMongoDBImplement.Implements
{
public class EmployeeOrderStorage : IEmployeeOrderStorage
{
private readonly ConstructionCompanyDatabase _source;
public EmployeeOrderStorage()
{
_source = ConstructionCompanyDatabase.GetInstance();
}
public List<EmployeeOrderViewModel> GetFullList()
{
List<EmployeeOrderViewModel> result = new List<EmployeeOrderViewModel>();
foreach (var material in _source.EmployeeOrders)
{
result.Add(material.GetViewModel);
}
return result;
}
public List<EmployeeOrderViewModel> GetFilteredList(EmployeeOrderSearchModel model)
{
if (model == null || !model.OrderId.HasValue || !model.EmployeeId.HasValue)
{
return new();
}
List<EmployeeOrderViewModel> result = new List<EmployeeOrderViewModel>();
foreach (var material in _source.EmployeeOrders)
{
if (material.EmployeeId == model.EmployeeId && material.OrderId == model.OrderId) result.Add(material.GetViewModel);
}
return result;
}
public EmployeeOrderViewModel? GetElement(EmployeeOrderSearchModel model)
{
if (model == null || !model.OrderId.HasValue || !model.EmployeeId.HasValue)
{
return new();
}
return _source.EmployeeOrders.FirstOrDefault(x => x.EmployeeId == model.EmployeeId && x.OrderId == model.OrderId)?.GetViewModel;
}
public EmployeeOrderViewModel? Insert(EmployeeOrderBindingModel model)
{
var order = _source.ReadDocument(new BsonDocument { { "_id", model.OrderId } }, "Orders");
var employeeIds = order[8].AsBsonArray;
var materials = order[9].AsBsonArray;
employeeIds.Add(model.EmployeeId);
var orderView = _source.Orders.First(x => x.Id == model.OrderId);
OrderBindingModel orderModel = new OrderBindingModel
{
Id = orderView.Id,
Description = orderView.Description,
Adress = orderView.Adress,
Price = orderView.Price,
Status = orderView.Status,
CustomerNumber = orderView.CustomerNumber,
DateBegin = orderView.DateBegin,
DateEnd = orderView.DateEnd,
};
var document = Order.UpdateBSON(orderModel, employeeIds, materials);
if (document == null)
{
return null;
}
_source.ReplaceDocument(document, new BsonDocument { { "_id", model.OrderId} }, "Orders");
var newEmployeeOrder = _source.EmployeeOrders[_source.EmployeeOrders.Count - 1];
return newEmployeeOrder.GetViewModel;
}
public EmployeeOrderViewModel? Delete(EmployeeOrderBindingModel model)
{
var deletedEmployeeOrder = _source.EmployeeOrders.First(x => x.EmployeeId == model.EmployeeId && x.OrderId == model.OrderId).GetViewModel;
var order = _source.ReadDocument(new BsonDocument { { "_id", model.OrderId } }, "Orders");
var employeeIds = order[8].AsBsonArray;
var materials = order[9].AsBsonArray;
employeeIds.Remove(model.EmployeeId);
var orderView = _source.Orders.First(x => x.Id == model.OrderId);
OrderBindingModel orderModel = new OrderBindingModel
{
Id = orderView.Id,
Description = orderView.Description,
Adress = orderView.Adress,
Price = orderView.Price,
Status = orderView.Status,
CustomerNumber = orderView.CustomerNumber,
DateBegin = orderView.DateBegin,
DateEnd = orderView.DateEnd,
};
var document = Order.UpdateBSON(orderModel, employeeIds, materials);
if (document == null)
{
return null;
}
_source.ReplaceDocument(document, new BsonDocument { { "_id", model.OrderId } }, "Orders");
return deletedEmployeeOrder;
}
}
}

View File

@ -0,0 +1,102 @@
using ConstructionCompanyContracts.BindingModels;
using ConstructionCompanyContracts.SearchModels;
using ConstructionCompanyContracts.StorageContracts;
using ConstructionCompanyContracts.ViewModels;
using ConstructionCompanyMongoDBImplement.Models;
using MongoDB.Bson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConstructionCompanyMongoDBImplement.Implements
{
public class EmployeeStorage : IEmployeeStorage
{
private readonly ConstructionCompanyDatabase _source;
private readonly IPositionStorage _positionStorage;
public EmployeeStorage(IPositionStorage positionStorage)
{
_source = ConstructionCompanyDatabase.GetInstance();
_positionStorage = positionStorage;
}
public List<EmployeeViewModel> GetFullList()
{
List<EmployeeViewModel> result = new List<EmployeeViewModel>();
foreach (var material in _source.Employees)
{
result.Add(material.GetViewModel);
}
return result;
}
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
{
if (model == null || !model.Id.HasValue && string.IsNullOrEmpty(model.EmployeeName))
{
return new();
}
List<EmployeeViewModel> result = new List<EmployeeViewModel>();
if (!string.IsNullOrEmpty(model.EmployeeName))
{
foreach (var material in _source.Employees)
{
if (material.EmployeeName.Equals(model.EmployeeName)) result.Add(material.GetViewModel);
}
return result;
}
else
{
foreach (var material in _source.Employees)
{
if (material.Id == model.Id) result.Add(material.GetViewModel);
}
return result;
}
}
public EmployeeViewModel? GetElement(EmployeeSearchModel model)
{
if (model == null || !model.Id.HasValue)
{
return new();
}
return _source.Employees.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public EmployeeViewModel? Insert(EmployeeBindingModel model)
{
model.Id = _source.Employees.Count > 0 ? _source.Employees.Max(x => x.Id) + 1 : 0;
var document = Employee.CreateBSON(model);
if (document == null)
{
return null;
}
_source.InsertDocument(document, "Employees");
var newEmployee = _source.Employees[_source.Employees.Count - 1];
return newEmployee.GetViewModel;
}
public EmployeeViewModel? Update(EmployeeBindingModel model)
{
var document = Employee.UpdateBSON(model);
if (document == null)
{
return null;
}
_source.ReplaceDocument(document, new BsonDocument { { "_id", model.Id } }, "Employees");
var position = _source.Positions.First(x => x.Id == model.PositionID);
_positionStorage.Update(new PositionBindingModel { Id = position.Id, PositionName = position.PositionName, Salary = position.Salary });
var updatedEmployee = _source.Employees.First(x => x.Id == model.Id);
return updatedEmployee.GetViewModel;
}
public EmployeeViewModel? Delete(EmployeeBindingModel model)
{
var deletedEmployee = _source.Employees.First(x => x.Id == model.Id).GetViewModel;
_source.DeleteDocument(new BsonDocument { { "_id", model.Id } }, "Employees");
return deletedEmployee;
}
}
}

View File

@ -0,0 +1,111 @@
using ConstructionCompanyContracts.BindingModels;
using ConstructionCompanyContracts.SearchModels;
using ConstructionCompanyContracts.StorageContracts;
using ConstructionCompanyContracts.ViewModels;
using ConstructionCompanyMongoDBImplement.Models;
using MongoDB.Bson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConstructionCompanyMongoDBImplement.Implements
{
public class MaterialOrderStorage : IMaterialOrderStorage
{
private readonly ConstructionCompanyDatabase _source;
public MaterialOrderStorage()
{
_source = ConstructionCompanyDatabase.GetInstance();
}
public List<MaterialOrderViewModel> GetFullList()
{
List<MaterialOrderViewModel> result = new List<MaterialOrderViewModel>();
foreach (var material in _source.MaterialOrders)
{
result.Add(material.GetViewModel);
}
return result;
}
public List<MaterialOrderViewModel> GetFilteredList(MaterialOrderSearchModel model)
{
if (model == null || !model.OrderId.HasValue || !model.MaterialId.HasValue)
{
return new();
}
List<MaterialOrderViewModel> result = new List<MaterialOrderViewModel>();
foreach (var material in _source.MaterialOrders)
{
if (material.MaterialId == model.MaterialId && material.OrderId == model.OrderId) result.Add(material.GetViewModel);
}
return result;
}
public MaterialOrderViewModel? GetElement(MaterialOrderSearchModel model)
{
if (model == null || !model.OrderId.HasValue || !model.MaterialId.HasValue)
{
return new();
}
return _source.MaterialOrders.FirstOrDefault(x => x.MaterialId == model.MaterialId && x.OrderId == model.OrderId)?.GetViewModel;
}
public MaterialOrderViewModel? Insert(MaterialOrderBindingModel model)
{
var order = _source.ReadDocument(new BsonDocument { { "_id", model.OrderId } }, "Orders");
var employeeIds = order[8].AsBsonArray;
var materials = order[9].AsBsonArray;
materials.Add(new BsonDocument {{"materialId", model.MaterialId}, {"quantity", model.Quantity}});
var orderView = _source.Orders.First(x => x.Id == model.OrderId);
OrderBindingModel orderModel = new OrderBindingModel
{
Id = orderView.Id,
Description = orderView.Description,
Adress = orderView.Adress,
Price = orderView.Price,
Status = orderView.Status,
CustomerNumber = orderView.CustomerNumber,
DateBegin = orderView.DateBegin,
DateEnd = orderView.DateEnd,
};
var document = Order.UpdateBSON(orderModel, employeeIds, materials);
if (document == null)
{
return null;
}
_source.ReplaceDocument(document, new BsonDocument { { "_id", model.OrderId } }, "Orders");
var newMaterialOrder = _source.MaterialOrders[_source.MaterialOrders.Count - 1];
return newMaterialOrder.GetViewModel;
}
public MaterialOrderViewModel? Delete(MaterialOrderBindingModel model)
{
var deletedMaterialOrder = _source.MaterialOrders.First(x => x.MaterialId == model.MaterialId && x.OrderId == model.OrderId).GetViewModel;
var order = _source.ReadDocument(new BsonDocument { { "_id", model.OrderId } }, "Orders");
var employeeIds = order[8].AsBsonArray;
var materials = order[9].AsBsonArray;
employeeIds.Remove(new BsonDocument {{"materialId", model.MaterialId}, {"quantity", model.Quantity}});
var orderView = _source.Orders.First(x => x.Id == model.OrderId);
OrderBindingModel orderModel = new OrderBindingModel
{
Id = orderView.Id,
Description = orderView.Description,
Adress = orderView.Adress,
Price = orderView.Price,
Status = orderView.Status,
CustomerNumber = orderView.CustomerNumber,
DateBegin = orderView.DateBegin,
DateEnd = orderView.DateEnd,
};
var document = Order.UpdateBSON(orderModel, employeeIds, materials);
if (document == null)
{
return null;
}
_source.ReplaceDocument(document, new BsonDocument { { "_id", model.OrderId } }, "Orders");
return deletedMaterialOrder;
}
}
}

View File

@ -0,0 +1,113 @@
using ConstructionCompanyContracts.BindingModels;
using ConstructionCompanyContracts.SearchModels;
using ConstructionCompanyContracts.StorageContracts;
using ConstructionCompanyContracts.ViewModels;
using ConstructionCompanyMongoDBImplement.Models;
using MongoDB.Bson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConstructionCompanyMongoDBImplement.Implements
{
public class MaterialStorage : IMaterialStorage
{
private readonly ConstructionCompanyDatabase _source;
public MaterialStorage()
{
_source = ConstructionCompanyDatabase.GetInstance();
}
public List<MaterialViewModel> GetFullList()
{
List<MaterialViewModel> result = new List<MaterialViewModel>();
foreach (var material in _source.Materials)
{
result.Add(material.GetViewModel);
}
return result;
}
public List<MaterialViewModel> GetFilteredList(MaterialSearchModel model)
{
if (model == null || !model.Id.HasValue || string.IsNullOrEmpty(model.MaterialName))
{
return new();
}
List<MaterialViewModel> result = new List<MaterialViewModel>();
if (!string.IsNullOrEmpty(model.MaterialName))
{
foreach (var material in _source.Materials)
{
if (material.MaterialName.Equals(model.MaterialName)) result.Add(material.GetViewModel);
}
return result;
}
else
{
foreach (var material in _source.Materials)
{
if (material.Id == model.Id) result.Add(material.GetViewModel);
}
return result;
}
}
public MaterialViewModel? GetElement(MaterialSearchModel model)
{
if (model == null || !model.Id.HasValue)
{
return new();
}
return _source.Materials.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public MaterialViewModel? Insert(MaterialBindingModel model)
{
model.Id = _source.Materials.Count > 0 ? _source.Materials.Max(x => x.Id) + 1 : 0;
var document = Material.CreateBSON(model);
if (document == null)
{
return null;
}
_source.InsertDocument(document, "Materials");
var newMaterial = _source.Materials[_source.Materials.Count - 1];
return newMaterial.GetViewModel;
}
public MaterialViewModel? Update(MaterialBindingModel model)
{
var document = Material.UpdateBSON(model);
if (document == null)
{
return null;
}
_source.ReplaceDocument(document, new BsonDocument { { "_id", model.Id } }, "Materials");
var updatedMaterial = _source.Materials.First(x => x.Id == model.Id);
return updatedMaterial.GetViewModel;
}
public MaterialViewModel? Delete(MaterialBindingModel model)
{
var deletedMaterial = _source.Materials.First(x => x.Id == model.Id).GetViewModel;
_source.DeleteDocument(new BsonDocument { { "_id", model.Id } }, "Materials");
return deletedMaterial;
}
public List<EmployeeViewModel>? GetEmployeesUsingMaterial(MaterialBindingModel model)
{
//var command = Material.GetEmployeeCommand(model);
//if (string.IsNullOrEmpty(command))
//{
// return null;
//}
//var employeesId = _source.ExecuteReader(command, 1);
List<EmployeeViewModel> employees = new List<EmployeeViewModel>();
//foreach (var id in employeesId)
//{
// employees.Add(_source.Employees.First(x => x.Id == Convert.ToInt32(id[0])).GetViewModel);
//}
return employees;
}
}
}

View File

@ -0,0 +1,90 @@
using ConstructionCompanyContracts.BindingModels;
using ConstructionCompanyContracts.SearchModels;
using ConstructionCompanyContracts.StorageContracts;
using ConstructionCompanyContracts.ViewModels;
using ConstructionCompanyMongoDBImplement.Models;
using MongoDB.Bson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConstructionCompanyMongoDBImplement.Implements
{
public class OrderStorage : IOrderStorage
{
private readonly ConstructionCompanyDatabase _source;
public OrderStorage()
{
_source = ConstructionCompanyDatabase.GetInstance();
}
public List<OrderViewModel> GetFullList()
{
List<OrderViewModel> result = new List<OrderViewModel>();
foreach (var material in _source.Orders)
{
result.Add(material.GetViewModel);
}
return result;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (model == null || !model.Id.HasValue)
{
return new();
}
List<OrderViewModel> result = new List<OrderViewModel>();
foreach (var material in _source.Orders)
{
if (material.Id == model.Id) result.Add(material.GetViewModel);
}
return result;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (model == null || !model.Id.HasValue)
{
return new();
}
return _source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public OrderViewModel? Insert(OrderBindingModel model)
{
model.Id = _source.Orders.Count > 0 ? _source.Orders.Max(x => x.Id) + 1 : 0;
var document = Order.CreateBSON(model);
if (document == null)
{
return null;
}
_source.InsertDocument(document, "Orders");
var newOrder = _source.Orders[_source.Orders.Count - 1];
return newOrder.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
{
var order = _source.ReadDocument(new BsonDocument { { "_id", model.Id } }, "Orders");
var employeeIds = order[8].AsBsonArray;
var materials = order[9].AsBsonArray;
var document = Order.UpdateBSON(model, employeeIds, materials);
if (document == null)
{
return null;
}
_source.ReplaceDocument(document, new BsonDocument { { "_id", model.Id} }, "Orders");
var updatedOrder = _source.Orders.First(x => x.Id == model.Id);
return updatedOrder.GetViewModel;
}
public OrderViewModel? Delete(OrderBindingModel model)
{
var deletedOrder = _source.Orders.First(x => x.Id == model.Id).GetViewModel;
_source.DeleteDocument(new BsonDocument { { "_id", model.Id } }, "Orders");
return deletedOrder;
}
}
}

View File

@ -0,0 +1,117 @@
using Amazon.Auth.AccessControlPolicy;
using ConstructionCompanyContracts.BindingModels;
using ConstructionCompanyContracts.SearchModels;
using ConstructionCompanyContracts.StorageContracts;
using ConstructionCompanyContracts.ViewModels;
using ConstructionCompanyMongoDBImplement.Models;
using MongoDB.Bson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConstructionCompanyMongoDBImplement.Implements
{
public class PositionStorage : IPositionStorage
{
private readonly ConstructionCompanyDatabase _source;
public PositionStorage()
{
_source = ConstructionCompanyDatabase.GetInstance();
}
public List<PositionViewModel> GetFullList()
{
List<PositionViewModel> result = new List<PositionViewModel>();
foreach (var material in _source.Positions)
{
result.Add(material.GetViewModel);
}
return result;
}
public List<PositionViewModel> GetFilteredList(PositionSearchModel model)
{
if (model == null || !model.Id.HasValue && string.IsNullOrEmpty(model.PositionName))
{
return new();
}
List<PositionViewModel> result = new List<PositionViewModel>();
if (!string.IsNullOrEmpty(model.PositionName))
{
foreach (var material in _source.Positions)
{
if (material.PositionName.Equals(model.PositionName)) result.Add(material.GetViewModel);
}
return result;
}
else
{
foreach (var material in _source.Positions)
{
if (material.Id == model.Id) result.Add(material.GetViewModel);
}
return result;
}
}
public PositionViewModel? GetElement(PositionSearchModel model)
{
if (model == null || !model.Id.HasValue)
{
return new();
}
return _source.Positions.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public PositionViewModel? Insert(PositionBindingModel model)
{
model.Id = _source.Positions.Count > 0 ? _source.Positions.Max(x => x.Id) + 1 : 0;
var document = Position.CreateBSON(model);
if (document == null)
{
return null;
}
_source.InsertDocument(document, "Positions");
var newPosition = _source.Positions[_source.Positions.Count - 1];
return newPosition.GetViewModel;
}
public PositionViewModel? Update(PositionBindingModel model)
{
List<int> ids = new List<int>();
foreach (var employee in _source.Employees)
{
if (employee.PositionID == model.Id) ids.Add(employee.Id);
}
var document = Position.UpdateBSON(model, ids);
if (document == null)
{
return null;
}
_source.ReplaceDocument(document, new BsonDocument { {"_id" , model.Id} }, "Positions");
var updatedPosition = _source.Positions.First(x => x.Id == model.Id);
return updatedPosition.GetViewModel;
}
public PositionViewModel? Delete(PositionBindingModel model)
{
var deletedPosition = _source.Positions.First(x => x.Id == model.Id).GetViewModel;
_source.DeleteDocument(new BsonDocument { { "_id", model.Id } }, "Positions");
return deletedPosition;
}
public List<BrigadeReportViewModel> GetPositionsAverage(DateTime dateFrom, DateTime dateTo)
{
//var command = Position.PositionsAVGCommnad(dateFrom, dateTo);
//var result = _source.ExecuteReader(command, 2);
List<BrigadeReportViewModel> positionsAverages = new List<BrigadeReportViewModel>();
//foreach (var posAvgPair in result)
//{
// string positionName = _source.Positions.First(x => x.Id == Convert.ToInt32(posAvgPair[0])).PositionName;
// positionsAverages.Add(new BrigadeReportViewModel { PositionId = Convert.ToInt32(posAvgPair[0]), PositionName = positionName, materialAvg = Convert.ToDouble(posAvgPair[1]) });
//}
return positionsAverages;
}
}
}

View File

@ -1,4 +1,5 @@
using ConstructionCompanyContracts.BindingModels;
using ConstructionCompanyContracts.ViewModels;
using ConstructionCompanyDataModels.Models;
using MongoDB.Bson;
using System;
@ -59,5 +60,12 @@ namespace ConstructionCompanyMongoDBImplement.Models
{"positionId", $"{model.PositionID}" }
};
}
public EmployeeViewModel GetViewModel => new()
{
Id = Id,
EmployeeName = EmployeeName,
PositionID = PositionID,
PositionName = Position.PositionName
};
}
}

View File

@ -1,4 +1,5 @@
using ConstructionCompanyContracts.BindingModels;
using ConstructionCompanyContracts.ViewModels;
using ConstructionCompanyDataModels.Models;
using MongoDB.Bson;
using System;
@ -57,5 +58,12 @@ namespace ConstructionCompanyMongoDBImplement.Models
{"quantity", $"{model.Quantity}" }
};
}
public MaterialViewModel GetViewModel => new()
{
Id = Id,
MaterialName = MaterialName,
Quantity = Quantity
};
}
}

View File

@ -1,4 +1,5 @@
using ConstructionCompanyContracts.BindingModels;
using ConstructionCompanyContracts.ViewModels;
using ConstructionCompanyDataModels.Enums;
using MongoDB.Bson;
using MongoDB.Driver;
@ -54,11 +55,11 @@ namespace ConstructionCompanyMongoDBImplement.Models
{"_id", model.Id},
{"description", $"{model.Description}"},
{"adress", $"{model.Adress}"},
{"customerNumber", $"{model.CustomerNumber}"},
{"price", $"{model.Price}"},
{"status", $"{model.Status}"},
{"dateBegin", $"{model.DateBegin}"},
{"dateEnd", $"{model.DateEnd}"},
{"customerNumber", $"{model.CustomerNumber}"},
{"dateBegin", new BsonDateTime(model.DateBegin)},
{"dateEnd", model.DateEnd.HasValue ? new BsonDateTime(model.DateEnd.Value) : ""},
{"employeesId", new BsonArray() },
{"materials", new BsonArray()}
};
@ -75,14 +76,26 @@ namespace ConstructionCompanyMongoDBImplement.Models
{"_id", model.Id},
{"description", $"{model.Description}"},
{"adress", $"{model.Adress}"},
{"customerNumber", $"{model.CustomerNumber}"},
{"price", $"{model.Price}"},
{"status", $"{model.Status}"},
{"dateBegin", $"{model.DateBegin}"},
{"dateEnd", $"{model.DateEnd}"},
{"customerNumber", $"{model.CustomerNumber}"},
{"dateBegin", new BsonDateTime(model.DateBegin)},
{"dateEnd", model.DateEnd.HasValue ? new BsonDateTime(model.DateEnd.Value) : ""},
{"employeesId", employeesId },
{"materials", materials}
};
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
Description = Description,
Adress = Adress,
CustomerNumber = CustomerNumber,
Price = Price,
Status = Status,
DateBegin = DateBegin,
DateEnd = DateEnd
};
}
}

View File

@ -48,7 +48,7 @@ namespace ConstructionCompanyMongoDBImplement.Models
};
}
public static BsonDocument? UpdateBSON(PositionBindingModel? model, List<string> ids)
public static BsonDocument? UpdateBSON(PositionBindingModel? model, List<int> ids)
{
if (model == null)
{

View File

@ -1,7 +1,7 @@
using ConstructionCompanyBusinessLogic.BusinessLogics;
using ConstructionCompanyContracts.BusinessLogicContracts;
using ConstructionCompanyContracts.StorageContracts;
using ConstructionCompanyPsqlImplement.Implements;
using ConstructionCompanyMongoDBImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;