From c622bfa3e695aaf58a5cad2dc730ccf59a906580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=BA=20=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Sat, 8 Apr 2023 15:38:52 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B8=D0=BC=D0=B8=D1=82=D0=B0=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D1=80=D0=BE=D0=BB=D0=B8=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomerRoleImitationLogic.cs | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/CarService/CarServiceBusinessLogic/BusinessLogics/CustomerRoleImitationLogic.cs b/CarService/CarServiceBusinessLogic/BusinessLogics/CustomerRoleImitationLogic.cs index bf666d0..d4b0437 100644 --- a/CarService/CarServiceBusinessLogic/BusinessLogics/CustomerRoleImitationLogic.cs +++ b/CarService/CarServiceBusinessLogic/BusinessLogics/CustomerRoleImitationLogic.cs @@ -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; } } }