имитация роли клиента

This commit is contained in:
Мк Игорь 2023-05-26 03:45:49 +04:00
parent 63512cf103
commit 6ae1f4a9e7
12 changed files with 64 additions and 9 deletions

View File

@ -62,7 +62,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
Name = vehicleRecData[0],
Plate = vehicleRecData[1],
VIN = vehicleRecData[2],
CustomerId = Convert.ToInt32(vehicleRecData[4])
CustomerId = Convert.ToInt32(vehicleRecData[3])
});
}
}
@ -128,11 +128,13 @@ namespace CarServiceBusinessLogic.BusinessLogics
Random r = new();
for (int i = 0; i < 2; i++)
{
int RRId = RequestList[r.Next(RequestList.Count)].Id;
int WId = WorksList[r.Next(WorksList.Count)].Id;
_workInRequestLogic.Create(new()
{
RepairRequestId = r.Next(0, RequestList.Count),
WorkId = r.Next(0, WorksList.Count),
Count = r.Next(1, 2)
RepairRequestId = RRId,
WorkId = WId,
Count = 1
});
}
return true;
@ -151,12 +153,13 @@ namespace CarServiceBusinessLogic.BusinessLogics
Random r = new();
for (int i = 0; i < 2; i++)
{
int paidWorkId = r.Next(0, WorksInRequestList.Count);//определяем, какую работу оплачиваем
int work = r.Next(0, WorksInRequestList.Count);
int paidWorkId = WorksInRequestList[work].Id;//определяем, какую работу оплачиваем
bool payFullPrice = Convert.ToBoolean(r.Next(0, 1));//определяем, оплачиваем заявку полностью или наполовину
_workPaymentLogic.Create(new()
{
DatePayment = DateTime.Now,
Sum = payFullPrice ? WorksInRequestList[paidWorkId].Cost : WorksInRequestList[paidWorkId].Cost / 2,
Sum = payFullPrice ? WorksInRequestList[work].Cost : WorksInRequestList[work].Cost / 2,
WorkInRequestId = paidWorkId
});
}

View File

@ -34,7 +34,7 @@ namespace CarServiceDatabase.Models
{
Count = model.Count,
Cost = context.Works.First(x => x.Id == model.WorkId).Price * model.Count,
RepairRequestId = model.RepairRequestId,
RepairRequest = context.RepairRequests.First(x => x.Id == model.RepairRequestId),
Work = context.Works.First(x => x.Id == model.WorkId)
};
}

View File

@ -16,8 +16,9 @@ namespace CarServiceWebApp.Controllers
private readonly IRepairRequestLogic _repairRequestLogic;
private readonly IItemForRepairLogic _itemForRepairLogic;
private readonly IWorkInRequestLogic _workInRequestLogic;
private readonly ICustomerRoleImitationLogic _customer;
public HomeController(ILogger<HomeController> logger, IWorkLogic workLogic, IWorkerLogic workerLogic, IItemLogic itemLogic, IRepairRequestLogic repairRequestLogic, IItemForRepairLogic itemForRepairLogic, IWorkInRequestLogic workInRequestLogic)
public HomeController(ILogger<HomeController> logger, IWorkLogic workLogic, IWorkerLogic workerLogic, IItemLogic itemLogic, IRepairRequestLogic repairRequestLogic, IItemForRepairLogic itemForRepairLogic, IWorkInRequestLogic workInRequestLogic, ICustomerRoleImitationLogic customer)
{
_logger = logger;
_workLogic = workLogic;
@ -26,6 +27,7 @@ namespace CarServiceWebApp.Controllers
_repairRequestLogic = repairRequestLogic;
_itemForRepairLogic = itemForRepairLogic;
_workInRequestLogic = workInRequestLogic;
_customer = customer;
}
/// <summary>
/// Главная страница
@ -325,6 +327,21 @@ namespace CarServiceWebApp.Controllers
}
return View();
}
public IActionResult GenerateRequestData()
{
_customer.GenerateRequestData();
return Redirect("~/Home/Index");
}
public IActionResult GenerateWorksInRequest()
{
_customer.GenerateWorksInRequest();
return Redirect("~/Home/Index");
}
public IActionResult GeneratePayments()
{
_customer.GeneratePayments();
return Redirect("~/Home/Index");
}
/// <summary>
/// Вывод ошибок
/// </summary>

View File

@ -34,6 +34,14 @@ builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
builder.Services.AddTransient<ICustomerRoleImitationLogic, CustomerRoleImitationLogic>();
builder.Services.AddTransient<ICustomerLogic, CustomerLogic>();
builder.Services.AddTransient<ICustomerStorage, CustomerStorage>();
builder.Services.AddTransient<IVehicleLogic, VehicleLogic>();
builder.Services.AddTransient<IVehicleStorage, VehicleStorage>();
builder.Services.AddTransient<IWorkPaymentLogic, WorkPaymentLogic>();
var app = builder.Build();
// Configure the HTTP request pipeline.

View File

@ -1,6 +1,6 @@
@using CarServiceContracts.BindingModels
@model MailSendInfoBindingModel
<form method="post">
<center><input name="MailAddress" type="text" value="affh" /></center>
<center><input name="MailAddress" type="text" value="" /></center>
<div><center><input type="submit" class="btn btn-primary" value="Отправить на почту" /></center></div>
</form>

View File

@ -34,6 +34,15 @@
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="GenerateRequestData">+Пользователи</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="GenerateWorksInRequest">+Привязка работ</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="GeneratePayments">+Оплаты</a>
</li>
</ul>
</div>
</div>

View File

@ -0,0 +1,5 @@
igor_melnikov,12345,Игорь,Мельников
alexander_zhukov,12345,Александр,Жуков
ivanov_sergey,12345,Иванов,Сергей
alexeev_alexey,12345,Алексеев,Алексей
petrov_petr,12345,Петров,Петр

View File

@ -0,0 +1,7 @@
2023-01-02,1
2023-04-05,2
2023-04-06,2
2023-04-07,3
2023-04-07,4
2023-04-07,5
2023-04-08,6

View File

@ -0,0 +1,6 @@
ВАЗ-2110,К417ЕН73,XTA21102010263437,1
ВАЗ-2110,А269СХ74,XTA21104566787899,2
Peugeot Partner,С567ЕК34,32557585768,3
ВАЗ ОКА,Е456НН73,56672357567,4
ВАЗ-2101,В076НК73,34658685432,4
Renault Logan,У324РВ73,3236859874576,5