using ConstructionCompanyContracts.BindingModels; using ConstructionCompanyContracts.SearchModels; 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 = 1; for (int i = 0; i < 200; i++) { _employee.Create(new EmployeeBindingModel { EmployeeName = "testEmp" + (i + 1), PositionID = posInd }); posInd++; if (posInd == 11) posInd = 1; } } public void GenerateEmployeesOrders() { for (int i = 1; i <= 200; i++) { _employeeOrder.Create(new EmployeeOrderBindingModel { EmployeeId = i, OrderId = i}); } } public void GenerateMaterialOrders() { int quantity = 1; for (int i = 1; i <= 200; i++) { _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++) { int mat = rand.Next(1, 10); int ord = rand.Next(1, 100); 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; } } public void GenerateMaterials() { for (int i = 0; i < 200; i++) { _material.Create(new MaterialBindingModel { MaterialName = "testMat" + (i + 1), Quantity = 2000 }); } } public void GenerateOrders() { for (int i = 0; i < 1000; i++) { _order.CreateOrder(new OrderBindingModel { Description = "order" + (i + 1), Adress = "dsdsdssd", Price=20000, Status=OrderStatus.Неизвестен, CustomerNumber="+7838347475"}); } } public void GeneratePositions() { for (int i = 0; i < 20; i++) { _position.Create(new PositionBindingModel { PositionName = "testPos" + (i + 1), Salary = 20000 }); } } } }