2024-04-30 02:44:02 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2024-05-27 01:47:37 +04:00
|
|
|
|
using ServiceStationContracts.BindingModels;
|
|
|
|
|
using ServiceStationContracts.SearchModels;
|
2024-04-30 02:44:02 +04:00
|
|
|
|
using ServiceStationContracts.ViewModels;
|
|
|
|
|
using ServiceStationExecutorApp.Models;
|
2024-04-30 14:59:16 +04:00
|
|
|
|
using System.Collections.Generic;
|
2024-04-30 02:44:02 +04:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace ServiceStationExecutorApp.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
|
|
|
|
|
|
public HomeController(ILogger<HomeController> logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Privacy()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if(APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIExecutor.Executor);
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Privacy(string email, string fio, string number, string password)
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(number) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введены не все данные");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/executor/updateexecutor", new ExecutorBindingModel
|
|
|
|
|
{
|
|
|
|
|
ExecutorEmail = email,
|
|
|
|
|
ExecutorNumber = number,
|
|
|
|
|
ExecutorFIO = fio,
|
|
|
|
|
ExecutorPassword = password,
|
|
|
|
|
Id = APIExecutor.Executor.Id
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("Index");
|
2024-04-30 02:44:02 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Enter()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Enter(string executorNumber, string password)
|
|
|
|
|
{
|
|
|
|
|
if(string.IsNullOrEmpty(executorNumber) || string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Не хватает пароля или номера.");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.Executor = APIExecutor.GetRequest<ExecutorViewModel>($"api/executor/login?executorNumber={executorNumber}&password={password}");
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Неверный логин/пароль");
|
|
|
|
|
}
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
2024-04-30 02:44:02 +04:00
|
|
|
|
public IActionResult Register()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Register(string fio, string executorNumber, string password, string email)
|
2024-04-30 02:44:02 +04:00
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if(string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(executorNumber) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
|
2024-04-30 02:44:02 +04:00
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
throw new Exception("Введены не все данные");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/executor/register", new ExecutorBindingModel
|
|
|
|
|
{
|
|
|
|
|
ExecutorNumber = executorNumber,
|
|
|
|
|
ExecutorEmail = email,
|
|
|
|
|
ExecutorFIO = fio,
|
|
|
|
|
ExecutorPassword = password
|
2024-04-30 02:44:02 +04:00
|
|
|
|
});
|
2024-05-27 01:47:37 +04:00
|
|
|
|
Response.Redirect("Enter");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
public IActionResult ListCars()
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIExecutor.GetRequest<List<CarViewModel>>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}"));
|
2024-04-30 02:44:02 +04:00
|
|
|
|
}
|
|
|
|
|
public IActionResult ListDefects()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
2024-04-30 02:44:02 +04:00
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIExecutor.GetRequest<List<DefectViewModel>>($"api/main/getdefectlist?executorId={APIExecutor.Executor.Id}"));
|
2024-04-30 02:44:02 +04:00
|
|
|
|
}
|
2024-04-30 16:28:34 +04:00
|
|
|
|
public IActionResult ListTechnicalWorks()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
2024-04-30 16:28:34 +04:00
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIExecutor.GetRequest<List<TechnicalWorkViewModel>>($"api/main/gettechnicalworklist?executorId={APIExecutor.Executor.Id}"));
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public Tuple<DefectViewModel, string>? GetDefect(int defectId)
|
|
|
|
|
{
|
|
|
|
|
if(APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
var result = APIExecutor.GetRequest<Tuple<DefectViewModel, List<Tuple<string, string>>>>($"api/main/getdefect?defectId={defectId}");
|
|
|
|
|
if (result == null) return default;
|
|
|
|
|
string table = "";
|
|
|
|
|
for(int i = 0; i < result.Item2.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var carNumber = result.Item2[i].Item1;
|
|
|
|
|
var carBrand = result.Item2[i].Item2;
|
|
|
|
|
table += "<tr>";
|
|
|
|
|
table += $"<td>{carNumber}</td>";
|
|
|
|
|
table += $"<td>{carBrand}</td>";
|
|
|
|
|
table += "</tr>";
|
|
|
|
|
}
|
|
|
|
|
return Tuple.Create(result.Item1, table);
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public Tuple<TechnicalWorkViewModel, string>? GetTechnicalWork(int technicalWorkId)
|
|
|
|
|
{
|
|
|
|
|
if(APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
var result = APIExecutor.GetRequest<Tuple<TechnicalWorkViewModel, List<Tuple<string, string>>>>($"api/main/gettechnicalwork?technicalworkId={technicalWorkId}");
|
|
|
|
|
if (result == null) return default;
|
|
|
|
|
string table = "";
|
|
|
|
|
for(int i = 0;i<result.Item2.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var carNumber = result.Item2[i].Item1;
|
|
|
|
|
var carBrand = result.Item2[i].Item2;
|
|
|
|
|
table += "<tr>";
|
|
|
|
|
table += $"<td>{carNumber}</td>";
|
|
|
|
|
table += $"<td>{carBrand}</td>";
|
|
|
|
|
table += "</tr>";
|
|
|
|
|
}
|
|
|
|
|
return Tuple.Create(result.Item1, table);
|
2024-04-30 16:28:34 +04:00
|
|
|
|
}
|
2024-04-30 02:44:02 +04:00
|
|
|
|
public IActionResult DeleteCar()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Cars = APIExecutor.GetRequest<List<CarViewModel>>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}");
|
2024-04-30 02:44:02 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteCar(int car)
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/deletecar", new CarBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = car
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListCars");
|
|
|
|
|
}
|
2024-04-30 02:44:02 +04:00
|
|
|
|
public IActionResult DeleteDefect()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Defects = APIExecutor.GetRequest<List<DefectViewModel>>($"api/main/getdefectlist?executorId={APIExecutor.Executor.Id}");
|
2024-04-30 02:44:02 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteDefect(int defect)
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/deletedefect", new DefectBindingModel { Id = defect });
|
|
|
|
|
Response.Redirect("ListDefects");
|
|
|
|
|
}
|
2024-04-30 16:28:34 +04:00
|
|
|
|
public IActionResult DeleteTechnicalWork()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.TechnicalWorks = APIExecutor.GetRequest<List<TechnicalWorkViewModel>>($"api/main/gettechnicalworklist?executorId={APIExecutor.Executor.Id}");
|
2024-04-30 16:28:34 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteTechnicalWork(int technicalWork)
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/deletetechnicalwork", new TechnicalWorkBindingModel { Id = technicalWork });
|
|
|
|
|
Response.Redirect("ListTechnicalWorks");
|
|
|
|
|
}
|
2024-04-30 02:44:02 +04:00
|
|
|
|
public IActionResult UpdateCar()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Cars = APIExecutor.GetRequest<List<CarViewModel>>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}");
|
2024-04-30 02:44:02 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateCar(int car, string carNumber, string carBrand)
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(carNumber))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите номер машины");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(carBrand))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите бренд машины");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/updatecar", new CarBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = car,
|
|
|
|
|
CarNumber = carNumber,
|
|
|
|
|
CarBrand = carBrand,
|
|
|
|
|
ExecutorId = APIExecutor.Executor.Id
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListCars");
|
|
|
|
|
}
|
2024-04-30 14:59:16 +04:00
|
|
|
|
public IActionResult UpdateDefect()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Defects = APIExecutor.GetRequest<List<DefectViewModel>>($"api/main/getdefectlist?executorId={APIExecutor.Executor.Id}");
|
2024-04-30 14:59:16 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateDefect(int defect, string DefectType, double DefectPrice)
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(DefectType))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите тип неисправности");
|
|
|
|
|
}
|
|
|
|
|
if(DefectPrice < 100)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Минимальная цена неисправности 100");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/updatedefect", new DefectBindingModel
|
|
|
|
|
{
|
|
|
|
|
ExecutorId = APIExecutor.Executor.Id,
|
|
|
|
|
Id = defect,
|
|
|
|
|
DefectType = DefectType,
|
|
|
|
|
DefectPrice = DefectPrice
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListDefects");
|
|
|
|
|
}
|
2024-04-30 16:28:34 +04:00
|
|
|
|
public IActionResult UpdateTechnicalWork()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.TechnicalWorks = APIExecutor.GetRequest<List<TechnicalWorkViewModel>>($"api/main/gettechnicalworklist?executorId={APIExecutor.Executor.Id}");
|
2024-04-30 16:28:34 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateTechnicalWork(int technicalWork, string TechnicalWorkType, double TechnicalWorkPrice)
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(TechnicalWorkType))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите тип ТО");
|
|
|
|
|
}
|
|
|
|
|
if(TechnicalWorkPrice < 100)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Цена ТО должны быть больше 100");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/updatetechnicalwork", new TechnicalWorkBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = technicalWork,
|
|
|
|
|
WorkType = TechnicalWorkType,
|
|
|
|
|
ExecutorId = APIExecutor.Executor.Id,
|
|
|
|
|
WorkPrice = TechnicalWorkPrice,
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListTechnicalWorks");
|
|
|
|
|
}
|
2024-04-30 02:44:02 +04:00
|
|
|
|
public IActionResult CreateCar()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
2024-04-30 02:44:02 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateCar(string CarNumber, string CarBrand)
|
|
|
|
|
{
|
|
|
|
|
if(APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/createcar", new CarBindingModel
|
|
|
|
|
{
|
|
|
|
|
ExecutorId = APIExecutor.Executor.Id,
|
|
|
|
|
CarNumber = CarNumber,
|
|
|
|
|
CarBrand = CarBrand
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListCars");
|
|
|
|
|
}
|
2024-04-30 14:59:16 +04:00
|
|
|
|
public IActionResult CreateDefect()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
2024-04-30 14:59:16 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateDefect(string defectType, double defectPrice)
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/createdefect", new DefectBindingModel
|
|
|
|
|
{
|
|
|
|
|
ExecutorId = APIExecutor.Executor.Id,
|
|
|
|
|
DefectType = defectType,
|
|
|
|
|
DefectPrice = defectPrice
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListDefects");
|
|
|
|
|
}
|
2024-04-30 16:28:34 +04:00
|
|
|
|
public IActionResult CreateTechnicalWork()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
2024-04-30 16:28:34 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-27 01:47:37 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateTechnicalWork(string WorkType, double WorkPrice)
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/createtechnicalwork", new TechnicalWorkBindingModel
|
|
|
|
|
{
|
|
|
|
|
ExecutorId = APIExecutor.Executor.Id,
|
|
|
|
|
WorkType = WorkType,
|
|
|
|
|
WorkPrice = WorkPrice,
|
|
|
|
|
DateStartWork = DateTime.Now
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListTechnicalWorks");
|
|
|
|
|
}
|
2024-04-30 14:59:16 +04:00
|
|
|
|
public IActionResult AddCarToDefect()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
2024-04-30 14:59:16 +04:00
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(Tuple.Create(APIExecutor.GetRequest<List<DefectViewModel>>($"api/main/getdefectlist?executorId={APIExecutor.Executor.Id}"),
|
|
|
|
|
APIExecutor.GetRequest<List<CarViewModel>>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}")));
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void AddCarToDefect(int defect, int[] car)
|
|
|
|
|
{
|
|
|
|
|
if(APIExecutor.Executor == null)
|
2024-04-30 14:59:16 +04:00
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/addcartodefect", Tuple.Create(
|
|
|
|
|
new DefectSearchModel() { Id = defect },
|
|
|
|
|
car
|
|
|
|
|
));
|
|
|
|
|
Response.Redirect("ListDefects");
|
2024-04-30 14:59:16 +04:00
|
|
|
|
}
|
2024-04-30 16:28:34 +04:00
|
|
|
|
public IActionResult AddCarToTechnicalWork()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
2024-04-30 16:28:34 +04:00
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(Tuple.Create(APIExecutor.GetRequest<List<TechnicalWorkViewModel>>($"api/main/gettechnicalworklist?executorId={APIExecutor.Executor.Id}"),
|
|
|
|
|
APIExecutor.GetRequest<List<CarViewModel>>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}")));
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void AddCarToTechnicalWork(int technicalWork, int[] car)
|
|
|
|
|
{
|
|
|
|
|
if (APIExecutor.Executor == null)
|
2024-04-30 16:28:34 +04:00
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
throw new Exception("Авторизироваться не забыли?");
|
|
|
|
|
}
|
|
|
|
|
APIExecutor.PostRequest("api/main/addcartotechnicalwork", Tuple.Create(
|
|
|
|
|
new TechnicalWorkSearchModel() { Id = technicalWork },
|
|
|
|
|
car
|
|
|
|
|
));
|
|
|
|
|
Response.Redirect("ListTechnicalWorks");
|
2024-04-30 16:28:34 +04:00
|
|
|
|
}
|
2024-04-30 17:49:26 +04:00
|
|
|
|
public IActionResult BindingTechnicalWorkToWork()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
2024-04-30 17:49:26 +04:00
|
|
|
|
var technicalWork = new TechnicalWorkViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = 1,
|
|
|
|
|
WorkType = "type1",
|
|
|
|
|
WorkPrice = 1000.0,
|
|
|
|
|
DateStartWork = DateTime.Now,
|
|
|
|
|
ExecutorId = 1
|
|
|
|
|
};
|
|
|
|
|
var work = new WorkViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = 1,
|
|
|
|
|
WorkName = "work1",
|
|
|
|
|
WorkPrice = 1000.0,
|
|
|
|
|
Status = ServiceStationDataModels.Enums.WorkStatus.Принята
|
|
|
|
|
};
|
|
|
|
|
List<TechnicalWorkViewModel> technicalWorks = new List<TechnicalWorkViewModel>();
|
|
|
|
|
List <WorkViewModel> works = new List<WorkViewModel>();
|
|
|
|
|
technicalWorks.Add(technicalWork);
|
|
|
|
|
works.Add(work);
|
|
|
|
|
return View(Tuple.Create(technicalWorks, works));
|
|
|
|
|
}
|
|
|
|
|
public IActionResult ListWorkToFile()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
2024-04-30 17:49:26 +04:00
|
|
|
|
var car = new CarViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = 1,
|
|
|
|
|
CarNumber = "111",
|
|
|
|
|
CarBrand = "lamba"
|
|
|
|
|
};
|
|
|
|
|
var car2 = new CarViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
CarNumber = "121",
|
|
|
|
|
CarBrand = "lamba"
|
|
|
|
|
};
|
|
|
|
|
var car3 = new CarViewModel
|
|
|
|
|
{
|
|
|
|
|
Id = 3,
|
|
|
|
|
CarNumber = "131",
|
|
|
|
|
CarBrand = "lamba"
|
|
|
|
|
};
|
|
|
|
|
List<CarViewModel> cars = new List<CarViewModel>();
|
|
|
|
|
cars.Add(car);
|
|
|
|
|
cars.Add(car2);
|
|
|
|
|
cars.Add(car3);
|
|
|
|
|
return View(cars);
|
|
|
|
|
}
|
|
|
|
|
public IActionResult ListCarsToPdf()
|
|
|
|
|
{
|
2024-05-27 01:47:37 +04:00
|
|
|
|
if (APIExecutor.Executor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
2024-04-30 17:49:26 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-04-30 02:44:02 +04:00
|
|
|
|
|
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
|
|
|
public IActionResult Error()
|
|
|
|
|
{
|
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|