88 lines
3.2 KiB
C#
88 lines
3.2 KiB
C#
using ConstructionCompanyContracts.BindingModels;
|
||
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()
|
||
{
|
||
for (int i = 0; i < 400; i++)
|
||
{
|
||
_employee.Create(new EmployeeBindingModel { EmployeeName = "testEmp", PositionID = 1 });
|
||
}
|
||
}
|
||
|
||
public void GenerateEmployeesOrders()
|
||
{
|
||
for (int i = 0; i < 2000; i++)
|
||
{
|
||
Random rand = new Random();
|
||
int emp = rand.Next(1, 600);
|
||
int ord = rand.Next(1, 2000);
|
||
if (_employeeOrder.ReadList(null)?.FirstOrDefault(x => x.OrderId == ord && x.EmployeeId == emp) != null) continue;
|
||
_employeeOrder.Create(new EmployeeOrderBindingModel { EmployeeId = emp, OrderId = ord});
|
||
}
|
||
}
|
||
|
||
public void GenerateMaterialOrders()
|
||
{
|
||
for (int i = 0; i < 50; i++)
|
||
{
|
||
Random rand = new Random();
|
||
int mat = rand.Next(1, 10);
|
||
int ord = rand.Next(1, 200);
|
||
if (_materialOrder.ReadList(null)?.FirstOrDefault(x => x.OrderId == ord && x.MaterialId == mat) != null) continue;
|
||
_materialOrder.Create(new MaterialOrderBindingModel { MaterialId = mat, OrderId = ord, Quantity = 1});
|
||
}
|
||
}
|
||
|
||
public void GenerateMaterials()
|
||
{
|
||
for (int i = 0; i < 1000; i++)
|
||
{
|
||
_material.Create(new MaterialBindingModel { MaterialName = "testMat", Quantity = 2000 });
|
||
}
|
||
}
|
||
|
||
public void GenerateOrders()
|
||
{
|
||
for (int i = 0; i < 2000; i++)
|
||
{
|
||
_order.CreateOrder(new OrderBindingModel { Description = "snfjknfjksfns", Adress = "dsdsdssd", Price=20000, Status=OrderStatus.Неизвестен, CustomerNumber="+7838347475"});
|
||
}
|
||
}
|
||
|
||
public void GeneratePositions()
|
||
{
|
||
for (int i = 0; i < 15; i++)
|
||
{
|
||
_position.Create(new PositionBindingModel { PositionName = "testPos", Salary = 20000 });
|
||
}
|
||
}
|
||
}
|
||
}
|