PIbd-23_Abazov_A.A._Constru.../ConstructionCompany/ConstructionCompanyBusiness/BusinessLogics/RandomGeneratorLogic.cs

106 lines
3.6 KiB
C#
Raw Normal View History

2023-04-10 14:24:22 +04:00
using ConstructionCompanyContracts.BindingModels;
2023-04-23 18:04:13 +04:00
using ConstructionCompanyContracts.SearchModels;
2023-04-10 14:24:22 +04:00
using ConstructionCompanyContracts.BusinessLogicContracts;
using ConstructionCompanyDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConstructionCompanyBusinessLogic.BusinessLogics
{
public class RandomGeneratorLogic : IRandomGeneratorLogic
{
private readonly IMaterialLogic _material;
private readonly IEmployeeLogic _employee;
private readonly IPositionLogic _position;
private readonly IOrderLogic _order;
private readonly IMaterialOrderLogic _materialOrder;
private readonly IEmployeeOrderLogic _employeeOrder;
public RandomGeneratorLogic(IMaterialLogic material, IEmployeeLogic employee, IPositionLogic position, IOrderLogic order, IMaterialOrderLogic materialOrder, IEmployeeOrderLogic employeeOrder)
{
_material = material;
_employee = employee;
_position = position;
_order = order;
_materialOrder = materialOrder;
_employeeOrder = employeeOrder;
}
public void GenerateEmployees()
{
int posInd = 0;
2023-04-23 18:04:13 +04:00
for (int i = 0; i < 200; i++)
2023-04-10 14:24:22 +04:00
{
2023-04-23 18:04:13 +04:00
_employee.Create(new EmployeeBindingModel { EmployeeName = "testEmp" + (i + 1), PositionID = posInd });
posInd++;
if (posInd == 20) posInd = 0;
2023-04-10 14:24:22 +04:00
}
}
public void GenerateEmployeesOrders()
{
for (int i = 0; i < 200; i++)
2023-04-10 14:24:22 +04:00
{
2023-04-23 18:04:13 +04:00
_employeeOrder.Create(new EmployeeOrderBindingModel { EmployeeId = i, OrderId = i});
2023-04-10 14:24:22 +04:00
}
}
public void GenerateMaterialOrders()
{
2023-04-23 18:04:13 +04:00
int quantity = 1;
for (int i = 0; i < 200; i++)
2023-04-23 18:04:13 +04:00
{
_materialOrder.Create(new MaterialOrderBindingModel { MaterialId = i, OrderId = i, Quantity = quantity});
quantity++;
if (quantity == 7) quantity = 1;
}
}
public void GenerateAdditionalMaterialOrders()
{
Random rand = new Random();
int quantity = 1;
for (int i = 1; i <= 100; i++)
2023-04-10 14:24:22 +04:00
{
int mat = rand.Next(0, 10);
int ord = rand.Next(0, 100);
2023-04-23 18:04:13 +04:00
if (_materialOrder.ReadElement(new MaterialOrderSearchModel { MaterialId = mat, OrderId = ord}) != null)
{
i--;
continue;
}
_materialOrder.Create(new MaterialOrderBindingModel { MaterialId = mat, OrderId = ord, Quantity = quantity });
quantity++;
if (quantity == 7) quantity = 1;
2023-04-10 14:24:22 +04:00
}
}
public void GenerateMaterials()
{
2023-04-23 18:04:13 +04:00
for (int i = 0; i < 200; i++)
2023-04-10 14:24:22 +04:00
{
2023-04-23 18:04:13 +04:00
_material.Create(new MaterialBindingModel { MaterialName = "testMat" + (i + 1), Quantity = 2000 });
2023-04-10 14:24:22 +04:00
}
}
public void GenerateOrders()
{
2023-04-23 18:04:13 +04:00
for (int i = 0; i < 1000; i++)
2023-04-10 14:24:22 +04:00
{
2023-04-23 18:04:13 +04:00
_order.CreateOrder(new OrderBindingModel { Description = "order" + (i + 1), Adress = "dsdsdssd", Price=20000, Status=OrderStatus.Неизвестен, CustomerNumber="+7838347475"});
2023-04-10 14:24:22 +04:00
}
}
public void GeneratePositions()
{
2023-04-23 18:04:13 +04:00
for (int i = 0; i < 20; i++)
2023-04-10 14:24:22 +04:00
{
2023-04-23 18:04:13 +04:00
_position.Create(new PositionBindingModel { PositionName = "testPos" + (i + 1), Salary = 20000 });
2023-04-10 14:24:22 +04:00
}
}
}
}