Сreate work
This commit is contained in:
parent
4b81de1b6c
commit
f468ca7603
@ -55,7 +55,7 @@ namespace ServiceStationBusinessLogic.BusinessLogic {
|
|||||||
if (model == null) {
|
if (model == null) {
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation($"ReadElement.Id:{model.Id}.login:{model.Login}");
|
_logger.LogInformation($"ReadElement.Id:{model.Id}.login:{model.fio}");
|
||||||
var element = _storage.GetElement(model);
|
var element = _storage.GetElement(model);
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
_logger.LogWarning("ReadElement.Element not fount");
|
_logger.LogWarning("ReadElement.Element not fount");
|
||||||
@ -83,22 +83,11 @@ namespace ServiceStationBusinessLogic.BusinessLogic {
|
|||||||
if (!withParams) {
|
if (!withParams) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.FIO)) {
|
if (string.IsNullOrEmpty(model.FIO)) {
|
||||||
throw new ArgumentNullException("Нет ФИО клиента", nameof(model.FIO));
|
throw new ArgumentNullException("Нет ФИО клиента", nameof(model.FIO));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Password)) {
|
|
||||||
throw new ArgumentNullException("Нет пароля пользователя", nameof(model.Password));
|
_logger.LogInformation($"Client.Id:{model.Id}.FIO:{model.FIO}.TotalPoints:{model.TotalPoints}");
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.Login)) {
|
|
||||||
throw new ArgumentNullException("Нет номера телефона пользователя", nameof(model.Login));
|
|
||||||
}
|
|
||||||
_logger.LogInformation($"Client.Id:{model.Id}.FIO:{model.FIO}.Password:{model.Password}.Login:{model.Login}");
|
|
||||||
|
|
||||||
var element = _storage.GetElement(new ClientSearchModel { Login = model.Login});
|
|
||||||
if (element != null && element.Id != model.Id) {
|
|
||||||
throw new InvalidOperationException("Такой логин пользователя уже есть");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ namespace ServiceStationContracts.BindingModels
|
|||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string FIO { get; set; } = string.Empty;
|
public string FIO { get; set; } = string.Empty;
|
||||||
public string Password { get; set; } = string.Empty;
|
public int TotalPoints { get; set; }
|
||||||
public string Login { get; set; } = string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,6 @@ namespace ServiceStationContracts.BindingModels {
|
|||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
}
|
public double Price { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@ namespace ServiceStationContracts.BindingModels {
|
|||||||
|
|
||||||
public int TaskId { get; set; }
|
public int TaskId { get; set; }
|
||||||
|
|
||||||
public string client_ids { get; set; } = string.Empty;
|
public int[] client_ids { get; set; } = new int[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
public class ClientSearchModel
|
public class ClientSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? Login { get; set; }
|
public string? fio { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,7 @@ namespace ServiceStationContracts.ViewModels
|
|||||||
[DisplayName("ФИО")]
|
[DisplayName("ФИО")]
|
||||||
public string FIO { get; set; } = string.Empty;
|
public string FIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Пароль")]
|
[DisplayName("Всего баллов")]
|
||||||
public string Password { get; set; } = string.Empty;
|
public int TotalPoints { get; set; }
|
||||||
|
|
||||||
[DisplayName("Логин пользователя")]
|
|
||||||
public string Login { get; set; } = string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,8 @@ namespace ServiceStationContracts.ViewModels
|
|||||||
|
|
||||||
[DisplayName("Наименование задачи")]
|
[DisplayName("Наименование задачи")]
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
}
|
|
||||||
|
[DisplayName("Стоимость задачи")]
|
||||||
|
public double Price { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
@ -18,6 +18,9 @@ namespace ServiceStationContracts.ViewModels
|
|||||||
|
|
||||||
public int TaskId { get; set; }
|
public int TaskId { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Задача")]
|
||||||
|
public string TaskName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public Dictionary<int, IClientModel> ClientList { get; set; } = new();
|
public Dictionary<int, IClientModel> ClientList { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ namespace ServiceStationDataModels.Models
|
|||||||
public interface IClientModel : IId
|
public interface IClientModel : IId
|
||||||
{
|
{
|
||||||
string FIO { get; }
|
string FIO { get; }
|
||||||
string Password { get; }
|
int TotalPoints { get; }
|
||||||
string Login { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,6 @@ namespace ServiceStationDataModels.Models
|
|||||||
public interface ITaskModel : IId
|
public interface ITaskModel : IId
|
||||||
{
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
|
double Price { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,9 @@ namespace ServiceSourceClientApp.Controllers {
|
|||||||
if (APIClient.executor == null) {
|
if (APIClient.executor == null) {
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
return View();
|
|
||||||
|
var view = APIClient.GetRequest<List<WorkViewModel>>($"api/Main/GetWorks?_executorId={APIClient.executor.Id}");
|
||||||
|
return View(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -92,5 +94,31 @@ namespace ServiceSourceClientApp.Controllers {
|
|||||||
public IActionResult Error() {
|
public IActionResult Error() {
|
||||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreateWork() {
|
||||||
|
ViewBag.Tasks = APIClient.GetRequest<List<TaskViewModel>>($"api/Main/GetTasks?");
|
||||||
|
return View(APIClient.GetRequest<List<ClientViewModel>>($"api/Main/GetClients?"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateWork(int[] ids, int task) {
|
||||||
|
if (APIClient.executor == null) {
|
||||||
|
Response.Redirect("~/Home/Enter");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/Main/CreateWork", new WorkFromWebBindingModel {
|
||||||
|
Price = Calc(task, ids.Length),
|
||||||
|
ExecutorId = APIClient.executor.Id,
|
||||||
|
TaskId = task,
|
||||||
|
client_ids = ids
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public double Calc(int task, int count) {
|
||||||
|
var task_info = APIClient.GetRequest<TaskViewModel>($"api/Main/GetTask?_taskId={task}") ?? throw new Exception("Îøèáêà ïîëó÷åèÿ äàííûõ");
|
||||||
|
return task_info.Price + 700 * count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,145 @@
|
|||||||
@{
|
@using ServiceStationContracts.ViewModels
|
||||||
ViewData["Title"] = "Create";
|
@{
|
||||||
|
ViewData["Title"] = "CreateWork";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@model List<ClientViewModel>
|
||||||
|
|
||||||
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Создание работы</h2>
|
<h2 class="display-4">Создать работу</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Товар:</div>
|
<div class="col-4">Задача:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.Products,"ID"))"></select>
|
<select id="task" name="task" class="form-control" asp-items="@(new SelectList(ViewBag.Tasks, "Id", "Name"))"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Сумма:</div>
|
<div class="col-4">Стоимость:</div>
|
||||||
<div class="col-8"><input type="text" id="Price" name="Price" readonly /></div>
|
<div class="col-8">
|
||||||
|
<input id="price" type="text" name="price" readonly />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
</form>
|
||||||
<div class="col-4">Сумма:</div>
|
|
||||||
<div class="col-8"><input type="text" id="Category" name="Category" readonly /></div>
|
<div class="text-center">
|
||||||
</div>
|
<h2 class="display-5">Выбрать клиентов в работу</h2>
|
||||||
<div class="row">
|
</div>
|
||||||
<div class="col-8"></div>
|
|
||||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
<div class="text-center">
|
||||||
</div>
|
@{
|
||||||
</form>
|
if (Model == null) {
|
||||||
|
<h3 class="display-4">Авторизируйтесь</h3>
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
<div class="text-end">
|
||||||
|
<button class="btn btn-outline-primary" id="btnCreate">Создать</button>
|
||||||
|
</div>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Номер клиента
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
ФИО клиента
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<input type="checkbox" class="form-check-input" id="Select_all" name="Select_all" /> Выбрать все
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model) {
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayFor(modelItem => item.Id)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayFor(modelItem => item.FIO)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<input type="checkbox" class="form-check-input" id="Select_rec" name="Select_rec" value="@item.Id" />
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$('#task').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
$('.form-check-input').on('change', function () {
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
|
||||||
|
check();
|
||||||
|
|
||||||
|
function check() {
|
||||||
|
debugger
|
||||||
|
var task = $('#task').val();
|
||||||
|
let checkboxes = document.getElementsByTagName('input');
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
|
$("input[name='Select_rec']:checked").each(function () {
|
||||||
|
count++;
|
||||||
|
});
|
||||||
|
if (task && count >= 0) {
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/Home/Calc',
|
||||||
|
data: {task: task, count: count},
|
||||||
|
success: function (result) {
|
||||||
|
$('#price').val(result)
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#Select_all').on('click', function () {
|
||||||
|
let checkboxes = document.getElementsByTagName('input');
|
||||||
|
let val = null;
|
||||||
|
|
||||||
|
for (var i = 0; i < checkboxes.length; i++) {
|
||||||
|
if (checkboxes[i].type === 'checkbox') {
|
||||||
|
if (val == null) {
|
||||||
|
val = checkboxes[i].checked;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
checkboxes[i].checked = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
check();
|
||||||
|
|
||||||
|
});
|
||||||
|
$('#btnCreate').on('click', function () {
|
||||||
|
let val = [];
|
||||||
|
var task = $('#task').val();
|
||||||
|
|
||||||
|
$("input[name='Select_rec']:checked").each(function () {
|
||||||
|
val.push($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '/Home/CreateWork',
|
||||||
|
data: {'ids':val, 'task': task},
|
||||||
|
success: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
@ -1,40 +1,65 @@
|
|||||||
@{
|
@using ServiceStationContracts.ViewModels
|
||||||
|
@{
|
||||||
ViewData["Title"] = "Home Page";
|
ViewData["Title"] = "Home Page";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@model List<WorkViewModel>
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h1 class="display-4">Список работ</h1>
|
<h1 class="display-4">Список работ</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
@{
|
@{
|
||||||
if (Model == null) {
|
if (Model == null) {
|
||||||
<h3 class="display-4">Авторизируйтесь</h3>
|
<h3 class="display-4">Авторизируйтесь</h3>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
<p>
|
|
||||||
<a asp-action="Create">Список работ</a>
|
<p>
|
||||||
</p>
|
<a asp-action="CreateWork">Создать работу</a>
|
||||||
<table class="table">
|
</p>
|
||||||
<thead>
|
<table class="table">
|
||||||
<tr>
|
<thead>
|
||||||
<th>
|
<tr>
|
||||||
Номер
|
<th>
|
||||||
</th>
|
Номер
|
||||||
<th>
|
</th>
|
||||||
Дата начала
|
<th>
|
||||||
</th>
|
Дата работы
|
||||||
<th>
|
</th>
|
||||||
Цена
|
<th>
|
||||||
</th>
|
Стоимость работы
|
||||||
<th>
|
</th>
|
||||||
Статус
|
<th>
|
||||||
</th>
|
Номер задания
|
||||||
</tr>
|
</th>
|
||||||
</thead>
|
<th>
|
||||||
<tbody>
|
Задания
|
||||||
</tbody>
|
</th>
|
||||||
</table>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model) {
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayFor(modelItem => item.Id)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayFor(modelItem => item.Date)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayFor(modelItem => item.Price)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayFor(modelItem => item.TaskId)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayFor(modelItem => item.TaskName)
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
@ -82,12 +82,10 @@ namespace ServiceStationRestAPI.Controllers {
|
|||||||
ClientList = new()
|
ClientList = new()
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (char id in model.client_ids) {
|
foreach (int id in model.client_ids) {
|
||||||
if (int.TryParse(id.ToString(), out int _id)) {
|
var client = _clientLogic.ReadElement(new ClientSearchModel { Id = id }) ?? throw new Exception("Ошибка получения данных");
|
||||||
var client = _clientLogic.ReadElement(new ClientSearchModel { Id = _id }) ?? throw new Exception("Ошибка получения данных");
|
record.ClientList.Add(client.Id, (client));
|
||||||
record.ClientList.Add(client.Id, (client));
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +147,17 @@ namespace ServiceStationRestAPI.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateTask(TaskBindingModel model) {
|
||||||
|
try {
|
||||||
|
_taskLogic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, $"Ошибка создания задачи");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<TaskViewModel>? GetTasks() {
|
public List<TaskViewModel>? GetTasks() {
|
||||||
try {
|
try {
|
||||||
@ -160,6 +169,29 @@ namespace ServiceStationRestAPI.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public TaskViewModel? GetTask (int _taskId) {
|
||||||
|
try {
|
||||||
|
return _taskLogic.ReadElement(new TaskSearchModel { Id = _taskId });
|
||||||
|
}
|
||||||
|
catch(Exception ex) {
|
||||||
|
_logger.LogError(ex, "Ошибка получения задачи");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateClient(ClientBindingModel model) {
|
||||||
|
try {
|
||||||
|
_clientLogic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, $"Ошибка добавление клиента");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<ClientViewModel>? GetClients() {
|
public List<ClientViewModel>? GetClients() {
|
||||||
try {
|
try {
|
||||||
|
@ -56,7 +56,7 @@ namespace ServiceStationsDataBaseImplement.Implements
|
|||||||
else {
|
else {
|
||||||
return context.Clients
|
return context.Clients
|
||||||
.Include(x => x.WorkClients)
|
.Include(x => x.WorkClients)
|
||||||
.FirstOrDefault(x => x.Login == model.Login)
|
.FirstOrDefault(x => x.FIO == model.fio)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ namespace ServiceStationsDataBaseImplement.Implements
|
|||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
if (model.Id.HasValue) {
|
if (model.Id.HasValue) {
|
||||||
return context.Works
|
return context.Works
|
||||||
|
.Include(x => x._task)
|
||||||
.Include(x => x.WorkClients)
|
.Include(x => x.WorkClients)
|
||||||
.ThenInclude(x => x._work)
|
.ThenInclude(x => x._work)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
@ -74,13 +75,15 @@ namespace ServiceStationsDataBaseImplement.Implements
|
|||||||
}
|
}
|
||||||
else if (model.ExecutorId.HasValue) {
|
else if (model.ExecutorId.HasValue) {
|
||||||
return context.Works
|
return context.Works
|
||||||
.Include(x => x.WorkClients)
|
.Include(x => x._task)
|
||||||
|
.Include(x => x.WorkClients)
|
||||||
.ThenInclude(x => x._work)
|
.ThenInclude(x => x._work)
|
||||||
.FirstOrDefault(x => x.ExecutorId == model.ExecutorId)
|
.FirstOrDefault(x => x.ExecutorId == model.ExecutorId)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
return context.Works
|
return context.Works
|
||||||
.Include(x => x.WorkClients)
|
.Include(x => x._task)
|
||||||
|
.Include(x => x.WorkClients)
|
||||||
.ThenInclude(x => x._work)
|
.ThenInclude(x => x._work)
|
||||||
.FirstOrDefault(x => x.TaskId == model.TaskId)
|
.FirstOrDefault(x => x.TaskId == model.TaskId)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
@ -91,23 +94,27 @@ namespace ServiceStationsDataBaseImplement.Implements
|
|||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
if (model.DateFrom.HasValue && model.DateTo.HasValue) {
|
if (model.DateFrom.HasValue && model.DateTo.HasValue) {
|
||||||
return context.Works
|
return context.Works
|
||||||
.Include(x => x.WorkClients)
|
.Include(x => x._task)
|
||||||
.ThenInclude(x => x._work)
|
.Include(x => x.WorkClients)
|
||||||
|
.ThenInclude(x => x._client)
|
||||||
.Where(x => x.Date >= model.DateFrom && x.Date <= model.DateTo)
|
.Where(x => x.Date >= model.DateFrom && x.Date <= model.DateTo)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
else if (model.ExecutorId.HasValue) {
|
else if (model.ExecutorId.HasValue) {
|
||||||
return context.Works
|
return context.Works
|
||||||
.Include(x => x.WorkClients)
|
.Include(x => x._task)
|
||||||
.ThenInclude(x => x._work)
|
.Include(x => x.WorkClients)
|
||||||
.Where(x => x.ExecutorId == model.ExecutorId)
|
.ThenInclude(x => x._client)
|
||||||
|
.Where(x => x.ExecutorId == model.ExecutorId)
|
||||||
|
.ToList()
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
return context.Works
|
return context.Works
|
||||||
.Include(x => x.WorkClients)
|
.Include(x => x._task)
|
||||||
.ThenInclude(x => x._work)
|
.Include(x => x.WorkClients)
|
||||||
|
.ThenInclude(x => x._client)
|
||||||
.Where(x => x.TaskId == model.TaskId)
|
.Where(x => x.TaskId == model.TaskId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -117,8 +124,9 @@ namespace ServiceStationsDataBaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
return context.Works
|
return context.Works
|
||||||
.Include(x => x.WorkClients)
|
.Include(x => x._task)
|
||||||
.ThenInclude(x => x._work)
|
.Include(x => x.WorkClients)
|
||||||
|
.ThenInclude(x => x._client)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
204
ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240822072626_Migration02.Designer.cs
generated
Normal file
204
ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240822072626_Migration02.Designer.cs
generated
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using ServiceStationsDataBaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ServiceStationsDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Database))]
|
||||||
|
[Migration("20240822072626_Migration02")]
|
||||||
|
partial class Migration02
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.18")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("FIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Login")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("FIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Executors");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.TaskByWork", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Tasks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("ExecutorId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<int>("TaskId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("_taskId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ExecutorId");
|
||||||
|
|
||||||
|
b.HasIndex("_taskId");
|
||||||
|
|
||||||
|
b.ToTable("Works");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PointCount")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("WorkId");
|
||||||
|
|
||||||
|
b.ToTable("WorksClients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Executor", null)
|
||||||
|
.WithMany("Works")
|
||||||
|
.HasForeignKey("ExecutorId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.TaskByWork", "_task")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("_taskId");
|
||||||
|
|
||||||
|
b.Navigation("_task");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Client", "_client")
|
||||||
|
.WithMany("WorkClients")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Work", "_work")
|
||||||
|
.WithMany("WorkClients")
|
||||||
|
.HasForeignKey("WorkId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("_client");
|
||||||
|
|
||||||
|
b.Navigation("_work");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("WorkClients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Works");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("WorkClients");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ServiceStationsDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migration02 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "_taskId",
|
||||||
|
table: "Works",
|
||||||
|
type: "int",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Works__taskId",
|
||||||
|
table: "Works",
|
||||||
|
column: "_taskId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Works_Tasks__taskId",
|
||||||
|
table: "Works",
|
||||||
|
column: "_taskId",
|
||||||
|
principalTable: "Tasks",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Works_Tasks__taskId",
|
||||||
|
table: "Works");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Works__taskId",
|
||||||
|
table: "Works");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "_taskId",
|
||||||
|
table: "Works");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
202
ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240822081747_Migration03.Designer.cs
generated
Normal file
202
ServiceStation/ServiceStationsDataBaseImplement/Migrations/20240822081747_Migration03.Designer.cs
generated
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using ServiceStationsDataBaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ServiceStationsDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Database))]
|
||||||
|
[Migration("20240822081747_Migration03")]
|
||||||
|
partial class Migration03
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.18")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("FIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("TotalPoints")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("FIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Executors");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.TaskByWork", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Tasks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("ExecutorId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<int>("TaskId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("_taskId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ExecutorId");
|
||||||
|
|
||||||
|
b.HasIndex("_taskId");
|
||||||
|
|
||||||
|
b.ToTable("Works");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PointCount")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("WorkId");
|
||||||
|
|
||||||
|
b.ToTable("WorksClients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Executor", null)
|
||||||
|
.WithMany("Works")
|
||||||
|
.HasForeignKey("ExecutorId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.TaskByWork", "_task")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("_taskId");
|
||||||
|
|
||||||
|
b.Navigation("_task");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Client", "_client")
|
||||||
|
.WithMany("WorkClients")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.Work", "_work")
|
||||||
|
.WithMany("WorkClients")
|
||||||
|
.HasForeignKey("WorkId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("_client");
|
||||||
|
|
||||||
|
b.Navigation("_work");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("WorkClients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Works");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("WorkClients");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ServiceStationsDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migration03 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Login",
|
||||||
|
table: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Password",
|
||||||
|
table: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<double>(
|
||||||
|
name: "Price",
|
||||||
|
table: "Tasks",
|
||||||
|
type: "float",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0.0);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "TotalPoints",
|
||||||
|
table: "Clients",
|
||||||
|
type: "int",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Price",
|
||||||
|
table: "Tasks");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TotalPoints",
|
||||||
|
table: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Login",
|
||||||
|
table: "Clients",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Password",
|
||||||
|
table: "Clients",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -34,17 +34,12 @@ namespace ServiceStationsDataBaseImplement.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
b.Property<string>("Login")
|
b.Property<int>("TotalPoints")
|
||||||
.IsRequired()
|
.HasColumnType("int");
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<string>("Password")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Clients");
|
b.ToTable("Clients", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b =>
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Executor", b =>
|
||||||
@ -69,7 +64,7 @@ namespace ServiceStationsDataBaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Executors");
|
b.ToTable("Executors", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.TaskByWork", b =>
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.TaskByWork", b =>
|
||||||
@ -84,9 +79,12 @@ namespace ServiceStationsDataBaseImplement.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("Tasks");
|
b.ToTable("Tasks", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
@ -109,11 +107,16 @@ namespace ServiceStationsDataBaseImplement.Migrations
|
|||||||
b.Property<int>("TaskId")
|
b.Property<int>("TaskId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("_taskId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("ExecutorId");
|
b.HasIndex("ExecutorId");
|
||||||
|
|
||||||
b.ToTable("Works");
|
b.HasIndex("_taskId");
|
||||||
|
|
||||||
|
b.ToTable("Works", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
||||||
@ -139,7 +142,7 @@ namespace ServiceStationsDataBaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("WorkId");
|
b.HasIndex("WorkId");
|
||||||
|
|
||||||
b.ToTable("WorksClients");
|
b.ToTable("WorksClients", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.Work", b =>
|
||||||
@ -149,6 +152,12 @@ namespace ServiceStationsDataBaseImplement.Migrations
|
|||||||
.HasForeignKey("ExecutorId")
|
.HasForeignKey("ExecutorId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("ServiceStationsDataBaseImplement.Models.TaskByWork", "_task")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("_taskId");
|
||||||
|
|
||||||
|
b.Navigation("_task");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
modelBuilder.Entity("ServiceStationsDataBaseImplement.Models.WorkClient", b =>
|
||||||
|
@ -18,11 +18,7 @@ namespace ServiceStationsDataBaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public string FIO { get; set; } = string.Empty;
|
public string FIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
public int TotalPoints { get; set; }
|
||||||
public string Password { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public string Login { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
[ForeignKey("ClientId")]
|
[ForeignKey("ClientId")]
|
||||||
public virtual List<WorkClient> WorkClients { get; set; } = new();
|
public virtual List<WorkClient> WorkClients { get; set; } = new();
|
||||||
@ -34,8 +30,7 @@ namespace ServiceStationsDataBaseImplement.Models
|
|||||||
return new Client() {
|
return new Client() {
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
FIO = model.FIO,
|
FIO = model.FIO,
|
||||||
Password = model.Password,
|
TotalPoints = model.TotalPoints,
|
||||||
Login = model.Login
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,15 +39,13 @@ namespace ServiceStationsDataBaseImplement.Models
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FIO = model.FIO;
|
FIO = model.FIO;
|
||||||
Login = model.Login;
|
TotalPoints = model.TotalPoints;
|
||||||
Password = model.Password;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel GetViewModel => new() {
|
public ClientViewModel GetViewModel => new() {
|
||||||
Id = Id,
|
Id = Id,
|
||||||
FIO = FIO,
|
FIO = FIO,
|
||||||
Password = Password,
|
TotalPoints = TotalPoints
|
||||||
Login = Login
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,17 @@ namespace ServiceStationsDataBaseImplement.Models {
|
|||||||
[Required]
|
[Required]
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public double Price { get; set; }
|
||||||
|
|
||||||
public static TaskByWork? Create(TaskBindingModel? model) {
|
public static TaskByWork? Create(TaskBindingModel? model) {
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new TaskByWork() {
|
return new TaskByWork() {
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
Name = model.Name
|
Name = model.Name,
|
||||||
|
Price = model.Price,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +38,9 @@ namespace ServiceStationsDataBaseImplement.Models {
|
|||||||
|
|
||||||
public TaskViewModel GetViewModel => new() {
|
public TaskViewModel GetViewModel => new() {
|
||||||
Id = Id,
|
Id = Id,
|
||||||
Name = Name
|
Name = Name,
|
||||||
|
Price = Price,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ServiceStationsDataBaseImplement.Models
|
namespace ServiceStationsDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
@ -28,6 +27,7 @@ namespace ServiceStationsDataBaseImplement.Models
|
|||||||
[ForeignKey("TaskId")]
|
[ForeignKey("TaskId")]
|
||||||
public int TaskId { get; set; }
|
public int TaskId { get; set; }
|
||||||
|
|
||||||
|
public virtual TaskByWork? _task { get; set; }
|
||||||
|
|
||||||
[ForeignKey("WorkId")]
|
[ForeignKey("WorkId")]
|
||||||
public virtual List<WorkClient> WorkClients { get; set; } = new();
|
public virtual List<WorkClient> WorkClients { get; set; } = new();
|
||||||
@ -39,7 +39,7 @@ namespace ServiceStationsDataBaseImplement.Models
|
|||||||
public Dictionary<int, IClientModel> ClientList {
|
public Dictionary<int, IClientModel> ClientList {
|
||||||
get {
|
get {
|
||||||
if (_clientList == null) {
|
if (_clientList == null) {
|
||||||
_clientList = WorkClients.ToDictionary(recWC => recWC.WorkId, recWC => recWC._client as IClientModel);
|
_clientList = WorkClients.ToDictionary(recWC => recWC.ClientId, recWC => recWC._client as IClientModel);
|
||||||
}
|
}
|
||||||
return _clientList;
|
return _clientList;
|
||||||
}
|
}
|
||||||
@ -56,7 +56,8 @@ namespace ServiceStationsDataBaseImplement.Models
|
|||||||
ExecutorId = model.ExecutorId,
|
ExecutorId = model.ExecutorId,
|
||||||
TaskId = model.TaskId,
|
TaskId = model.TaskId,
|
||||||
WorkClients = model.ClientList.Select(x => new WorkClient {
|
WorkClients = model.ClientList.Select(x => new WorkClient {
|
||||||
_work = context.Works.First(y => y.Id == x.Key)
|
_client = context.Clients.First(y => y.Id == x.Key),
|
||||||
|
PointCount = 0
|
||||||
}).ToList()
|
}).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -74,7 +75,8 @@ namespace ServiceStationsDataBaseImplement.Models
|
|||||||
Price = Price,
|
Price = Price,
|
||||||
ExecutorId = ExecutorId,
|
ExecutorId = ExecutorId,
|
||||||
TaskId = TaskId,
|
TaskId = TaskId,
|
||||||
ClientList = ClientList
|
ClientList = ClientList,
|
||||||
|
TaskName = _task?.Name ?? string.Empty
|
||||||
};
|
};
|
||||||
|
|
||||||
public void UpdateClients(Database context, WorkBindingModel model) {
|
public void UpdateClients(Database context, WorkBindingModel model) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user