Merge pull request 'бизнес_логика_rest_api_исполнитель' (#14) from бизнес_логика_rest_api_исполнитель into main
Reviewed-on: #14
This commit is contained in:
commit
aecee9325c
@ -4,6 +4,7 @@ using ServiceStationContracts.BusinessLogicsContracts;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.StoragesContracts;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -83,6 +84,44 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AddCarToDefect(DefectSearchModel model, int[] cars)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("AddCarToDefect. DefectName:{DefectName}. Id:{Id}", model.DefectType, model.Id);
|
||||
var element = _defectStorage.GetElement(model);
|
||||
|
||||
if(element == null)
|
||||
{
|
||||
_logger.LogWarning("AddCarToDefect element not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddCarToDefect find. Id:{Id}", element.Id);
|
||||
|
||||
foreach(int car in cars)
|
||||
{
|
||||
if (!element.DefectCars.Keys.Contains(car))
|
||||
{
|
||||
element.DefectCars.Add(car, new CarViewModel() { Id = car });
|
||||
}
|
||||
}
|
||||
|
||||
_defectStorage.Update(new DefectBindingModel()
|
||||
{
|
||||
Id = element.Id,
|
||||
DefectPrice = element.DefectPrice,
|
||||
DefectType = element.DefectType,
|
||||
ExecutorId = element.ExecutorId,
|
||||
RepairId = element.RepairId,
|
||||
DefectCars = element.DefectCars,
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(DefectBindingModel model, bool withParams = true)
|
||||
{
|
||||
if(model == null)
|
||||
|
@ -83,6 +83,44 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AddCarToTechnicalWork(TechnicalWorkSearchModel model, int[] cars)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("AddCarToTechnicalWork. WorkType:{worktype}. Id:{Id}", model.WorkType, model.Id);
|
||||
var element = _technicalWorkStorage.GetElement(model);
|
||||
|
||||
if(element == null)
|
||||
{
|
||||
_logger.LogWarning("AddCarToTechnicalWork element not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddCarToTechnicalWork find. Id:{Id}", element.Id);
|
||||
|
||||
foreach(int car in cars)
|
||||
{
|
||||
if (!element.TechnicalWorkCars.Keys.Contains(car))
|
||||
{
|
||||
element.TechnicalWorkCars.Add(car, new CarViewModel() { Id = car });
|
||||
}
|
||||
}
|
||||
|
||||
_technicalWorkStorage.Update(new TechnicalWorkBindingModel
|
||||
{
|
||||
Id = element.Id,
|
||||
WorkType = element.WorkType,
|
||||
WorkPrice = element.WorkPrice,
|
||||
DateStartWork = element.DateStartWork,
|
||||
TechnicalWorkCars = element.TechnicalWorkCars,
|
||||
ExecutorId = element.ExecutorId,
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(TechnicalWorkBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -17,5 +17,6 @@ namespace ServiceStationContracts.BusinessLogicsContracts
|
||||
bool Create(DefectBindingModel model);
|
||||
bool Update(DefectBindingModel model);
|
||||
bool Delete(DefectBindingModel model);
|
||||
bool AddCarToDefect(DefectSearchModel model, int[] cars);
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,7 @@ namespace ServiceStationContracts.BusinessLogicsContracts
|
||||
bool Create(TechnicalWorkBindingModel model);
|
||||
bool Update(TechnicalWorkBindingModel model);
|
||||
bool Delete(TechnicalWorkBindingModel model);
|
||||
bool AddCarToTechnicalWork(TechnicalWorkSearchModel model, int[] cars);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ namespace ServiceStationContracts.SearchModels
|
||||
public string? ExecutorFIO { get; set; }
|
||||
public string? ExecutorNumber { get; set; }
|
||||
public string? ExecutorEmail { get; set; }
|
||||
public string? ExecutorPassword { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ServiceStationDataModels\ServiceStationDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ServiceStationContracts.ViewModels
|
||||
{
|
||||
@ -24,5 +24,13 @@ namespace ServiceStationContracts.ViewModels
|
||||
public int? RepairId { get; set; }
|
||||
|
||||
public Dictionary<int, ICarModel> DefectCars { get; set; } = new();
|
||||
|
||||
public DefectViewModel() { }
|
||||
|
||||
[JsonConstructor]
|
||||
public DefectViewModel(Dictionary<int, CarViewModel> DefectCars)
|
||||
{
|
||||
this.DefectCars = DefectCars.ToDictionary(x => x.Key, x => x.Value as ICarModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using ServiceStationDataModels.Models;
|
||||
using Newtonsoft.Json;
|
||||
using ServiceStationDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -21,5 +22,13 @@ namespace ServiceStationContracts.ViewModels
|
||||
public int ExecutorId { get; set; }
|
||||
|
||||
public Dictionary<int, ICarModel> TechnicalWorkCars { get; set; } = new();
|
||||
|
||||
public TechnicalWorkViewModel() { }
|
||||
|
||||
[JsonConstructor]
|
||||
public TechnicalWorkViewModel(Dictionary<int, CarViewModel> TechnicalWorkCars)
|
||||
{
|
||||
this.TechnicalWorkCars = TechnicalWorkCars.ToDictionary(x => x.Key, x => x.Value as ICarModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.Include(x => x.Repair)
|
||||
.Include(x => x.Executor)
|
||||
.Where(x => x.ExecutorId == model.ExecutorId)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -40,15 +40,15 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
public ExecutorViewModel? GetElement(ExecutorSearchModel model)
|
||||
{
|
||||
using var context = new ServiceStationDatabase();
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.ExecutorNumber)) return null;
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.ExecutorNumber) && string.IsNullOrEmpty(model.ExecutorPassword)) return null;
|
||||
|
||||
if (!string.IsNullOrEmpty(model.ExecutorNumber))
|
||||
if (!string.IsNullOrEmpty(model.ExecutorNumber) && !string.IsNullOrEmpty(model.ExecutorPassword))
|
||||
{
|
||||
return context.Executors
|
||||
.Include(x => x.Cars)
|
||||
.Include(x => x.Defects)
|
||||
.Include(x => x.TechnicalWorks)
|
||||
.FirstOrDefault(x => x.ExecutorNumber.Contains(model.ExecutorNumber))?
|
||||
.FirstOrDefault(x => x.ExecutorNumber.Contains(model.ExecutorNumber) && x.ExecutorPassword.Contains(model.ExecutorPassword))?
|
||||
.GetViewModel;
|
||||
}
|
||||
return context.Executors
|
||||
|
@ -68,7 +68,6 @@ namespace ServiceStationDatabaseImplement.Models
|
||||
{
|
||||
WorkType = model.WorkType;
|
||||
WorkPrice = model.WorkPrice;
|
||||
DateStartWork = model.DateStartWork;
|
||||
ExecutorId = model.ExecutorId;
|
||||
}
|
||||
public TechnicalWorkViewModel GetViewModel => new()
|
||||
|
@ -1,4 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationExecutorApp.Models;
|
||||
using System.Collections.Generic;
|
||||
@ -22,144 +24,418 @@ namespace ServiceStationExecutorApp.Controllers
|
||||
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
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");
|
||||
}
|
||||
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[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");
|
||||
}
|
||||
public IActionResult Register()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(string fio, string executorNumber, string password, string email)
|
||||
{
|
||||
if(string.IsNullOrEmpty(fio) || string.IsNullOrEmpty(executorNumber) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
|
||||
{
|
||||
throw new Exception("Введены не все данные");
|
||||
}
|
||||
APIExecutor.PostRequest("api/executor/register", new ExecutorBindingModel
|
||||
{
|
||||
ExecutorNumber = executorNumber,
|
||||
ExecutorEmail = email,
|
||||
ExecutorFIO = fio,
|
||||
ExecutorPassword = password
|
||||
});
|
||||
Response.Redirect("Enter");
|
||||
return;
|
||||
}
|
||||
public IActionResult ListCars()
|
||||
{
|
||||
var cars = new List<CarViewModel>();
|
||||
cars.Add(new CarViewModel
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
Id = 1,
|
||||
CarNumber = "111",
|
||||
CarBrand = "lamba",
|
||||
ExecutorId = 1
|
||||
});
|
||||
|
||||
return View(cars);
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
return View(APIExecutor.GetRequest<List<CarViewModel>>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}"));
|
||||
}
|
||||
public IActionResult ListDefects()
|
||||
{
|
||||
var defects = new List<DefectViewModel>();
|
||||
defects.Add(new DefectViewModel
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
Id = 1,
|
||||
DefectType = "type1",
|
||||
DefectPrice = 100.0,
|
||||
ExecutorId = 1
|
||||
});
|
||||
|
||||
return View(defects);
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
return View(APIExecutor.GetRequest<List<DefectViewModel>>($"api/main/getdefectlist?executorId={APIExecutor.Executor.Id}"));
|
||||
}
|
||||
public IActionResult ListTechnicalWorks()
|
||||
{
|
||||
var technicalWorks = new List<TechnicalWorkViewModel>();
|
||||
technicalWorks.Add(new TechnicalWorkViewModel
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
Id = 1,
|
||||
WorkType = "type1",
|
||||
DateStartWork = DateTime.Now,
|
||||
WorkPrice = 100.0,
|
||||
ExecutorId = 1
|
||||
});
|
||||
|
||||
return View(technicalWorks);
|
||||
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);
|
||||
}
|
||||
public IActionResult DeleteCar()
|
||||
{
|
||||
ViewBag.Cars = new List<CarViewModel>();
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
ViewBag.Cars = APIExecutor.GetRequest<List<CarViewModel>>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}");
|
||||
return View();
|
||||
}
|
||||
[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");
|
||||
}
|
||||
public IActionResult DeleteDefect()
|
||||
{
|
||||
ViewBag.Defects = new List<DefectViewModel>();
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
ViewBag.Defects = APIExecutor.GetRequest<List<DefectViewModel>>($"api/main/getdefectlist?executorId={APIExecutor.Executor.Id}");
|
||||
return View();
|
||||
}
|
||||
[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");
|
||||
}
|
||||
public IActionResult DeleteTechnicalWork()
|
||||
{
|
||||
ViewBag.TechnicalWorks = new List<TechnicalWorkViewModel>();
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
ViewBag.TechnicalWorks = APIExecutor.GetRequest<List<TechnicalWorkViewModel>>($"api/main/gettechnicalworklist?executorId={APIExecutor.Executor.Id}");
|
||||
return View();
|
||||
}
|
||||
[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");
|
||||
}
|
||||
public IActionResult UpdateCar()
|
||||
{
|
||||
ViewBag.Cars = new List<CarViewModel>();
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
ViewBag.Cars = APIExecutor.GetRequest<List<CarViewModel>>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}");
|
||||
return View();
|
||||
}
|
||||
[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");
|
||||
}
|
||||
public IActionResult UpdateDefect()
|
||||
{
|
||||
ViewBag.Defects = new List<DefectViewModel>();
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
ViewBag.Defects = APIExecutor.GetRequest<List<DefectViewModel>>($"api/main/getdefectlist?executorId={APIExecutor.Executor.Id}");
|
||||
return View();
|
||||
}
|
||||
[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");
|
||||
}
|
||||
public IActionResult UpdateTechnicalWork()
|
||||
{
|
||||
ViewBag.TechnicalWorks = new List<TechnicalWorkViewModel>();
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
ViewBag.TechnicalWorks = APIExecutor.GetRequest<List<TechnicalWorkViewModel>>($"api/main/gettechnicalworklist?executorId={APIExecutor.Executor.Id}");
|
||||
return View();
|
||||
}
|
||||
[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");
|
||||
}
|
||||
public IActionResult CreateCar()
|
||||
{
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[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");
|
||||
}
|
||||
public IActionResult CreateDefect()
|
||||
{
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[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");
|
||||
}
|
||||
public IActionResult CreateTechnicalWork()
|
||||
{
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[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");
|
||||
}
|
||||
public IActionResult AddCarToDefect()
|
||||
{
|
||||
var defect = new DefectViewModel
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
Id = 1,
|
||||
DefectType = "type1",
|
||||
DefectPrice = 1000.0,
|
||||
ExecutorId = 1
|
||||
};
|
||||
var car = new CarViewModel
|
||||
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)
|
||||
{
|
||||
Id = 1,
|
||||
CarNumber = "111",
|
||||
CarBrand = "lamba"
|
||||
};
|
||||
List<DefectViewModel> defects = new List<DefectViewModel>();
|
||||
List <CarViewModel> cars = new List<CarViewModel>();
|
||||
defects.Add(defect);
|
||||
cars.Add(car);
|
||||
return View(Tuple.Create(defects, cars));
|
||||
throw new Exception("Авторизироваться не забыли?");
|
||||
}
|
||||
APIExecutor.PostRequest("api/main/addcartodefect", Tuple.Create(
|
||||
new DefectSearchModel() { Id = defect },
|
||||
car
|
||||
));
|
||||
Response.Redirect("ListDefects");
|
||||
}
|
||||
public IActionResult AddCarToTechnicalWork()
|
||||
{
|
||||
var technicalWork = new TechnicalWorkViewModel
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
Id = 1,
|
||||
WorkType = "type1",
|
||||
WorkPrice = 1000.0,
|
||||
DateStartWork = DateTime.Now,
|
||||
ExecutorId = 1
|
||||
};
|
||||
var car = new CarViewModel
|
||||
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)
|
||||
{
|
||||
Id = 1,
|
||||
CarNumber = "111",
|
||||
CarBrand = "lamba"
|
||||
};
|
||||
List<TechnicalWorkViewModel> technicalWorks = new List<TechnicalWorkViewModel>();
|
||||
List <CarViewModel> cars = new List<CarViewModel>();
|
||||
technicalWorks.Add(technicalWork);
|
||||
cars.Add(car);
|
||||
return View(Tuple.Create(technicalWorks, cars));
|
||||
throw new Exception("Авторизироваться не забыли?");
|
||||
}
|
||||
APIExecutor.PostRequest("api/main/addcartotechnicalwork", Tuple.Create(
|
||||
new TechnicalWorkSearchModel() { Id = technicalWork },
|
||||
car
|
||||
));
|
||||
Response.Redirect("ListTechnicalWorks");
|
||||
}
|
||||
public IActionResult BindingTechnicalWorkToWork()
|
||||
{
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
var technicalWork = new TechnicalWorkViewModel
|
||||
{
|
||||
Id = 1,
|
||||
@ -175,40 +451,24 @@ namespace ServiceStationExecutorApp.Controllers
|
||||
WorkPrice = 1000.0,
|
||||
Status = ServiceStationDataModels.Enums.WorkStatus.Принята
|
||||
};
|
||||
List<TechnicalWorkViewModel> technicalWorks = new List<TechnicalWorkViewModel>();
|
||||
List <WorkViewModel> works = new List<WorkViewModel>();
|
||||
technicalWorks.Add(technicalWork);
|
||||
List<WorkViewModel> works = new();
|
||||
works.Add(work);
|
||||
return View(Tuple.Create(technicalWorks, works));
|
||||
return View(Tuple.Create(APIExecutor.GetRequest<List<TechnicalWorkViewModel>>($"api/main/gettechnicalworklist?executorId={APIExecutor.Executor.Id}"), works));
|
||||
}
|
||||
public IActionResult ListWorkToFile()
|
||||
{
|
||||
var car = new CarViewModel
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
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);
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
return View(APIExecutor.GetRequest<List<CarViewModel>>($"api/main/getcarlist?executorId={APIExecutor.Executor.Id}"));
|
||||
}
|
||||
public IActionResult ListCarsToPdf()
|
||||
{
|
||||
if (APIExecutor.Executor == null)
|
||||
{
|
||||
return RedirectToAction("Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
using ServiceStationExecutorApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
APIExecutor.Connect(builder.Configuration);
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
|
@ -1,4 +1,4 @@
|
||||
@using ServiceStationContracts.ViewModels;
|
||||
@using ServiceStationContracts.ViewModels;
|
||||
@using ServiceStationDataModels.Models;
|
||||
|
||||
@{
|
||||
@ -8,7 +8,7 @@
|
||||
@model Tuple<List<TechnicalWorkViewModel>, List<WorkViewModel>>
|
||||
|
||||
<div class="container w-50">
|
||||
<h2>Добавление машин к неисправностям:</h2>
|
||||
<h2>Привязка ТО к работе:</h2>
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label for="technicalWork">Выберите ТО</label>
|
||||
|
@ -24,7 +24,7 @@
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr style="height: 75px">
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr style="height: 75px">
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
|
@ -27,7 +27,7 @@
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr style="height: 75px">
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
<div class="text-center">
|
||||
<h2>
|
||||
Создание отчета по машинам
|
||||
Создание списка работ
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
|
@ -1,6 +1,52 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
@using ServiceStationContracts.ViewModels
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
@model ExecutorViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Privacy";
|
||||
}
|
||||
<head>
|
||||
<link rel="stylesheet" asp-append-version="true" />
|
||||
</head>
|
||||
<div class="text-center">
|
||||
<h2 > Мои данные </h2>
|
||||
</div>
|
||||
<form method="post" class="justify-content-center align-items-center container text-center">
|
||||
<div>
|
||||
<label>Электронная почта</label>
|
||||
<input
|
||||
type="email"
|
||||
placeholder="Введите электронную почту"
|
||||
name="email"
|
||||
class="form-control w-50 mx-auto mx-aut"
|
||||
value="@Model.ExecutorEmail" />
|
||||
</div>
|
||||
<div>
|
||||
<label>ФИО</label>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Введите ФИО"
|
||||
name="fio"
|
||||
class="form-control w-50 mx-auto"
|
||||
value="@Model.ExecutorFIO" />
|
||||
</div>
|
||||
<div>
|
||||
<label>Номер телефона</label>
|
||||
<input
|
||||
type="text"
|
||||
name="number"
|
||||
value="@Model.ExecutorNumber"
|
||||
class="form-control w-50 mx-auto"
|
||||
placeholder="Введите номер телефона"/>
|
||||
</div>
|
||||
<div>
|
||||
<label>Пароль</label>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Введите пароль"
|
||||
name="password"
|
||||
class="form-control w-50 mx-auto"
|
||||
value="@Model.ExecutorPassword" />
|
||||
</div>
|
||||
<div class="py-3"><input type="submit" class="btn btn-secondary text-center" value="Изменить" /></div>
|
||||
</form>
|
@ -26,7 +26,7 @@
|
||||
<th scope="col">Марка машины</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody id="table-elements">
|
||||
@* полученные машины *@
|
||||
</tbody>
|
||||
</table>
|
||||
@ -37,3 +37,27 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var defect = $('#defect').val();
|
||||
if (defect) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetDefect",
|
||||
data: { defectId: defect },
|
||||
success: function (result) {
|
||||
$('#defectType').val(result.item1.defectType);
|
||||
$('#table-elements').html(result.item2);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#defect').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
<div class="card-body ">
|
||||
<div class="form-group">
|
||||
<label>ТО: </label>
|
||||
<select id="technicalWork" name="technicalWork" class="form-control" asp-items="@(new SelectList(@ViewBag.TechnicalWorks, "Id", "TechnicalWorkType", "TechnicalWorkPrice"))"></select>
|
||||
<select id="technicalWork" name="technicalWork" class="form-control" asp-items="@(new SelectList(@ViewBag.TechnicalWorks, "Id", "WorkType", "WorkPrice"))"></select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Тип ТО</label>
|
||||
@ -26,7 +26,7 @@
|
||||
<th scope="col">Марка машины</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody id="table-elements">
|
||||
@* полученные машины *@
|
||||
</tbody>
|
||||
</table>
|
||||
@ -38,3 +38,28 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var technicalWork = $('#technicalWork').val();
|
||||
if (technicalWork) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetTechnicalWork",
|
||||
data: { technicalWorkId: technicalWork },
|
||||
success: function (result) {
|
||||
$('#technicalWorkType').val(result.item1.WorkType);
|
||||
$('#table-elements').html(result.item2);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#technicalWork').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,5 +5,7 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
|
||||
"IPAddress": "https://localhost:7288/"
|
||||
}
|
||||
|
@ -0,0 +1,66 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.BusinessLogicsContracts;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
|
||||
namespace ServiceStationRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ExecutorController : Controller
|
||||
{
|
||||
private readonly IExecutorLogic _elogic;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public ExecutorController(IExecutorLogic elogic, ILogger<ExecutorController> logger)
|
||||
{
|
||||
_elogic = elogic;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Register(ExecutorBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_elogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка регистрации");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public ExecutorViewModel? Login(string executorNumber, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _elogic.ReadElement(new ExecutorSearchModel
|
||||
{
|
||||
ExecutorNumber = executorNumber,
|
||||
ExecutorPassword = password
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateExecutor(ExecutorBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_elogic.Update(model);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления данных");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,9 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.BusinessLogicsContracts;
|
||||
using ServiceStationContracts.SearchModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationDatabaseImplement.Models;
|
||||
|
||||
namespace ServiceStationRestApi.Controllers
|
||||
{
|
||||
@ -6,6 +11,239 @@ namespace ServiceStationRestApi.Controllers
|
||||
[ApiController]
|
||||
public class MainController : Controller
|
||||
{
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarLogic _clogic;
|
||||
private readonly IDefectLogic _dlogic;
|
||||
private readonly ITechnicalWorkLogic _tlogic;
|
||||
|
||||
public MainController(ILogger<MainController> logger, ICarLogic clogic, IDefectLogic dlogic, ITechnicalWorkLogic tlogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_clogic = clogic;
|
||||
_dlogic = dlogic;
|
||||
_tlogic = tlogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CarViewModel>? GetCarList(int executorId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _clogic.ReadList(new CarSearchModel
|
||||
{
|
||||
ExecutorId = executorId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка машин");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<DefectViewModel>? GetDefectList(int executorId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _dlogic.ReadList(new DefectSearchModel
|
||||
{
|
||||
ExecutorId = executorId
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка неисправностей");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<TechnicalWorkViewModel>? GetTechnicalWorkList(int executorId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _tlogic.ReadList(new TechnicalWorkSearchModel
|
||||
{
|
||||
ExecutorId = executorId
|
||||
});
|
||||
}
|
||||
catch( Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка ТО");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateCar(CarBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_clogic.Create(model);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания машины");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateDefect(DefectBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dlogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания неисправности");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateTechnicalWork(TechnicalWorkBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_tlogic.Create(model);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания ТО");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteCar(CarBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_clogic.Delete(model);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления машины");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteDefect(DefectBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dlogic.Delete(model);
|
||||
}
|
||||
catch( Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления неисправности");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteTechnicalWork(TechnicalWorkBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_tlogic.Delete(model);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления ТО");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateCar(CarBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_clogic.Update(model);
|
||||
}
|
||||
catch( Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления машины");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateDefect(DefectBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dlogic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления неисправности");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateTechnicalWork(TechnicalWorkBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_tlogic.Update(model);
|
||||
}
|
||||
catch( Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления ТО");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void AddCarToDefect(Tuple<DefectSearchModel, int[]> model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dlogic.AddCarToDefect(model.Item1, model.Item2);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка добавления машины в неисправность.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void AddCarToTechnicalWork(Tuple<TechnicalWorkSearchModel, int[]> model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_tlogic.AddCarToTechnicalWork(model.Item1, model.Item2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка добавления машины в ТО.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public Tuple<DefectViewModel, List<Tuple<string, string>>>? GetDefect(int defectId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _dlogic.ReadElement(new DefectSearchModel { Id = defectId });
|
||||
if (elem == null) return null;
|
||||
return Tuple.Create(elem, elem.DefectCars.Select(x => Tuple.Create(x.Value.CarNumber, x.Value.CarBrand)).ToList());
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения машины по id={Id}", defectId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public Tuple<TechnicalWorkViewModel, List<Tuple<string,string>>>? GetTechnicalWork(int technicalWorkId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _tlogic.ReadElement(new TechnicalWorkSearchModel { Id = technicalWorkId });
|
||||
if (elem == null) return null;
|
||||
return Tuple.Create(elem, elem.TechnicalWorkCars.Select(x => Tuple.Create(x.Value.CarNumber, x.Value.CarBrand)).ToList());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения машины по id={Id}", technicalWorkId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user