доработка имитации роли клиента

This commit is contained in:
Мк Игорь 2023-04-08 15:38:52 +04:00
parent c75ec10d8a
commit c622bfa3e6

View File

@ -12,13 +12,15 @@ namespace CarServiceBusinessLogic.BusinessLogics
private readonly IRepairRequestLogic _repairRequestLogic;
private readonly IWorkInRequestLogic _workInRequestLogic;
private readonly IWorkLogic _workLogic;
public CustomerRoleImitationLogic(ICustomerLogic customerLogic, IVehicleLogic vehicleLogic, IRepairRequestLogic repairRequestLogic, IWorkInRequestLogic workInRequestLogic, IWorkLogic workLogic)
private readonly IWorkPaymentLogic _workPaymentLogic;
public CustomerRoleImitationLogic(ICustomerLogic customerLogic, IVehicleLogic vehicleLogic, IRepairRequestLogic repairRequestLogic, IWorkInRequestLogic workInRequestLogic, IWorkLogic workLogic, IWorkPaymentLogic workPaymentLogic)
{
_customerLogic = customerLogic;
_vehicleLogic = vehicleLogic;
_repairRequestLogic = repairRequestLogic;
_workInRequestLogic = workInRequestLogic;
_workLogic = workLogic;
_workPaymentLogic = workPaymentLogic;
}
private bool GenerateCustomerData()
{
@ -134,7 +136,31 @@ namespace CarServiceBusinessLogic.BusinessLogics
});
}
return true;
}
public bool GeneratePayments()
{
var WorksInRequestList = _workInRequestLogic.ReadList(null);
if (WorksInRequestList == null)
{
return false;
}
if (WorksInRequestList.Count == 0)
{
return false;
}
Random r = new();
for (int i = 0; i < 2; i++)
{
int paidWorkId = r.Next(0, WorksInRequestList.Count);//определяем, какую работу оплачиваем
bool payFullPrice = Convert.ToBoolean(r.Next(0, 1));//определяем, оплачиваем заявку полностью или наполовину
_workPaymentLogic.Create(new()
{
DatePayment = DateTime.Now,
Sum = payFullPrice ? WorksInRequestList[paidWorkId].Cost : WorksInRequestList[paidWorkId].Cost / 2,
WorkInRequestId = paidWorkId
});
}
return true;
}
}
}