2024-04-30 20:36:13 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using ServiceStationContracts.BindingModels;
|
2024-05-27 23:35:42 +04:00
|
|
|
|
using ServiceStationContracts.SearchModels;
|
|
|
|
|
using ServiceStationContracts.ViewModels;
|
2024-04-30 20:36:13 +04:00
|
|
|
|
using ServiceStationGuarantorApp.Models;
|
|
|
|
|
using System.Diagnostics;
|
2024-05-27 23:35:42 +04:00
|
|
|
|
using System.Runtime.InteropServices.ComTypes;
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
|
|
|
|
namespace ServiceStationGuarantorApp.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 23:35:42 +04:00
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIGuarantor.Guarantor);
|
2024-04-30 20:36:13 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Privacy(string number, string email, string FIO, string password)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(number) || string.IsNullOrEmpty(FIO) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Вы ввели не все данные!");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/guarantor/updatedata", new GuarantorBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = APIGuarantor.Guarantor.Id,
|
|
|
|
|
GuarantorNumber = number,
|
|
|
|
|
GuarantorEmail = email,
|
|
|
|
|
GuarantorFIO = FIO,
|
|
|
|
|
GuarantorPassword = password,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
APIGuarantor.Guarantor.GuarantorNumber = number;
|
|
|
|
|
APIGuarantor.Guarantor.GuarantorEmail = email;
|
|
|
|
|
APIGuarantor.Guarantor.GuarantorFIO = FIO;
|
|
|
|
|
APIGuarantor.Guarantor.GuarantorPassword = password;
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
|
|
|
public IActionResult Error()
|
|
|
|
|
{
|
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Enter()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Enter(string number, string password)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(number) || string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Не хватает пароля или номера.");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.Guarantor = APIGuarantor.GetRequest<GuarantorViewModel>($"api/guarantor/login?guarantorNumber={number}&password={password}");
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Неверный логин/пароль");
|
|
|
|
|
}
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
|
|
|
|
public IActionResult Register()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Register(string FIO, string number, string password, string email)
|
2024-04-30 20:36:13 +04:00
|
|
|
|
{
|
2024-05-27 23:35:42 +04:00
|
|
|
|
if (string.IsNullOrEmpty(FIO) || string.IsNullOrEmpty(number) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введены не все данные");
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
APIGuarantor.PostRequest("api/guarantor/register", new GuarantorBindingModel
|
|
|
|
|
{
|
|
|
|
|
GuarantorNumber = number,
|
|
|
|
|
GuarantorEmail = email,
|
|
|
|
|
GuarantorFIO = FIO,
|
|
|
|
|
GuarantorPassword = password
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("Enter");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//......................................................... Запчасть..............................................................................
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
public IActionResult ListSpareParts()
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}"));
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
public IActionResult CreateSparePart()
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateSparePart(string SparePartName, double SparePartPrice)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/createsparepart", new SparePartBindingModel
|
|
|
|
|
{
|
|
|
|
|
GuarantorId = APIGuarantor.Guarantor.Id,
|
|
|
|
|
SparePartName = SparePartName,
|
|
|
|
|
SparePartPrice = SparePartPrice
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListSpareParts");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult UpdateSparePart()
|
|
|
|
|
{
|
|
|
|
|
ViewBag.SpareParts = new List<SparePartViewModel>();
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.SpareParts = APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateSparePart(int sparepart, string sparepartName, double sparepartPrice)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(sparepartName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите название запчасти");
|
|
|
|
|
}
|
|
|
|
|
if (sparepartPrice < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Цена запчасти не может быть меньше 0");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/updatesparepart", new SparePartBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = sparepart,
|
|
|
|
|
SparePartName = sparepartName,
|
|
|
|
|
SparePartPrice = sparepartPrice,
|
|
|
|
|
GuarantorId = APIGuarantor.Guarantor.Id
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListSpareParts");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult DeleteSparePart()
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.SpareParts = APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteSparePart(int sparepart)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/deletesparepart", new SparePartBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = sparepart
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListSpareParts");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//......................................................... Ремонт..............................................................................
|
|
|
|
|
|
|
|
|
|
public IActionResult ListRepairs()
|
2024-04-30 20:36:13 +04:00
|
|
|
|
{
|
2024-05-27 23:35:42 +04:00
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIGuarantor.GetRequest<List<RepairViewModel>>($"api/main/getrepairlist?guarantorId={APIGuarantor.Guarantor.Id}"));
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public Tuple<RepairViewModel, string>? GetRepair(int repairId)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
var result = APIGuarantor.GetRequest<Tuple<RepairViewModel, List<Tuple<string, string>>>>($"api/main/getrepair?repairId={repairId}");
|
|
|
|
|
if (result == null) return default;
|
|
|
|
|
string table = "";
|
|
|
|
|
for (int i = 0; i < result.Item2.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var sparepartName = result.Item2[i].Item1;
|
|
|
|
|
var sparepartPrice = result.Item2[i].Item2;
|
|
|
|
|
table += "<tr>";
|
|
|
|
|
table += $"<td>{sparepartName}</td>";
|
|
|
|
|
table += $"<td>{sparepartPrice}</td>";
|
|
|
|
|
table += "</tr>";
|
|
|
|
|
}
|
|
|
|
|
return Tuple.Create(result.Item1, table);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult CreateRepair()
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateRepair(string repairName, double repairPrice)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/createrepair", new RepairBindingModel
|
|
|
|
|
{
|
|
|
|
|
GuarantorId = APIGuarantor.Guarantor.Id,
|
|
|
|
|
RepairName = repairName,
|
|
|
|
|
RepairPrice = repairPrice
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListRepairs");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult UpdateRepair()
|
|
|
|
|
{
|
|
|
|
|
ViewBag.Repairs = new List<RepairViewModel>();
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Repairs = APIGuarantor.GetRequest<List<RepairViewModel>>($"api/main/getrepairlist?guarantorId={APIGuarantor.Guarantor.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateRepair(int repair, string RepairName, double RepairPrice)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(RepairName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите название ремонта");
|
|
|
|
|
}
|
|
|
|
|
if (RepairPrice < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Цена ремонта не может быть меньше 0");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/updaterepair", new RepairBindingModel
|
|
|
|
|
{
|
|
|
|
|
GuarantorId = APIGuarantor.Guarantor.Id,
|
|
|
|
|
Id = repair,
|
|
|
|
|
RepairName = RepairName,
|
|
|
|
|
RepairPrice = RepairPrice
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListRepairs");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult DeleteRepair()
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Repairs = APIGuarantor.GetRequest<List<RepairViewModel>>($"api/main/getrepairlist?guarantorId={APIGuarantor.Guarantor.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteRepair(int repair)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/deleterepair", new RepairBindingModel { Id = repair });
|
|
|
|
|
Response.Redirect("ListRepairs");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//......................................................... Работа..............................................................................
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2024-04-30 20:36:13 +04:00
|
|
|
|
public IActionResult ListWorks()
|
|
|
|
|
{
|
2024-05-27 23:35:42 +04:00
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIGuarantor.GetRequest<List<WorkViewModel>>($"api/main/getworklist?guarantorId={APIGuarantor.Guarantor.Id}"));
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public Tuple<WorkViewModel, string>? GetWork(int workId)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Необходима авторизация");
|
|
|
|
|
}
|
|
|
|
|
var result = APIGuarantor.GetRequest<Tuple<WorkViewModel, List<Tuple<string, string>>>>($"api/main/getwork?workId={workId}");
|
|
|
|
|
if (result == null) return default;
|
|
|
|
|
string table = "";
|
|
|
|
|
for (int i = 0; i < result.Item2.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var sparepartName = result.Item2[i].Item1;
|
|
|
|
|
var sparepartPrice = result.Item2[i].Item2;
|
|
|
|
|
table += "<tr>";
|
|
|
|
|
table += $"<td>{sparepartName}</td>";
|
|
|
|
|
table += $"<td>{sparepartPrice}</td>";
|
|
|
|
|
table += "</tr>";
|
|
|
|
|
}
|
|
|
|
|
return Tuple.Create(result.Item1, table);
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
public IActionResult CreateWork()
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateWork(string WorkName, double WorkPrice)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/creatework", new WorkBindingModel
|
|
|
|
|
{
|
|
|
|
|
GuarantorId = APIGuarantor.Guarantor.Id,
|
|
|
|
|
WorkName = WorkName,
|
|
|
|
|
WorkPrice = WorkPrice,
|
|
|
|
|
Status = ServiceStationDataModels.Enums.WorkStatus.Принята
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListWorks");
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
public IActionResult UpdateWork()
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Works = APIGuarantor.GetRequest<List<WorkViewModel>>($"api/main/getworklist?guarantorId={APIGuarantor.Guarantor.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateWork(int work, string WorkName, double WorkPrice)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(WorkName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Введите название работы");
|
|
|
|
|
}
|
|
|
|
|
if (WorkPrice < 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Цена работы не может быть меньше 0");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/updatework", new WorkBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = work,
|
|
|
|
|
WorkName = WorkName,
|
|
|
|
|
GuarantorId = APIGuarantor.Guarantor.Id,
|
|
|
|
|
WorkPrice = WorkPrice,
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("ListWorks");
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
public IActionResult DeleteWork()
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Works = APIGuarantor.GetRequest<List<WorkViewModel>>($"api/main/getworklist?guarantorId={APIGuarantor.Guarantor.Id}");
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void DeleteWork(int work)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/deletework", new WorkBindingModel { Id = work });
|
|
|
|
|
Response.Redirect("ListWorks");
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateWorkStatus(int work, string status)
|
2024-04-30 20:36:13 +04:00
|
|
|
|
{
|
2024-05-27 23:35:42 +04:00
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
if (status == "Отдать на выполнение")
|
|
|
|
|
{
|
|
|
|
|
APIGuarantor.PostRequest("api/main/updateworkstatusexecution", new WorkBindingModel { Id = work, Status = ServiceStationDataModels.Enums.WorkStatus.Выполняется});
|
|
|
|
|
}
|
|
|
|
|
if (status == "Готова")
|
|
|
|
|
{
|
|
|
|
|
APIGuarantor.PostRequest("api/main/updateworkstatusexecution", new WorkBindingModel { Id = work, Status = ServiceStationDataModels.Enums.WorkStatus.Готова});
|
|
|
|
|
}
|
|
|
|
|
Response.Redirect("ListWorks");
|
2024-04-30 20:36:13 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
public IActionResult UpdateWorkStatus()
|
2024-04-30 20:36:13 +04:00
|
|
|
|
{
|
2024-05-27 23:35:42 +04:00
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
ViewBag.Works = APIGuarantor.GetRequest<List<WorkViewModel>>($"api/main/getworklist?guarantorId={APIGuarantor.Guarantor.Id}");
|
2024-04-30 20:36:13 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2024-05-27 23:35:42 +04:00
|
|
|
|
public IActionResult AddSparepartToRepair()
|
2024-04-30 20:36:13 +04:00
|
|
|
|
{
|
2024-05-27 23:35:42 +04:00
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(Tuple.Create(APIGuarantor.GetRequest<List<RepairViewModel>>($"api/main/getrepairlist?guarantorId={APIGuarantor.Guarantor.Id}"),
|
|
|
|
|
APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}")));
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
2024-05-27 23:35:42 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void AddSparepartToRepair(int repair, int[] sparepart)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/addspareparttorepair", Tuple.Create(new RepairSearchModel() { Id = repair }, sparepart));
|
|
|
|
|
Response.Redirect("ListRepairs");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult AddSparepartToWork()
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
return RedirectToAction("Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(Tuple.Create(APIGuarantor.GetRequest<List<WorkViewModel>>($"api/main/getworklist?guarantorId={APIGuarantor.Guarantor.Id}"),
|
|
|
|
|
APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void AddSparepartToWork(int work, int[] sparepart)
|
|
|
|
|
{
|
|
|
|
|
if (APIGuarantor.Guarantor == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Авторизуйтесь");
|
|
|
|
|
}
|
|
|
|
|
APIGuarantor.PostRequest("api/main/addspareparttowork", Tuple.Create(new WorkSearchModel() { Id = work }, sparepart));
|
|
|
|
|
Response.Redirect("ListWorks");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult ListDefectSparePartToFile()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult ListSparePartsToPdfFile()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-04-30 20:36:13 +04:00
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult BindingRepairToDefects()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|